diff --git a/lix/libutil/file-system.cc b/lix/libutil/file-system.cc index 60f2e91ff..4464fccf5 100644 --- a/lix/libutil/file-system.cc +++ b/lix/libutil/file-system.cc @@ -693,6 +693,11 @@ Path makeTempPath(const Path & root, const Path & suffix) return fmt("%1%%2%-%3%-%4%", root, suffix, getpid(), counter.fetch_add(1, std::memory_order_relaxed)); } +Path makeTempSiblingPath(const Path & path) +{ + return makeTempPath(fs::path(path).remove_filename()); +} + void createSymlink(const Path & target, const Path & link) { if (symlink(target.c_str(), link.c_str())) diff --git a/lix/libutil/file-system.hh b/lix/libutil/file-system.hh index 8b9100bdc..cdcb61a65 100644 --- a/lix/libutil/file-system.hh +++ b/lix/libutil/file-system.hh @@ -318,6 +318,11 @@ Path createTempSubdir(const Path & parent, const Path & prefix = "nix", */ Path makeTempPath(const Path & root, const Path & suffix = ".tmp"); +/** + * Return temporary path in the same directory as a given path. + */ +Path makeTempSiblingPath(const Path & root); + /** * Used in various places. */