1

Make dir in C, linux doesnt create sub-dirs (dir tree) - why?

view story
linux-howto

http://stackoverflow.com – I want to create a dir tree in C on linux. I wrote that code: #include <sys/types.h> #include <sys/stat.h> #include <stdio.h> #include <stdlib.h> static int dirExists(const char *path) { struct stat info; if(stat( path, &info ) != 0) return 0; else if(info.st_mode & S_IFDIR) return 1; else return 0; } int main(int argc, char **argv) { const char *path = "./mydir/firstdir/"; if(!dirExists(path)) { mode_t mask = umask(0); if(mkdir(path, S_IRWXU | S_IRWXG | S_IRWXO) == -1) exit(-1) (HowTos)