#include "types.hh"
#include "serialise.hh"
#include "fs-sink.hh"
Go to the source code of this file.
|
constexpr std::string_view | nix::narVersionMagic1 = "nix-archive-1" |
|
constexpr std::string_view | nix::caseHackSuffix = "~nix~case~hack~" |
|
◆ copyNAR()
void nix::copyNAR |
( |
Source & | source, |
|
|
Sink & | sink ) |
Read a NAR from 'source' and write it to 'sink'.
◆ dumpPath()
void nix::dumpPath |
( |
const Path & | path, |
|
|
Sink & | sink, |
|
|
PathFilter & | filter = defaultPathFilter ) |
dumpPath creates a Nix archive of the specified path.
- Parameters
-
| path | the file system data to dump. Dumping is recursive so if this is a directory we dump it and all its children. |
[out] | sink | The serialised archive is fed into this sink. |
| filter | Can be used to skip certain files. |
The format is as follows:
IF
path points
to a REGULAR FILE:
[ ("type", "regular")
, (
"contents", contents(
path))
])
IF
path points
to a DIRECTORY:
[ ("type", "directory")
, (
"entries", concat(map(
f, sort(entries(
path)))))
])
[ ("name", fn)
, (
"file", dump(
path +
"/" + fn))
])
where:
attrs(as) = concat(map(attr, as)) + encN(0)
attrs((a, b)) = encS(a) + encS(b)
encS(
s) = encN(len(
s)) +
s + (padding until
next 64-bit boundary)
encN(n) = 64-bit little-endian encoding of n.
contents(
path) = the contents of a regular file.
sort(strings) = lexicographic sort by 8-bit
value (strcmp).
entries(
path) = the entries of a directory, without `.` and
`..`.
`+` denotes string concatenation.
return s
Definition lexer.l:459
const T & value
Definition lexer.l:492
Source & next
Definition lexer.l:3413
std::string path
Definition lexer.l:1399
std::string std::string_view std::string_view to
Definition lexer.l:2592
◆ dumpPathAndGetMtime()
time_t nix::dumpPathAndGetMtime |
( |
const Path & | path, |
|
|
Sink & | sink, |
|
|
PathFilter & | filter = defaultPathFilter ) |
Same as dumpPath(), but returns the last modified date of the path.
◆ dumpString()
void nix::dumpString |
( |
std::string_view | s, |
|
|
Sink & | sink ) |
Dump an archive with a single file with these contents.
- Parameters
-