closed #4711: [win32] Passing empty string to FileUtils::isFileExist may also return true

This commit is contained in:
James Chen 2014-04-08 15:24:47 +08:00
parent 0834c07fa3
commit e04b820cfc
1 changed files with 4 additions and 1 deletions

View File

@ -112,7 +112,10 @@ bool FileUtilsWin32::isFileExistInternal(const std::string& strFilePath) const
WCHAR utf16Buf[CC_MAX_PATH] = {0};
MultiByteToWideChar(CP_UTF8, 0, strPath.c_str(), -1, utf16Buf, sizeof(utf16Buf)/sizeof(utf16Buf[0]));
return GetFileAttributesW(utf16Buf) != -1 ? true : false;
DWORD attr = GetFileAttributesW(utf16Buf);
if(attr == INVALID_FILE_ATTRIBUTES || (attr & FILE_ATTRIBUTE_DIRECTORY))
return false; // not a file
return true;
}
bool FileUtilsWin32::isAbsolutePath(const std::string& strPath) const