I didn't find any relevant answer for this question.
I want to create a file and its parent directory at the same time:
example:
FILE *fd2 = fopen("test/test", "w+");
where test/ doesn't exist.
Is there a way to do this?
I didn't find any relevant answer for this question.
I want to create a file and its parent directory at the same time:
example:
FILE *fd2 = fopen("test/test", "w+");
where test/ doesn't exist.
Is there a way to do this?
In Linux you can do it with the following code
For the situation when file
test
exists in firstif
statement (stat
return value is zero), you can also check if this is a file or a directory using macrosS_ISREG
andS_ISDIR
and fieldst_mode
ofstat
struct.