开发者

Programmatically Recursively Make Directory

I want my program to create a file located at the path of the command parameter, i.e. program /home/user/directory/that/doesnt/exist/file开发者_JAVA百科. If the directory doesn't exist, fopen will fail to open the file, so the program would have to create the directories. Would I have to program my own loop to detect each slash and mkdir each directory or is there a function to do this automatically?


Someone coded it for you: mkpath()

Or if you're satisfied using system(), then you can use system("mkdir -p /your/path/here");

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜