mirror of
https://github.com/NixOS/nix
synced 2025-07-05 16:31:47 +02:00
fix tests and minor changes
- use the iterator in `CanonPath` to count `level` - use the `CanonPath::basename` method - use `CanonPath::root` instead of `CanonPath{""}` - remove `Path` and `PathView`, use `std::filesystem::path` directly
This commit is contained in:
parent
72bb530141
commit
2cf24a2df0
7 changed files with 21 additions and 13 deletions
|
@ -290,11 +290,11 @@ void parseDump(FileSystemObjectSink & sink, Source & source)
|
|||
}
|
||||
if (version != narVersionMagic1)
|
||||
throw badArchive("input doesn't look like a Nix archive");
|
||||
parse(sink, source, CanonPath{""});
|
||||
parse(sink, source, CanonPath::root);
|
||||
}
|
||||
|
||||
|
||||
void restorePath(const Path & path, Source & source)
|
||||
void restorePath(const std::filesystem::path & path, Source & source)
|
||||
{
|
||||
RestoreSink sink;
|
||||
sink.dstPath = path;
|
||||
|
|
|
@ -75,7 +75,7 @@ void dumpString(std::string_view s, Sink & sink);
|
|||
|
||||
void parseDump(FileSystemObjectSink & sink, Source & source);
|
||||
|
||||
void restorePath(const Path & path, Source & source);
|
||||
void restorePath(const std::filesystem::path & path, Source & source);
|
||||
|
||||
/**
|
||||
* Read a NAR from 'source' and write it to 'sink'.
|
||||
|
|
|
@ -127,7 +127,7 @@ Path dirOf(const PathView path)
|
|||
}
|
||||
|
||||
|
||||
std::string_view baseNameOf(PathView path)
|
||||
std::string_view baseNameOf(std::string_view path)
|
||||
{
|
||||
if (path.empty())
|
||||
return "";
|
||||
|
|
|
@ -84,8 +84,12 @@ struct RestoreRegularFile : CreateRegularFileSink {
|
|||
|
||||
void RestoreSink::createRegularFile(const CanonPath & path, std::function<void(CreateRegularFileSink &)> func)
|
||||
{
|
||||
std::cout << "SCREAM!!!====== " << dstPath / path.rel() << std::endl;
|
||||
std::filesystem::path p = dstPath / path.rel();
|
||||
auto p = dstPath;
|
||||
|
||||
if (!path.rel().empty()) {
|
||||
p = p / path.rel();
|
||||
}
|
||||
|
||||
RestoreRegularFile crf;
|
||||
crf.fd =
|
||||
#ifdef _WIN32
|
||||
|
@ -136,7 +140,9 @@ void RestoreRegularFile::operator () (std::string_view data)
|
|||
|
||||
void RestoreSink::createSymlink(const CanonPath & path, const std::string & target)
|
||||
{
|
||||
std::filesystem::path p = dstPath / path.rel();
|
||||
auto p = dstPath;
|
||||
if (!path.rel().empty())
|
||||
p = dstPath / path.rel();
|
||||
nix::createSymlink(target, p);
|
||||
}
|
||||
|
||||
|
|
|
@ -208,7 +208,7 @@ std::optional<Mode> convertMode(SourceAccessor::Type type)
|
|||
|
||||
void restore(FileSystemObjectSink & sink, Source & source, std::function<RestoreHook> hook)
|
||||
{
|
||||
parse(sink, CanonPath{""}, source, BlobMode::Regular, [&](CanonPath name, TreeEntry entry) {
|
||||
parse(sink, CanonPath::root, source, BlobMode::Regular, [&](CanonPath name, TreeEntry entry) {
|
||||
auto [accessor, from] = hook(entry.hash);
|
||||
auto stat = accessor->lstat(from);
|
||||
auto gotOpt = convertMode(stat.type);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue