1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-28 13:41:15 +02:00

* nix-env: a tool to manage user environments.

* Replace all directory reading code by a generic readDirectory()
  function.
This commit is contained in:
Eelco Dolstra 2003-11-19 17:27:16 +00:00
parent fd7ac09f10
commit 9898746ef3
16 changed files with 412 additions and 51 deletions

View file

@ -51,23 +51,12 @@ static void dump(const string & path, DumpSink & sink);
static void dumpEntries(const Path & path, DumpSink & sink)
{
AutoCloseDir dir = opendir(path.c_str());
if (!dir) throw SysError("opening directory " + path);
Strings names = readDirectory(path);
vector<string> names2(names.begin(), names.end());
sort(names2.begin(), names2.end());
vector<string> names;
struct dirent * dirent;
while (errno = 0, dirent = readdir(dir)) {
string name = dirent->d_name;
if (name == "." || name == "..") continue;
names.push_back(name);
}
if (errno) throw SysError("reading directory " + path);
sort(names.begin(), names.end());
for (vector<string>::iterator it = names.begin();
it != names.end(); it++)
for (vector<string>::iterator it = names2.begin();
it != names2.end(); it++)
{
writeString("entry", sink);
writeString("(", sink);