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 ext[_MAX_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);
|
||||
if (dir) {
|
||||
// TRACE("\tsearching for: %s", fileName.c_str());
|
||||
WIN32_FIND_DATA ffd;
|
||||
HANDLE hFind = FindFirstFile(dirName.c_str(), &ffd);
|
||||
if (INVALID_HANDLE_VALUE != hFind) {
|
||||
do {
|
||||
if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY == 0) {
|
||||
// TRACE("comparing with: %s", ffd.cFileName);
|
||||
if (!strcasecmp(fileName.c_str(), ffd.cFileName)) {
|
||||
strcpy(result, dirName.c_str());
|
||||
strcat(result, "/");
|
||||
strcat(result, ffd.cFileName);
|
||||
TRACE("\tfound: %s", ffd.cFileName);
|
||||
fileMap.insert(filemap_t:: value_type(path, result));
|
||||
return result;
|
||||
}
|
||||
std::string searchName = dirName + "*";
|
||||
// TRACE("\tsearching for: %s", fileName.c_str());
|
||||
WIN32_FIND_DATA ffd;
|
||||
HANDLE hFind = FindFirstFile(searchName.c_str(), &ffd);
|
||||
if (INVALID_HANDLE_VALUE != hFind) {
|
||||
do {
|
||||
if (!(ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
|
||||
//TRACE("comparing with: %s", ffd.cFileName);
|
||||
if (!strcasecmp(fileName.c_str(), ffd.cFileName)) {
|
||||
strcpy(result, dirName.c_str());
|
||||
strcat(result, ffd.cFileName);
|
||||
TRACE("\tfound: %s", ffd.cFileName);
|
||||
fileMap.insert(filemap_t:: value_type(path, result));
|
||||
return result;
|
||||
}
|
||||
}
|
||||
while (FindNextFile(hFind, &ffd) != 0);
|
||||
}
|
||||
while (FindNextFile(hFind, &ffd) != 0);
|
||||
}
|
||||
#else
|
||||
strcpy(result, path);
|
||||
|
||||
Reference in New Issue
Block a user