c++ how to create a directory from a path

前端 未结 5 1152
迷失自我
迷失自我 2020-12-20 15:06

what is a convenient way to create a directory when a path like this is given: \"\\server\\foo\\bar\\\"

note that the intermediate directories may not exist.

5条回答
  •  攒了一身酷
    2020-12-20 15:46

    I'd write a loop. Split the path into components, and "walk it", i.e. starting at the beginning, check to see if it exists. If it does, enter it and continue. If it does not, create it, enter it and continue. For bonus points, detect if a component exists, but is a file rather than an a directory.

提交回复
热议问题