diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2014-08-01T14·37+0200 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2014-08-01T15·14+0200 |
commit | daf3f2c11ff467b600473a2fda7bd513aacc1efa (patch) | |
tree | 2f69efd2cff7f7801b16ebe6a8c5b35cccf90065 /src/nix-env | |
parent | 1c208f2b7ef8ffb5e6d435d703dad83223a67bd6 (diff) |
Make readDirectory() return inode / file type
Diffstat (limited to 'src/nix-env')
-rw-r--r-- | src/nix-env/nix-env.cc | 12 | ||||
-rw-r--r-- | src/nix-env/profiles.cc | 7 |
2 files changed, 9 insertions, 10 deletions
diff --git a/src/nix-env/nix-env.cc b/src/nix-env/nix-env.cc index 05f6aa354997..062118d8a095 100644 --- a/src/nix-env/nix-env.cc +++ b/src/nix-env/nix-env.cc @@ -106,16 +106,16 @@ static bool isNixExpr(const Path & path, struct stat & st) static void getAllExprs(EvalState & state, const Path & path, StringSet & attrs, Value & v) { - Strings names = readDirectory(path); - StringSet namesSorted(names.begin(), names.end()); + StringSet namesSorted; + for (auto & i : readDirectory(path)) namesSorted.insert(i.name); - foreach (StringSet::iterator, i, namesSorted) { + for (auto & i : namesSorted) { /* Ignore the manifest.nix used by profiles. This is necessary to prevent it from showing up in channels (which are implemented using profiles). */ - if (*i == "manifest.nix") continue; + if (i == "manifest.nix") continue; - Path path2 = path + "/" + *i; + Path path2 = path + "/" + i; struct stat st; if (stat(path2.c_str(), &st) == -1) @@ -126,7 +126,7 @@ static void getAllExprs(EvalState & state, otherwise the attribute cannot be selected with the `-A' option. Useful if you want to stick a Nix expression directly in ~/.nix-defexpr. */ - string attrName = *i; + string attrName = i; if (hasSuffix(attrName, ".nix")) attrName = string(attrName, 0, attrName.size() - 4); if (attrs.find(attrName) != attrs.end()) { diff --git a/src/nix-env/profiles.cc b/src/nix-env/profiles.cc index f7b306890d4c..074a5e8c9db8 100644 --- a/src/nix-env/profiles.cc +++ b/src/nix-env/profiles.cc @@ -42,12 +42,11 @@ Generations findGenerations(Path profile, int & curGen) Path profileDir = dirOf(profile); string profileName = baseNameOf(profile); - Strings names = readDirectory(profileDir); - for (Strings::iterator i = names.begin(); i != names.end(); ++i) { + for (auto & i : readDirectory(profileDir)) { int n; - if ((n = parseName(profileName, *i)) != -1) { + if ((n = parseName(profileName, i.name)) != -1) { Generation gen; - gen.path = profileDir + "/" + *i; + gen.path = profileDir + "/" + i.name; gen.number = n; struct stat st; if (lstat(gen.path.c_str(), &st) != 0) |