[Common] Make sure we always have a path in CPath::SetComponents

This commit is contained in:
zilmar 2016-01-29 04:34:50 +11:00
parent 3a1fc904c6
commit 4203cbd2ef
1 changed files with 22 additions and 18 deletions

View File

@ -451,7 +451,11 @@ void CPath::SetComponents(const char * lpszDrive, const char * lpszDirectory, co
char buff_fullname[MAX_PATH];
memset(buff_fullname, 0, sizeof(buff_fullname));
if (lpszDirectory == NULL || strlen(lpszDirectory) == 0)
{
static char empty_dir[] = { DIRECTORY_DELIMITER, '\0' };
lpszDirectory = empty_dir;
}
_makepath(buff_fullname, lpszDrive, lpszDirectory, lpszName, lpszExtension);
m_strPath.erase();
@ -731,14 +735,14 @@ bool CPath::DirectoryExists() const
WIN32_FIND_DATA FindData;
HANDLE hFindFile = FindFirstFile((const char *)TestPath, &FindData); // Find anything
bool bGotFile = (hFindFile != INVALID_HANDLE_VALUE);
bool bGotDirectory = (hFindFile != INVALID_HANDLE_VALUE) && (FindData.dwFileAttributes && FILE_ATTRIBUTE_DIRECTORY != 0);
if (hFindFile != NULL) // Make sure we close the search
{
FindClose(hFindFile);
}
return bGotFile;
return bGotDirectory;
}
//-------------------------------------------------------------