mirror of
https://github.com/boostorg/filesystem.git
synced 2026-01-29 19:42:08 +00:00
filesystem::exists, must check to see why a filesystem stat failed, before assuming that the file does not exist.
[SVN r22564]
This commit is contained in:
@@ -310,9 +310,23 @@ namespace boost
|
||||
{
|
||||
# ifdef BOOST_POSIX
|
||||
struct stat path_stat;
|
||||
return ::stat( ph.string().c_str(), &path_stat ) == 0;
|
||||
if(::stat( ph.string().c_str(), &path_stat ) != 0)
|
||||
{
|
||||
if((errno == ENOENT) || (errno == ENOTDIR))
|
||||
return false; // stat failed because the path does not exist
|
||||
// for any other error we assume the file does exist and fall through,
|
||||
// this may not be the best policy though... (JM 20040330)
|
||||
}
|
||||
return true;
|
||||
# else
|
||||
return ::GetFileAttributesA( ph.string().c_str() ) != 0xFFFFFFFF;
|
||||
if(::GetFileAttributesA( ph.string().c_str() ) == 0xFFFFFFFF)
|
||||
{
|
||||
if((::GetLastError() == ERROR_FILE_NOT_FOUND) || (::GetLastError() == ERROR_PATH_NOT_FOUND))
|
||||
return false; // GetFileAttributes failed because the path does not exist
|
||||
// for any other error we assume the file does exist and fall through,
|
||||
// this may not be the best policy though... (JM 20040330)
|
||||
}
|
||||
return true;
|
||||
# endif
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user