开发者

Programmatically Recursively Make Directory

开发者 https://www.devze.com 2023-02-01 22:10 出处:网络
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 fa

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

精彩评论

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