diff options
author | John Ericson <John.Ericson@Obsidian.Systems> | 2020-07-27 14:22:45 +0000 |
---|---|---|
committer | John Ericson <John.Ericson@Obsidian.Systems> | 2020-07-27 14:22:45 +0000 |
commit | 699fc89b394ef5347ff0508abe389e77a7cde09e (patch) | |
tree | 35630ccbb1f9dae69137251b6198a71a20092c04 /src/libutil/archive.hh | |
parent | 5ea817dace2b554e602d7f9df6e43084ad112e3d (diff) | |
parent | d7c0f094cbcfe1ae4ccc3d54baec00b66ccb1ed0 (diff) |
Merge remote-tracking branch 'upstream/master' into hash-always-has-type
Diffstat (limited to 'src/libutil/archive.hh')
-rw-r--r-- | src/libutil/archive.hh | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/src/libutil/archive.hh b/src/libutil/archive.hh index 302b1bb18..57780d16a 100644 --- a/src/libutil/archive.hh +++ b/src/libutil/archive.hh @@ -63,12 +63,29 @@ struct ParseSink virtual void createSymlink(const Path & path, const string & target) { }; }; -struct TeeParseSink : 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 { - StringSink saved; - TeeSource source; + bool regular = true; + Sink & sink; - TeeParseSink(Source & source) : source(source, saved) { } + RetrieveRegularNARSink(Sink & sink) : sink(sink) { } + + void createDirectory(const Path & path) + { + regular = false; + } + + void receiveContents(unsigned char * data, unsigned int len) + { + sink(data, len); + } + + void createSymlink(const Path & path, const string & target) + { + regular = false; + } }; void parseDump(ParseSink & sink, Source & source); |