Created
December 5, 2019 11:12
-
-
Save orip/41ba348518ffd8dd3f0b24dd138442b2 to your computer and use it in GitHub Desktop.
DLang: does the file a symlink points to exist? ("exists" with dereference")
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// mirroring std.file.exists but with stat() instead of lstat() to dereference symbolic links | |
bool existsWithDereference(string name) @trusted nothrow @nogc { | |
import core.sys.posix.sys.stat: stat, stat_t; | |
import std.internal.cstring: tempCString; | |
auto namez = name.tempCString!char(); | |
stat_t statbuf = void; | |
return stat(namez, &statbuf) == 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment