mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-17 13:01:41 +00:00
Changed: Compare GetFileAttributes with INVALID_FILE_ATTRIBUTES to check if attributes are valid
This commit is contained in:
parent
629d273ecf
commit
4456d81dd8
3 changed files with 6 additions and 4 deletions
|
@ -1747,7 +1747,7 @@ bool CFile::isDirectory (const string &filename)
|
|||
{
|
||||
#ifdef NL_OS_WINDOWS
|
||||
DWORD res = GetFileAttributes(filename.c_str());
|
||||
if (res == ~0U)
|
||||
if (res == INVALID_FILE_ATTRIBUTES)
|
||||
{
|
||||
// nlwarning ("PATH: '%s' is not a valid file or directory name", filename.c_str ());
|
||||
return false;
|
||||
|
@ -1769,7 +1769,7 @@ bool CFile::isDirectory (const string &filename)
|
|||
bool CFile::isExists (const string &filename)
|
||||
{
|
||||
#ifdef NL_OS_WINDOWS
|
||||
return (GetFileAttributes(filename.c_str()) != ~0U);
|
||||
return (GetFileAttributes(filename.c_str()) != INVALID_FILE_ATTRIBUTES);
|
||||
#else // NL_OS_WINDOWS
|
||||
struct stat buf;
|
||||
return stat (filename.c_str (), &buf) == 0;
|
||||
|
|
|
@ -136,7 +136,8 @@ void dir (const string &sFilter, vector<string> &sAllFiles, bool bFullPath)
|
|||
hFind = FindFirstFile (sFilter.c_str(), &findData);
|
||||
while (hFind != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
if (!(GetFileAttributes(findData.cFileName)&FILE_ATTRIBUTE_DIRECTORY))
|
||||
DWORD res = GetFileAttributes(findData.cFileName);
|
||||
if (res != INVALID_FILE_ATTRIBUTES && !(res&FILE_ATTRIBUTE_DIRECTORY))
|
||||
{
|
||||
if (bFullPath)
|
||||
sAllFiles.push_back(string(sCurDir) + "\\" + findData.cFileName);
|
||||
|
|
|
@ -66,7 +66,8 @@ void dir (const std::string &sFilter, std::vector<std::string> &sAllFiles, bool
|
|||
hFind = FindFirstFile (sFilter.c_str(), &findData);
|
||||
while (hFind != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
if (!(GetFileAttributes(findData.cFileName)&FILE_ATTRIBUTE_DIRECTORY))
|
||||
DWORD res = GetFileAttributes(findData.cFileName);
|
||||
if (res != INVALID_FILE_ATTRIBUTES && !(res&FILE_ATTRIBUTE_DIRECTORY))
|
||||
{
|
||||
if (bFullPath)
|
||||
sAllFiles.push_back(string(sCurDir) + "\\" + findData.cFileName);
|
||||
|
|
Loading…
Reference in a new issue