Merge pull request #2342 from opentx/projectkk2glider/issue_2301_findTrueFileName_fix_on_windows_for_next
Fixes #2301: findTrueFileName() was not finding any files on Windows
This commit is contained in:
@@ -706,28 +706,26 @@ char *findTrueFileName(const char *path)
|
|||||||
char fname[_MAX_FNAME];
|
char fname[_MAX_FNAME];
|
||||||
char ext[_MAX_EXT];
|
char ext[_MAX_EXT];
|
||||||
_splitpath(path, drive, dir, fname, ext);
|
_splitpath(path, drive, dir, fname, ext);
|
||||||
std::string fileName = std::string(fname) + "." + std::string(ext);
|
std::string fileName = std::string(fname) + std::string(ext);
|
||||||
std::string dirName = std::string(drive) + std::string(dir);
|
std::string dirName = std::string(drive) + std::string(dir);
|
||||||
if (dir) {
|
std::string searchName = dirName + "*";
|
||||||
// TRACE("\tsearching for: %s", fileName.c_str());
|
// TRACE("\tsearching for: %s", fileName.c_str());
|
||||||
WIN32_FIND_DATA ffd;
|
WIN32_FIND_DATA ffd;
|
||||||
HANDLE hFind = FindFirstFile(dirName.c_str(), &ffd);
|
HANDLE hFind = FindFirstFile(searchName.c_str(), &ffd);
|
||||||
if (INVALID_HANDLE_VALUE != hFind) {
|
if (INVALID_HANDLE_VALUE != hFind) {
|
||||||
do {
|
do {
|
||||||
if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY == 0) {
|
if (!(ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
|
||||||
// TRACE("comparing with: %s", ffd.cFileName);
|
//TRACE("comparing with: %s", ffd.cFileName);
|
||||||
if (!strcasecmp(fileName.c_str(), ffd.cFileName)) {
|
if (!strcasecmp(fileName.c_str(), ffd.cFileName)) {
|
||||||
strcpy(result, dirName.c_str());
|
strcpy(result, dirName.c_str());
|
||||||
strcat(result, "/");
|
strcat(result, ffd.cFileName);
|
||||||
strcat(result, ffd.cFileName);
|
TRACE("\tfound: %s", ffd.cFileName);
|
||||||
TRACE("\tfound: %s", ffd.cFileName);
|
fileMap.insert(filemap_t:: value_type(path, result));
|
||||||
fileMap.insert(filemap_t:: value_type(path, result));
|
return result;
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (FindNextFile(hFind, &ffd) != 0);
|
|
||||||
}
|
}
|
||||||
|
while (FindNextFile(hFind, &ffd) != 0);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
strcpy(result, path);
|
strcpy(result, path);
|
||||||
|
|||||||
Reference in New Issue
Block a user