From af00aa2b6f540f938548fb50b0391435db1290fb Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 27 Sep 2010 14:40:21 +0200 Subject: [PATCH] Changed: Compare GetFileAttributes with INVALID_FILE_ATTRIBUTES to check if attributes are valid --- code/nel/src/misc/path.cpp | 4 ++-- code/nel/tools/3d/ig_elevation/main.cpp | 3 ++- code/nel/tools/3d/lightmap_optimizer/main.cpp | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/code/nel/src/misc/path.cpp b/code/nel/src/misc/path.cpp index 8b921fb0f..308b78af4 100644 --- a/code/nel/src/misc/path.cpp +++ b/code/nel/src/misc/path.cpp @@ -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; diff --git a/code/nel/tools/3d/ig_elevation/main.cpp b/code/nel/tools/3d/ig_elevation/main.cpp index 3d553d101..55f696fd0 100644 --- a/code/nel/tools/3d/ig_elevation/main.cpp +++ b/code/nel/tools/3d/ig_elevation/main.cpp @@ -136,7 +136,8 @@ void dir (const string &sFilter, vector &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); diff --git a/code/nel/tools/3d/lightmap_optimizer/main.cpp b/code/nel/tools/3d/lightmap_optimizer/main.cpp index c62501b4e..a2dd5602a 100644 --- a/code/nel/tools/3d/lightmap_optimizer/main.cpp +++ b/code/nel/tools/3d/lightmap_optimizer/main.cpp @@ -66,7 +66,8 @@ void dir (const std::string &sFilter, std::vector &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);