Creates the directory
pas if by POSIX
mkdir()
with a second argument of
static_cast<int>(std::filesystem::perms::all)(the parent directory must already exist). If the function fails because
presolves to an existing directory, no error is reported. Otherwise on failure an error is reported.
3,4)Same as
(1,2), except that the attributes of the new directory are copied from
existing_p(which must be a directory that exists). It is OS-dependent which attributes are copied: on POSIX systems, the attributes are copied as if by
stat(existing_p.c_str(), &attributes_stat) mkdir(p.c_str(), attributes_stat.st_mode)
On Windows OS, no attributes of
existing_pare copied.
5,6) Executes (1,2) for every element of p that does not already exist. If p already exists, the function does nothing (this condition is not treated as an error).
[edit] Parameters p - the path to the new directory to create existing_p - the path to a directory to copy the attributes from ec - out-parameter for error reporting in the non-throwing overload [edit] Return valuetrue if a directory was newly created for the directory p resolves to, false otherwise.
[edit] ExceptionsAny overload not marked noexcept
may throw std::bad_alloc if memory allocation fails.
Throws
std::filesystem::filesystem_erroron underlying OS API errors, constructed with
pas the first path argument and the OS error code as the error code argument.
2,6)Sets a
std::error_code¶meter to the OS API error code if an OS API call fails, and executes
ec.clear()if no errors occur.
3)Throws
std::filesystem::filesystem_erroron underlying OS API errors, constructed with
pas the first path argument,
existing_pas the second path argument, and the OS error code as the error code argument.
4)Sets a
std::error_code¶meter to the OS API error code if an OS API call fails, and executes
ec.clear()if no errors occur.
[edit] NotesThe attribute-preserving overload (3,4) is implicitly invoked by copy() when recursively copying directories. Its equivalent in boost.filesystem is copy_directory
(with argument order reversed).
Possible output:
drwxr-xr-x 2 user group 4096 Apr 15 09:33 a drwxr-x--- 2 user group 4096 Apr 15 09:33 b drwxr-x--- 2 user group 4096 Apr 15 09:33 c sandbox âââ 1 âââ 2 âââ a âââ b âââ c[edit] Defect reports
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
DR Applied to Behavior as published Correct behavior LWG 2935 C++17 error if target already exists but is not a directory not error LWG 3014 C++17error_code
overload of create_directories
marked noexcept but can allocate memory noexcept removed P1164R1 C++17 creation failure caused by an existing non-directory file is not an error made error [edit] See also
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4