mirror of
https://github.com/NixOS/nix
synced 2025-07-02 13:31:48 +02:00
Make readDirectory() return inode / file type
This commit is contained in:
parent
1c208f2b7e
commit
daf3f2c11f
7 changed files with 48 additions and 46 deletions
|
@ -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()) {
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue