mirror of
https://github.com/dlang/phobos.git
synced 2025-05-07 11:37:24 +03:00
Make std.file.DirEntry._ensureStatDone safe
This commit is contained in:
parent
ddae9ae99d
commit
2bec7fc296
1 changed files with 6 additions and 2 deletions
|
@ -2274,12 +2274,16 @@ else version(Posix)
|
|||
This is to support lazy evaluation, because doing stat's is
|
||||
expensive and not always needed.
|
||||
+/
|
||||
void _ensureStatDone()
|
||||
void _ensureStatDone() @safe
|
||||
{
|
||||
static auto trustedStat(in char[] path, stat_t* buf) @trusted
|
||||
{
|
||||
return stat(path.tempCString(), buf);
|
||||
}
|
||||
if(_didStat)
|
||||
return;
|
||||
|
||||
enforce(stat(_name.tempCString(), &_statBuf) == 0,
|
||||
enforce(trustedStat(_name, &_statBuf) == 0,
|
||||
"Failed to stat file `" ~ _name ~ "'");
|
||||
|
||||
_didStat = true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue