Skip to content

Commit

Permalink
support UAL's hack of find file APIs (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
MiranDMC authored Oct 30, 2023
1 parent 93757b0 commit a3c6924
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion source/FileEnumerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,13 @@ void FilesWalk(const char* directory, const char* extension, T callback)
continue; // skip directories
}

auto result = std::filesystem::weakly_canonical(pattern.substr(0, baseDirLen) + wfd.cFileName); // will use CWD if input path was relative!
std::string path;
if (std::filesystem::path(wfd.cFileName).is_absolute())
path = wfd.cFileName; // somebody hacked findFirstFile APIs and is providing us absolute path
else
path = pattern.substr(0, baseDirLen) + wfd.cFileName; // standard

auto result = std::filesystem::weakly_canonical(path); // will use CWD if input path was relative!
callback(result.string().c_str(), result.filename().string().c_str());

} while (FindNextFile(hSearch, &wfd));
Expand Down

0 comments on commit a3c6924

Please sign in to comment.