summaryrefslogtreecommitdiff
path: root/nix/libutil/archive.cc
diff options
context:
space:
mode:
Diffstat (limited to 'nix/libutil/archive.cc')
-rw-r--r--nix/libutil/archive.cc15
1 files changed, 8 insertions, 7 deletions
diff --git a/nix/libutil/archive.cc b/nix/libutil/archive.cc
index 54bcd21f936..0df5285860b 100644
--- a/nix/libutil/archive.cc
+++ b/nix/libutil/archive.cc
@@ -6,6 +6,7 @@
6#include <algorithm> 6#include <algorithm>
7#include <vector> 7#include <vector>
8#include <map> 8#include <map>
9#include <format>
9 10
10#include <strings.h> // for strcasecmp 11#include <strings.h> // for strcasecmp
11 12
@@ -35,7 +36,7 @@ static void dumpContents(const Path & path, size_t size,
35 writeLongLong(size, sink); 36 writeLongLong(size, sink);
36 37
37 AutoCloseFD fd = open(path.c_str(), O_RDONLY); 38 AutoCloseFD fd = open(path.c_str(), O_RDONLY);
38 if (fd == -1) throw SysError(format("opening file `%1%'") % path); 39 if (fd == -1) throw SysError(std::format("opening file `{}'", path));
39 40
40 unsigned char buf[65536]; 41 unsigned char buf[65536];
41 size_t left = size; 42 size_t left = size;
@@ -55,7 +56,7 @@ static void dump(const Path & path, Sink & sink, PathFilter & filter)
55{ 56{
56 struct stat st; 57 struct stat st;
57 if (lstat(path.c_str(), &st)) 58 if (lstat(path.c_str(), &st))
58 throw SysError(format("getting attributes of path `%1%'") % path); 59 throw SysError(std::format("getting attributes of path `{}'", path));
59 60
60 writeString("(", sink); 61 writeString("(", sink);
61 62
@@ -98,7 +99,7 @@ static void dump(const Path & path, Sink & sink, PathFilter & filter)
98 writeString(readLink(path), sink); 99 writeString(readLink(path), sink);
99 } 100 }
100 101
101 else throw Error(format("file `%1%' has an unsupported type") % path); 102 else throw Error(std::format("file `{}' has an unsupported type", path));
102 103
103 writeString(")", sink); 104 writeString(")", sink);
104} 105}
@@ -227,7 +228,7 @@ static void parse(ParseSink & sink, Source & source, const Path & path)
227 } else if (s == "name") { 228 } else if (s == "name") {
228 name = readString(source); 229 name = readString(source);
229 if (name.empty() || name == "." || name == ".." || name.find('/') != string::npos || name.find((char) 0) != string::npos) 230 if (name.empty() || name == "." || name == ".." || name.find('/') != string::npos || name.find((char) 0) != string::npos)
230 throw Error(format("NAR contains invalid file name `%1%'") % name); 231 throw Error(std::format("NAR contains invalid file name `{}'", name));
231 if (name <= prevName) 232 if (name <= prevName)
232 throw Error("NAR directory is not sorted"); 233 throw Error("NAR directory is not sorted");
233 prevName = name; 234 prevName = name;
@@ -274,7 +275,7 @@ struct RestoreSink : ParseSink
274 { 275 {
275 Path p = dstPath + path; 276 Path p = dstPath + path;
276 if (mkdir(p.c_str(), 0777) == -1) 277 if (mkdir(p.c_str(), 0777) == -1)
277 throw SysError(format("creating directory `%1%'") % p); 278 throw SysError(std::format("creating directory `{}'", p));
278 }; 279 };
279 280
280 void createRegularFile(const Path & path) 281 void createRegularFile(const Path & path)
@@ -282,7 +283,7 @@ struct RestoreSink : ParseSink
282 Path p = dstPath + path; 283 Path p = dstPath + path;
283 fd.close(); 284 fd.close();
284 fd = open(p.c_str(), O_CREAT | O_EXCL | O_WRONLY, 0666); 285 fd = open(p.c_str(), O_CREAT | O_EXCL | O_WRONLY, 0666);
285 if (fd == -1) throw SysError(format("creating file `%1%'") % p); 286 if (fd == -1) throw SysError(std::format("creating file `{}'", p));
286 } 287 }
287 288
288 void isExecutable() 289 void isExecutable()
@@ -304,7 +305,7 @@ struct RestoreSink : ParseSink
304 OpenSolaris). Since preallocation is just an 305 OpenSolaris). Since preallocation is just an
305 optimisation, ignore it. */ 306 optimisation, ignore it. */
306 if (errno && errno != EINVAL) 307 if (errno && errno != EINVAL)
307 throw SysError(format("preallocating file of %1% bytes") % len); 308 throw SysError(std::format("preallocating file of {} bytes", len));
308 } 309 }
309#endif 310#endif
310 } 311 }