Reputation: 15
just wanted to know if there are any drawbacks to using mkdir in C++ code? I've heard about the 'evils' of system and popen, particularly when talking about security concerns and memory usage... are there similar problems when using mkdir/getcwd/other direct unix commands like that in code? Thanks!
Upvotes: 0
Views: 559
Reputation: 1403
It's not portable to other OS's. If you are concerned about portability, try using Boost:
boost::filesystem::path dir("/path/to/newdir");
boost::filesystem::create_directory(dir);
Upvotes: 1
Reputation: 8052
The only issue you may run into while using mkdir
, getcwd
and the likes will be porting your program to different platforms.
Other than that, it is perfectly safe to use them.
Also - popen
and system
are not evil, but may be dangerous if used without care - something that applies to most system APIs.
Upvotes: 1