diff --git a/lix/libstore/temporary-dir.cc b/lix/libstore/temporary-dir.cc index 102585e39..795e55d29 100644 --- a/lix/libstore/temporary-dir.cc +++ b/lix/libstore/temporary-dir.cc @@ -5,7 +5,7 @@ namespace nix { -Path createTempDir(const std::optional & prefix, mode_t mode) +Path createTempDir(const Path & prefix, mode_t mode) { return createTempSubdir(defaultTempDir(), prefix, mode); } diff --git a/lix/libstore/temporary-dir.hh b/lix/libstore/temporary-dir.hh index a2a9587b2..a2a8a0d18 100644 --- a/lix/libstore/temporary-dir.hh +++ b/lix/libstore/temporary-dir.hh @@ -8,7 +8,7 @@ namespace nix { /** * Create a temporary directory. */ -Path createTempDir(const std::optional & prefix = "nix", mode_t mode = 0755); +Path createTempDir(const Path & prefix = "nix", mode_t mode = 0755); /** * Create a temporary file, returning a file handle and its path. diff --git a/lix/libutil/file-system.cc b/lix/libutil/file-system.cc index 1390925a9..26ac4fa94 100644 --- a/lix/libutil/file-system.cc +++ b/lix/libutil/file-system.cc @@ -646,7 +646,7 @@ void AutoDelete::reset(const Path & p, bool recursive) { ////////////////////////////////////////////////////////////////////// -Path createTempSubdir(const Path & parent, const std::optional & prefix, +Path createTempSubdir(const Path & parent, const Path & prefix, mode_t mode) { checkInterrupt(); @@ -670,7 +670,7 @@ Path createTempSubdir(const Path & parent, const std::optional & prefix, throw SysError("creating directory '%1%'", tmpDir); } -Path makeTempPath(const Path & root, const std::optional & prefix) +Path makeTempPath(const Path & root, const Path & prefix) { static thread_local std::random_device generator{}; std::uniform_int_distribution uniform_dist{}; @@ -679,11 +679,7 @@ Path makeTempPath(const Path & root, const std::optional & prefix) reinterpret_cast(entropy), sizeof(entropy) )); - if (prefix) { - return fmt("%s%s-%s", root, *prefix, unique); - } else { - return root + unique; - } + return fmt("%s%s-%s", root, prefix, unique); } Path makeTempSiblingPath(const Path & path) diff --git a/lix/libutil/file-system.hh b/lix/libutil/file-system.hh index f615470fa..85af08fdb 100644 --- a/lix/libutil/file-system.hh +++ b/lix/libutil/file-system.hh @@ -307,16 +307,16 @@ typedef std::unique_ptr AutoCloseDir; /** * Create a temporary directory in a given parent directory. */ -Path createTempSubdir(const Path & parent, const std::optional & prefix = "nix", +Path createTempSubdir(const Path & parent, const Path & prefix = "nix", mode_t mode = 0755); /** * Return temporary path constructed by appending to a root path. * - * The constructed path looks like `[-]`. To create a + * The constructed path looks like `-`. To create a * path nested in a directory, provide a root ending with `/`. */ -Path makeTempPath(const Path & root, const std::optional & prefix = ".tmp"); +Path makeTempPath(const Path & root, const Path & prefix = ".tmp"); /** * Return temporary path in the same directory as a given path.