Function rcpputils::fs::create_temporary_directory
Defined in File filesystem_helper.hpp
Function Documentation
-
std::filesystem::path rcpputils::fs::create_temporary_directory(const std::string &base_name, const std::filesystem::path &parent_path = std::filesystem::temp_directory_path(), size_t max_tries = 1000)
Construct a uniquely named temporary directory, in “parent”, with format base_nameXXXXXX The output, if successful, is guaranteed to be a newly-created directory. The underlying implementation keeps generating paths until one that does not exist is found or until the number of iterations exceeded the maximum tries. This guarantees that there will be no existing files in the returned directory.
- Parameters:
base_name – [in] User-specified portion of the created directory.
parent_path – [in] The parent path of the directory that will be created.
max_tries – [in] The maximum number of tries to find a unique directory (default 1000)
- Throws:
std::invalid_argument – If base_name contain directory-separator defined as std::filesystem::path::preferred_separator.
std::system_error – If any OS APIs do not succeed.
std::runtime_error – If the number of the iterations exceeds the maximum tries and a unique directory is not found.
- Returns:
A path to a newly created directory with base_name and a 6-character unique suffix.