#pragma once #include "types.hh" #include "serialise.hh" namespace nix { /* dumpPath creates a Nix archive of the specified path. The format is as follows: IF path points to a REGULAR FILE: dump(path) = attrs( [ ("type", "regular") , ("contents", contents(path)) ]) IF path points to a DIRECTORY: dump(path) = attrs( [ ("type", "directory") , ("entries", concat(map(f, sort(entries(path))))) ]) where f(fn) = attrs( [ ("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. */ struct PathFilter { virtual ~PathFilter() { } virtual bool operator () (const Path & path) { return true; } }; extern PathFilter defaultPathFilter; void dumpPath(const Path & path, Sink & sink, PathFilter & filter = defaultPathFilter); struct ParseSink { virtual void createDirectory(const Path & path) { }; virtual void createRegularFile(const Path & path) { }; virtual void isExecutable() { }; virtual void preallocateContents(unsigned long long size) { }; virtual void receiveContents(unsigned char * data, unsigned int len) { }; virtual void createSymlink(const Path & path, const string & target) { }; }; void parseDump(ParseSink & sink, Source & source); void restorePath(const Path & path, Source & source); } >committer
path: root/tests/nar.scm
AgeCommit message (Expand)Author
2019-12-12serialization: Add 'fold-archive'....Ludovic Courtès
2019-01-18serialization: 'restore-file' errors out upon non-convertible file names....Ludovic Courtès
2018-11-13deduplication: Restore directory mtime and permissions after deduplication....Ludovic Courtès
2018-11-13tests: Check file canonicalization for 'restore-file-set'....Ludovic Courtès
2018-11-13tests: Remove check for a feature that appeared in Guile 2.0.10....Ludovic Courtès
2018-09-04Switch to Guile-Gcrypt....Ludovic Courtès
2018-07-19serialization: Add 'write-file-tree'....Ludovic Courtès
2017-03-18build: Require Guile >= 2.0.9....Ludovic Courtès
2017-03-08hash: Close or flush sha256 output ports before calling their 'get' procedure....Ludovic Courtès
2016-06-12serialization: Add #:select? parameter to 'write-file'....Ludovic Courtès
2016-04-03build: Add a Guile custom test driver using SRFI-64....Mathieu Lirzin
2015-08-26tests: Work around Btrfs handling of nlink for empty directories....Ludovic Courtès
2015-06-24tests: Move 'file=?' to (guix tests)....Ludovic Courtès