1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-28 09:31:16 +02:00

SourceAccessor::readFile(): Support reading into a sink

This commit is contained in:
Eelco Dolstra 2023-10-20 16:36:41 +02:00
parent 7a086a32bc
commit 57db3be9e4
5 changed files with 94 additions and 13 deletions

View file

@ -44,12 +44,15 @@ void SourceAccessor::dumpPath(
{
auto dumpContents = [&](const CanonPath & path)
{
/* It would be nice if this was streaming, but we need the
size before the contents. */
auto s = readFile(path);
sink << "contents" << s.size();
sink(s);
writePadding(s.size(), sink);
sink << "contents";
std::optional<uint64_t> size;
readFile(path, sink, [&](uint64_t _size)
{
size = _size;
sink << _size;
});
assert(size);
writePadding(*size, sink);
};
std::function<void(const CanonPath & path)> dump;