diff options
author | John Ericson <John.Ericson@Obsidian.Systems> | 2020-08-03 21:02:28 +0000 |
---|---|---|
committer | John Ericson <John.Ericson@Obsidian.Systems> | 2020-08-03 21:02:28 +0000 |
commit | 062533f7cdb74026096ca8c7d5b6e393893d59ef (patch) | |
tree | cca64de7b3581072d1d9ecd11a31b053de68f6d5 /src/libutil/archive.hh | |
parent | d92d4f85a5c8a2a2385c084500a8b6bd54b54e6c (diff) | |
parent | a2842588ec86a0f488a385d453eda86e1f52f05a (diff) |
Merge remote-tracking branch 'upstream/master' into path-info-header
Diffstat (limited to 'src/libutil/archive.hh')
-rw-r--r-- | src/libutil/archive.hh | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/src/libutil/archive.hh b/src/libutil/archive.hh index 768fe2536..5665732d2 100644 --- a/src/libutil/archive.hh +++ b/src/libutil/archive.hh @@ -57,17 +57,35 @@ struct ParseSink 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 preallocateContents(uint64_t size) { }; + virtual void receiveContents(unsigned char * data, size_t len) { }; virtual void createSymlink(const Path & path, const string & target) { }; }; -struct TeeSink : ParseSink +/* If the NAR archive contains a single file at top-level, then save + the contents of the file to `s'. Otherwise barf. */ +struct RetrieveRegularNARSink : ParseSink { - TeeSource source; + bool regular = true; + Sink & sink; - TeeSink(Source & source) : source(source) { } + RetrieveRegularNARSink(Sink & sink) : sink(sink) { } + + void createDirectory(const Path & path) + { + regular = false; + } + + void receiveContents(unsigned char * data, size_t len) + { + sink(data, len); + } + + void createSymlink(const Path & path, const string & target) + { + regular = false; + } }; void parseDump(ParseSink & sink, Source & source); |