mirror of
https://github.com/NixOS/nix
synced 2025-06-26 20:01:15 +02:00
SourceAccessor: Change the main interface from lstat() to maybeLstat()
This commit is contained in:
parent
8ffd1695ce
commit
cdb27c1519
9 changed files with 22 additions and 20 deletions
|
@ -44,9 +44,13 @@ bool PosixSourceAccessor::pathExists(const CanonPath & path)
|
|||
return nix::pathExists(path.abs());
|
||||
}
|
||||
|
||||
SourceAccessor::Stat PosixSourceAccessor::lstat(const CanonPath & path)
|
||||
std::optional<SourceAccessor::Stat> PosixSourceAccessor::maybeLstat(const CanonPath & path)
|
||||
{
|
||||
auto st = nix::lstat(path.abs());
|
||||
struct stat st;
|
||||
if (::lstat(path.c_str(), &st)) {
|
||||
if (errno == ENOENT) return std::nullopt;
|
||||
throw SysError("getting status of '%s'", showPath(path));
|
||||
}
|
||||
mtime = std::max(mtime, st.st_mtime);
|
||||
return Stat {
|
||||
.type =
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue