Add O(1)-memory copyPath() function

This commit is contained in:
Eelco Dolstra 2018-10-01 17:05:55 +02:00
parent 3913afdd69
commit f1c0b2c0e1
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE
2 changed files with 11 additions and 0 deletions

View file

@ -375,4 +375,13 @@ void copyNAR(Source & source, Sink & sink)
}
void copyPath(const Path & from, const Path & to)
{
auto source = sinkToSource([&](Sink & sink) {
dumpPath(from, sink);
});
restorePath(to, *source);
}
}

View file

@ -77,6 +77,8 @@ void restorePath(const Path & path, Source & source);
/* Read a NAR from 'source' and write it to 'sink'. */
void copyNAR(Source & source, Sink & sink);
void copyPath(const Path & from, const Path & to);
extern const std::string narVersionMagic1;