From f8a92564f72057dc697f3ae694c959b9cd2b95bf Mon Sep 17 00:00:00 2001 From: Sergei Zimmerman Date: Sat, 10 Jan 2026 21:48:43 +0300 Subject: [PATCH] More std::filesystem::path for nix {cat,ls} Also fixes a double quoting issue I accidentally introduced ccdd1f1c65a7326f41d698a522a1102347af7f41 in seekableGetNarBytes. --- src/libutil/nar-accessor.cc | 2 +- src/nix/cat.cc | 6 +++--- src/nix/ls.cc | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/libutil/nar-accessor.cc b/src/libutil/nar-accessor.cc index 7387007e6..4cc956bbb 100644 --- a/src/libutil/nar-accessor.cc +++ b/src/libutil/nar-accessor.cc @@ -268,7 +268,7 @@ GetNarBytes seekableGetNarBytes(const std::filesystem::path & path) { AutoCloseFD fd = openFileReadonly(path); if (!fd) - throw NativeSysError("opening NAR cache file '%s'", path); + throw NativeSysError("opening NAR cache file %s", path); return [inner = seekableGetNarBytes(fd.get()), fd = make_ref(std::move(fd))]( uint64_t offset, uint64_t length) { return inner(offset, length); }; diff --git a/src/nix/cat.cc b/src/nix/cat.cc index dcf47f1fa..5b2a309a6 100644 --- a/src/nix/cat.cc +++ b/src/nix/cat.cc @@ -52,7 +52,7 @@ struct CmdCatStore : StoreCommand, MixCat struct CmdCatNar : StoreCommand, MixCat { - Path narPath; + std::filesystem::path narPath; std::string path; @@ -76,9 +76,9 @@ struct CmdCatNar : StoreCommand, MixCat void run(ref store) override { - AutoCloseFD fd = toDescriptor(open(narPath.c_str(), O_RDONLY)); + AutoCloseFD fd = openFileReadonly(narPath); if (!fd) - throw SysError("opening NAR file '%s'", narPath); + throw NativeSysError("opening NAR file %s", narPath); auto source = FdSource{fd.get()}; struct CatRegularFileSink : NullFileSystemObjectSink diff --git a/src/nix/ls.cc b/src/nix/ls.cc index 66f52a18a..9918132a6 100644 --- a/src/nix/ls.cc +++ b/src/nix/ls.cc @@ -126,7 +126,7 @@ struct CmdLsStore : StoreCommand, MixLs struct CmdLsNar : Command, MixLs { - Path narPath; + std::filesystem::path narPath; std::string path; @@ -150,9 +150,9 @@ struct CmdLsNar : Command, MixLs void run() override { - AutoCloseFD fd = toDescriptor(open(narPath.c_str(), O_RDONLY)); + AutoCloseFD fd = openFileReadonly(narPath); if (!fd) - throw SysError("opening NAR file '%s'", narPath); + throw NativeSysError("opening NAR file %s", narPath); auto source = FdSource{fd.get()}; list(makeLazyNarAccessor(source, seekableGetNarBytes(fd.get())), CanonPath{path}); }