mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-24 14:56:15 +02:00
resolveExprPath(): Handle symlinks
This commit is contained in:
parent
fdba67d4fa
commit
2a53574675
1 changed files with 4 additions and 20 deletions
|
@ -678,31 +678,15 @@ Expr * EvalState::parse(char * text, size_t length, FileOrigin origin,
|
||||||
|
|
||||||
SourcePath resolveExprPath(const SourcePath & path)
|
SourcePath resolveExprPath(const SourcePath & path)
|
||||||
{
|
{
|
||||||
#if 0
|
|
||||||
unsigned int followCount = 0, maxFollow = 1024;
|
|
||||||
|
|
||||||
/* If `path' is a symlink, follow it. This is so that relative
|
/* If `path' is a symlink, follow it. This is so that relative
|
||||||
path references work. */
|
path references work. */
|
||||||
struct stat st;
|
SourcePath path2 { path.accessor, path.path.resolveSymlinks() };
|
||||||
while (true) {
|
|
||||||
// Basic cycle/depth limit to avoid infinite loops.
|
|
||||||
if (++followCount >= maxFollow)
|
|
||||||
throw Error("too many symbolic links encountered while traversing the path '%s'", path);
|
|
||||||
st = lstat(path);
|
|
||||||
if (!S_ISLNK(st.st_mode)) break;
|
|
||||||
path = absPath(readLink(path), dirOf(path));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If `path' refers to a directory, append `/default.nix'. */
|
/* If `path' refers to a directory, append `/default.nix'. */
|
||||||
if (S_ISDIR(st.st_mode))
|
if (path2.lstat().type == InputAccessor::tDirectory)
|
||||||
path = canonPath(path + "/default.nix");
|
return path2 + "default.nix";
|
||||||
|
|
||||||
return path;
|
return path2;
|
||||||
#endif
|
|
||||||
|
|
||||||
// FIXME
|
|
||||||
auto path2 = path + "default.nix";
|
|
||||||
return path2.pathExists() ? path2 : path;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue