mirror of
https://github.com/NixOS/nix
synced 2025-07-05 20:41:47 +02:00
inline the usage of nix::readDirectory
`nix::readDirectory` is removed. `std::filesystem::directory_iterator` is used directly in places that used this util.
This commit is contained in:
parent
87ab3c0ea4
commit
1db7d1b840
18 changed files with 26 additions and 44 deletions
|
@ -222,20 +222,6 @@ Path readLink(const Path & path)
|
|||
}
|
||||
|
||||
|
||||
std::vector<fs::directory_entry> readDirectory(const Path & path)
|
||||
{
|
||||
std::vector<fs::directory_entry> entries;
|
||||
entries.reserve(64);
|
||||
|
||||
for (auto & entry : fs::directory_iterator{path}) {
|
||||
checkInterrupt();
|
||||
entries.push_back(std::move(entry));
|
||||
}
|
||||
|
||||
return entries;
|
||||
}
|
||||
|
||||
|
||||
fs::file_type getFileType(const Path & path)
|
||||
{
|
||||
return fs::symlink_status(path).type();
|
||||
|
|
|
@ -122,12 +122,6 @@ Path readLink(const Path & path);
|
|||
*/
|
||||
Descriptor openDirectory(const std::filesystem::path & path);
|
||||
|
||||
/**
|
||||
* Read the contents of a directory. The entries `.` and `..` are
|
||||
* removed.
|
||||
*/
|
||||
std::vector<std::filesystem::directory_entry> readDirectory(const Path & path);
|
||||
|
||||
std::filesystem::file_type getFileType(const Path & path);
|
||||
|
||||
/**
|
||||
|
|
|
@ -64,7 +64,7 @@ static CgroupStats destroyCgroup(const std::filesystem::path & cgroup, bool retu
|
|||
|
||||
/* Otherwise, manually kill every process in the subcgroups and
|
||||
this cgroup. */
|
||||
for (auto & entry : readDirectory(cgroup)) {
|
||||
for (auto & entry : std::filesystem::directory_iterator{cgroup}) {
|
||||
if (entry.symlink_status().type() != std::filesystem::file_type::directory) continue;
|
||||
destroyCgroup(cgroup / entry.path().filename(), false);
|
||||
}
|
||||
|
|
|
@ -132,7 +132,7 @@ SourceAccessor::DirEntries PosixSourceAccessor::readDirectory(const CanonPath &
|
|||
{
|
||||
assertNoSymlinks(path);
|
||||
DirEntries res;
|
||||
for (auto & entry : nix::readDirectory(makeAbsPath(path).string())) {
|
||||
for (auto & entry : std::filesystem::directory_iterator{makeAbsPath(path)}) {
|
||||
auto type = [&]() -> std::optional<Type> {
|
||||
std::filesystem::file_type nativeType;
|
||||
try {
|
||||
|
|
|
@ -124,7 +124,7 @@ void closeMostFDs(const std::set<int> & exceptions)
|
|||
{
|
||||
#if __linux__
|
||||
try {
|
||||
for (auto & s : readDirectory("/proc/self/fd")) {
|
||||
for (auto & s : std::filesystem::directory_iterator{"/proc/self/fd"}) {
|
||||
auto fd = std::stoi(s.path().filename());
|
||||
if (!exceptions.count(fd)) {
|
||||
debug("closing leaked FD %d", fd);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue