From 5916daf1febef72d71439f835339cb9540b4dd5b Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 7 Feb 2022 13:23:57 +0100 Subject: [PATCH] Implement readDirectory --- src/libfetchers/input-accessor.cc | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/libfetchers/input-accessor.cc b/src/libfetchers/input-accessor.cc index 19c85bf8c..c625007a5 100644 --- a/src/libfetchers/input-accessor.cc +++ b/src/libfetchers/input-accessor.cc @@ -9,9 +9,7 @@ static std::atomic nextNumber{0}; InputAccessor::InputAccessor() : number(++nextNumber) -{ - printError("CREATE %d", number); -} +{ } // FIXME: merge with archive.cc. const std::string narVersionMagic1 = "nix-archive-1"; @@ -133,7 +131,17 @@ struct FSInputAccessor : InputAccessor auto absPath = makeAbsPath(path); printError("READDIR %s", absPath); checkAllowed(absPath); - abort(); + DirEntries res; + for (auto & entry : nix::readDirectory(absPath)) { + std::optional 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