Prepare To Create Missing Directories #include /* standard input/output routines. */ #include /* strerror(), etc. */ #include /* unlnk(), etc. */ #include #include /* opendir(), etc. */ char* data_dir_path = "....."; /* check that the data directory exists. */ DIR* data_dir = opendir(data_dir_path); if (!data_dir) { /* cannot open directory - check why... */ switch(errno) { /* not a directory - remove this file first. */ case ENOTDIR: if (!unlink(data_dir_path)) { fprintf(stderr, "Data directory '%s' is actally a file!\n", data_dir_path); exit(1); /* give up. */ } /* FALL THROUGH */