Changed: Compare GetFileAttributes with INVALID_FILE_ATTRIBUTES to check if attributes are valid

hg/feature/sound
kervala 14 years ago
parent 1677874af2
commit 9e058f053d

@ -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…
Cancel
Save