mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-22 22:16:16 +02:00
canonPath in one pass
This commit is contained in:
parent
e7810665a7
commit
f3f228700a
1 changed files with 8 additions and 6 deletions
|
@ -143,16 +143,18 @@ Path canonPath(const Path & path, bool resolveSymlinks)
|
||||||
s += '/';
|
s += '/';
|
||||||
while (i != end && *i != '/') s += *i++;
|
while (i != end && *i != '/') s += *i++;
|
||||||
|
|
||||||
/* If s points to a symlink, resolve it and restart (since
|
/* If s points to a symlink, resolve it and continue from there */
|
||||||
the symlink target might contain new symlinks). */
|
|
||||||
if (resolveSymlinks && isLink(s)) {
|
if (resolveSymlinks && isLink(s)) {
|
||||||
if (++followCount >= maxFollow)
|
if (++followCount >= maxFollow)
|
||||||
throw Error("infinite symlink recursion in path '%1%'", path);
|
throw Error("infinite symlink recursion in path '%1%'", path);
|
||||||
temp = absPath(readLink(s), dirOf(s))
|
temp = readLink(s) + string(i, end);
|
||||||
+ string(i, end);
|
i = temp.begin();
|
||||||
i = temp.begin(); /* restart */
|
|
||||||
end = temp.end();
|
end = temp.end();
|
||||||
s = "";
|
if (!temp.empty() && temp[0] == '/') {
|
||||||
|
s.clear(); /* restart for symlinks pointing to absolute path */
|
||||||
|
} else {
|
||||||
|
s = dirOf(s);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue