std::experimental::filesystem::create_directory, std::experimental::filesystem::create_directories
Min standard notice:
Header: <experimental/filesystem>
- Creates the directory p as if by POSIX mkdir() with a second argument of static_cast
(fs::perms::all) (the parent directory must already exist). If p already exists and is already a directory, the function does nothing (this condition is not treated as an error).
# Declarations
bool create_directory( const path& p );
bool create_directory( const path& p, error_code& ec );
(filesystem TS)
bool create_directory( const path& p, const path& existing_p );
bool create_directory( const path& p, const path& existing_p, error_code& ec );
(filesystem TS)
bool create_directories( const path& p );
bool create_directories( const path& p, error_code& ec );
(filesystem TS)
# Parameters
p: the path to the new directory to createexisting_p: the path to a directory to copy the attributes fromec: out-parameter for error reporting in the non-throwing overload
# Notes
The attribute-preserving overload (2) is implicitly invoked by copy() when recursively copying directories. Its equivalent in boost.filesystem is copy_directory (with argument order reversed).
# Example
#include <cstdlib>
#include <experimental/filesystem>
#include <fstream>
#include <iostream>
namespace fs = std::experimental::filesystem;
int main()
{
fs::create_directories("sandbox/1/2/a");
fs::create_directory("sandbox/1/2/b");
fs::permissions("sandbox/1/2/b", fs::perms::remove_perms | fs::perms::others_all);
fs::create_directory("sandbox/1/2/c", "sandbox/1/2/b");
std::system("ls -l sandbox/1/2");
fs::remove_all("sandbox");
}