mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-11 00:36:20 +02:00
Implement readDirectory
This commit is contained in:
parent
ffe0dc9a8c
commit
5916daf1fe
1 changed files with 12 additions and 4 deletions
|
@ -9,9 +9,7 @@ static std::atomic<size_t> nextNumber{0};
|
||||||
|
|
||||||
InputAccessor::InputAccessor()
|
InputAccessor::InputAccessor()
|
||||||
: number(++nextNumber)
|
: number(++nextNumber)
|
||||||
{
|
{ }
|
||||||
printError("CREATE %d", number);
|
|
||||||
}
|
|
||||||
|
|
||||||
// FIXME: merge with archive.cc.
|
// FIXME: merge with archive.cc.
|
||||||
const std::string narVersionMagic1 = "nix-archive-1";
|
const std::string narVersionMagic1 = "nix-archive-1";
|
||||||
|
@ -133,7 +131,17 @@ struct FSInputAccessor : InputAccessor
|
||||||
auto absPath = makeAbsPath(path);
|
auto absPath = makeAbsPath(path);
|
||||||
printError("READDIR %s", absPath);
|
printError("READDIR %s", absPath);
|
||||||
checkAllowed(absPath);
|
checkAllowed(absPath);
|
||||||
abort();
|
DirEntries res;
|
||||||
|
for (auto & entry : nix::readDirectory(absPath)) {
|
||||||
|
std::optional<Type> type;
|
||||||
|
switch (entry.type) {
|
||||||
|
case DT_REG: type = Type::tRegular; break;
|
||||||
|
case DT_LNK: type = Type::tSymlink; break;
|
||||||
|
case DT_DIR: type = Type::tDirectory; break;
|
||||||
|
}
|
||||||
|
res.emplace(entry.name, type);
|
||||||
|
}
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string readLink(PathView path) override
|
std::string readLink(PathView path) override
|
||||||
|
|
Loading…
Reference in a new issue