diff --git a/include/tmp/directory b/include/tmp/directory index 3d71c0f..9c6438a 100644 --- a/include/tmp/directory +++ b/include/tmp/directory @@ -39,11 +39,20 @@ namespace tmp { class TMP_EXPORT directory : public entry { public: /// Creates a unique temporary directory - /// @param label A label to attach to the temporary directory path + /// @param[in] label A label to attach to the temporary directory path /// @throws std::filesystem::filesystem_error if cannot create a directory /// @throws std::invalid_argument if the label is ill-formatted explicit directory(std::string_view label = ""); + /// Creates a unique temporary directory + /// @param[out] ec Parameter for error reporting + explicit directory(std::error_code& ec); + + /// Creates a unique temporary directory + /// @param[in] label A label to attach to the temporary directory path + /// @param[out] ec Parameter for error reporting + explicit directory(std::string_view label, std::error_code& ec); + /// Creates a unique temporary copy recursively from the given path /// @param path A path to make a temporary copy from /// @param label A label to attach to the temporary directory path diff --git a/src/directory.cpp b/src/directory.cpp index c559d3f..94644d6 100644 --- a/src/directory.cpp +++ b/src/directory.cpp @@ -19,6 +19,12 @@ constexpr fs::copy_options copy_options = directory::directory(std::string_view label) : entry(create_directory(label)) {} +directory::directory(std::error_code& ec) + : entry(create_directory("", ec)) {} + +directory::directory(std::string_view label, std::error_code& ec) + : entry(create_directory(label, ec)) {} + directory directory::copy(const fs::path& path, std::string_view label) { directory tmpdir = directory(label);