Apparently, making sure a directory exists is an exceedingly complicated task: stackoverflow.com/questions/273192/create-directory-if-it-doesnt-exist-for-file-write