mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-22 14:06:16 +02:00
rm isLink
isLink util is removed in favour of std::filesystem::is_symlink
This commit is contained in:
parent
52ccaf7971
commit
ddea4c6deb
6 changed files with 6 additions and 13 deletions
|
@ -33,8 +33,9 @@ Path IndirectRootStore::addPermRoot(const StorePath & storePath, const Path & _g
|
|||
|
||||
/* Don't clobber the link if it already exists and doesn't
|
||||
point to the Nix store. */
|
||||
if (pathExists(gcRoot) && (!isLink(gcRoot) || !isInStore(readLink(gcRoot))))
|
||||
if (pathExists(gcRoot) && (!std::filesystem::is_symlink(gcRoot) || !isInStore(readLink(gcRoot))))
|
||||
throw Error("cannot create symlink '%1%'; already exists", gcRoot);
|
||||
|
||||
makeSymlink(gcRoot, printStorePath(storePath));
|
||||
addIndirectRoot(gcRoot);
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ Path Store::followLinksToStore(std::string_view _path) const
|
|||
{
|
||||
Path path = absPath(std::string(_path));
|
||||
while (!isInStore(path)) {
|
||||
if (!isLink(path)) break;
|
||||
if (!std::filesystem::is_symlink(path)) break;
|
||||
auto target = readLink(path);
|
||||
path = absPath(target, dirOf(path));
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@ Path canonPath(PathView path, bool resolveSymlinks)
|
|||
path,
|
||||
[&followCount, &temp, maxFollow, resolveSymlinks]
|
||||
(std::string & result, std::string_view & remaining) {
|
||||
if (resolveSymlinks && isLink(result)) {
|
||||
if (resolveSymlinks && std::filesystem::is_symlink(result)) {
|
||||
if (++followCount >= maxFollow)
|
||||
throw Error("infinite symlink recursion in path '%0%'", remaining);
|
||||
remaining = (temp = concatStrings(readLink(result), remaining));
|
||||
|
@ -222,12 +222,6 @@ Path readLink(const Path & path)
|
|||
}
|
||||
|
||||
|
||||
bool isLink(const Path & path)
|
||||
{
|
||||
return getFileType(path) == fs::file_type::symlink;
|
||||
}
|
||||
|
||||
|
||||
std::vector<fs::directory_entry> readDirectory(const Path & path)
|
||||
{
|
||||
std::vector<fs::directory_entry> entries;
|
||||
|
|
|
@ -117,8 +117,6 @@ bool pathAccessible(const Path & path);
|
|||
*/
|
||||
Path readLink(const Path & path);
|
||||
|
||||
bool isLink(const Path & path);
|
||||
|
||||
/**
|
||||
* Read the contents of a directory. The entries `.` and `..` are
|
||||
* removed.
|
||||
|
|
|
@ -101,7 +101,7 @@ struct CmdConfigCheck : StoreCommand
|
|||
Path userEnv = canonPath(profileDir, true);
|
||||
|
||||
if (store->isStorePath(userEnv) && hasSuffix(userEnv, "user-environment")) {
|
||||
while (profileDir.find("/profiles/") == std::string::npos && isLink(profileDir))
|
||||
while (profileDir.find("/profiles/") == std::string::npos && std::filesystem::is_symlink(profileDir))
|
||||
profileDir = absPath(readLink(profileDir), dirOf(profileDir));
|
||||
|
||||
if (profileDir.find("/profiles/") == std::string::npos)
|
||||
|
|
|
@ -121,7 +121,7 @@ struct CmdUpgradeNix : MixDryRun, StoreCommand
|
|||
Path profileDir = dirOf(where);
|
||||
|
||||
// Resolve profile to /nix/var/nix/profiles/<name> link.
|
||||
while (canonPath(profileDir).find("/profiles/") == std::string::npos && isLink(profileDir))
|
||||
while (canonPath(profileDir).find("/profiles/") == std::string::npos && std::filesystem::is_symlink(profileDir))
|
||||
profileDir = readLink(profileDir);
|
||||
|
||||
printInfo("found profile '%s'", profileDir);
|
||||
|
|
Loading…
Reference in a new issue