std::experimental::filesystem::create_directory,create_directories

From cppreference.com
< cpp‎ | experimental‎ | fs
Defined in header <experimental/filesystem>
bool create_directory( const path& p );
(1) (filesystem TS)
bool create_directory( const path& p, error_code& ec );
(2) (filesystem TS)
bool create_directory( const path& p, const path& existing_p );
(3) (filesystem TS)
bool create_directory( const path& p, const path& existing_p, error_code& ec );
(4) (filesystem TS)
bool create_directories( const path& p );
(5) (filesystem TS)
bool create_directories( const path& p, error_code& ec );
(6) (filesystem TS)

Creates directory that p resolves to. Directory creating failures caused by an already existing directory at p are not treated as errors.

1-4) Parent directories are not created. If parent directory of p does not exist, error occurs. (3-4) additionally copy operating system-dependent set of attributes from existing_p to the newly created directory.
5-6) If parent directory does not exist, any missing directories are created as if by call to create_directory.

true is returned on success, false on failure.

The (2), (4) and (6) overloads set ec to an appropriate error code if an error occurs. Otherwise, ec is cleared with a call to ec.clear().

Contents

[edit] Parameters

p - the path to the new directory to create
existing_p - the path to a directory to copy the attributes from
ec - error code to store the error status to

[edit] Return value

true if directory creation is successful, false otherwise.

[edit] Exceptions

1,3,5) filesystem_error if a directory can not be created or any other error occurs. The exception object is constructed with p (and existing_p in case of (3-4)) as an argument. The error code is set to appropriate operating system dependent value.
2,4,6)
noexcept specification:  
noexcept
  

[edit] Notes

On POSIX systems, new directories are created as if by calling mkdir(p.c_str(), S_IRWXU|S_IRWXG|S_IRWXO).

On POSIX systems, the attributes copied by (3-4) are those copied by mkdir(p.c_str(), attr.st_mode, where attr are retrieved as if by stat(existing_p.c_str(), &attr).

On Windows-based operating systems the attributes copied by (3-4) are those copied by native CreateDirectoryExW(existing_p.c_str(), p.c_str(), 0).

[edit] See also