1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-27 12:41:15 +02:00

Replace symlink_exists with pathExists

As it turns out the orignal implementation of symlink_exists cannot be
used in Nix because it did now std::filesystem::filesystem_error.
The new implementation fixes that but is now actually the same as
pathExists except for the path type.
This commit is contained in:
Jörg Thalheim 2025-05-01 11:43:37 +02:00
parent 143fb88ceb
commit 5b59be914d
6 changed files with 9 additions and 38 deletions

View file

@ -31,18 +31,6 @@
namespace nix {
namespace fs {
using namespace std::filesystem;
bool symlink_exists(const std::filesystem::path & path) {
try {
return std::filesystem::exists(std::filesystem::symlink_status(path));
} catch (const std::filesystem::filesystem_error & e) {
throw SysError("cannot check existence of %1%", path);
}
}
}
DirectoryIterator::DirectoryIterator(const std::filesystem::path& p) {
try {
// **Attempt to create the underlying directory_iterator**
@ -243,9 +231,9 @@ std::optional<struct stat> maybeLstat(const Path & path)
}
bool pathExists(const Path & path)
bool pathExists(const std::filesystem::path & path)
{
return maybeLstat(path).has_value();
return maybeLstat(path.string()).has_value();
}
bool pathAccessible(const std::filesystem::path & path)