how to give options like '-v' for mkdir using system call mkdir() ?
i've written a program which creates a directory using the system call mkdir()
int status; status = mkdir("myDirectory",S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); printf("%d",status); how can i execute 'mkdir -v' using this system call? is there another system call to include options? |
The mkdir command is different than the mkdir system call -- there is not a one-to-one correspondence between command options and system call options. To use the mkdir(2) system call in this manner, in your program, you'll need to tewst if each level of the parent directory (below the root) exists, and if not make it. Alternatively, you could just try to make the directory, check for the ENOENT error return and if you get it cycle through the path and find the missing component(s).
|
You can refer to the following urls related to mkdir "-p" option:
http://help.lockergnome.com/linux/mk...ict487118.html http://www.koders.com/cpp/fid3005DF8...aspx?s=mkdir_p The option -v from the manual of mkdir command: print a message for each created directory It is similar to the following codes: http://murugesan.webnode.com/technical/c/mkdir-v/ |
All times are GMT -5. The time now is 10:25 PM. |