Created
September 17, 2012 07:12
-
-
Save metametaclass/3735989 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BOOST_FILESYSTEM_DECL | |
bool create_directories(const path& p, system::error_code* ec) | |
{ | |
if (p.empty() || exists(p)) | |
{ | |
if (!p.empty() && !is_directory(p)) | |
{ | |
if (ec == 0) | |
BOOST_FILESYSTEM_THROW(filesystem_error( | |
"boost::filesystem::create_directories", p, | |
error_code(system::errc::file_exists, system::generic_category()))); | |
else ec->assign(system::errc::file_exists, system::generic_category()); | |
} | |
return false; | |
} | |
// First create branch, by calling ourself recursively | |
create_directories(p.parent_path(), ec); | |
// Now that parent's path exists, create the directory | |
create_directory(p, ec); | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment