[Issue 21289] [The D Bug Tracker] "File does not exist" FileException on c:\hiberfil.sys
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Oct 4 07:30:13 UTC 2020
https://issues.dlang.org/show_bug.cgi?id=21289
--- Comment #1 from Vital <vital.fadeev at gmail.com> ---
I look into the std.file... function "existsImpl()"...
...
version (Windows)
{
// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/
// fileio/base/getfileattributes.asp
return GetFileAttributesW(namez) != 0xFFFFFFFF; //
INVALID_FILE_ATTRIBUTES
}
...
existsImpl() functions return "false" on file "c:\\hiberfil.sys".
Because INVALID_FILE_ATTRIBUTES.
It not correct? because file exists.
I tried several ways: GetFileAttributesW(), GetFileAttributesExW(),
FindFirstFileW().
Working solution :
WIN32_FIND_DATAW fd;
auto hFind = FindFirstFile ( "c:\\hiberfil.sys", &fd );
if ( hFind != INVALID_HANDLE_VALUE )
{
writeln( "[ OK ]" );
FindClose( hFind );
}
Of course solution above is a little slower than GetFileAttributes(), but work
correct with .sys files.
I will suggest using "FindFirstFileW()" in the "std.file: existsImpl()" there
is no better solution yet.
--
More information about the Digitalmars-d-bugs
mailing list