From e9c427450322a1a36ad801d3cf4c788ec3706c61 Mon Sep 17 00:00:00 2001 From: Damjan Adamic Date: Mon, 25 May 2015 22:14:34 +0200 Subject: [PATCH] Fixes #2301: findTrueFileName() was not finding any files on Windows --- radio/src/targets/simu/simpgmspace.cpp | 34 ++++++++++++-------------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/radio/src/targets/simu/simpgmspace.cpp b/radio/src/targets/simu/simpgmspace.cpp index 5b97bd3d3..fe57baf1b 100644 --- a/radio/src/targets/simu/simpgmspace.cpp +++ b/radio/src/targets/simu/simpgmspace.cpp @@ -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);