mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-26 08:05:38 +00:00
Escaped some characters needed to get emulator wildcards to work with certain directories.
This commit is contained in:
parent
1bca70820c
commit
d8b99b1dff
|
@ -142,10 +142,17 @@ namespace Utils
|
||||||
if (dirContent.size() == 0)
|
if (dirContent.size() == 0)
|
||||||
return files;
|
return files;
|
||||||
|
|
||||||
|
// Some characters need to be escaped in order for the regular expression to work.
|
||||||
|
std::string escPattern {Utils::String::replace(pattern, "*", ".*")};
|
||||||
|
escPattern = Utils::String::replace(escPattern, ")", "\\)");
|
||||||
|
escPattern = Utils::String::replace(escPattern, "(", "\\(");
|
||||||
|
escPattern = Utils::String::replace(escPattern, "]", "\\]");
|
||||||
|
escPattern = Utils::String::replace(escPattern, "[", "\\[");
|
||||||
|
|
||||||
std::regex expression;
|
std::regex expression;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
expression = Utils::String::replace(pattern, "*", ".*");
|
expression = escPattern;
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
LOG(LogError) << "FileSystemUtil::getMatchingFiles(): Invalid regular expression "
|
LOG(LogError) << "FileSystemUtil::getMatchingFiles(): Invalid regular expression "
|
||||||
|
@ -153,9 +160,9 @@ namespace Utils
|
||||||
return files;
|
return files;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& dir : dirContent) {
|
for (auto& entry : dirContent) {
|
||||||
if (std::regex_match(dir, expression))
|
if (std::regex_match(entry, expression))
|
||||||
files.emplace_back(dir);
|
files.emplace_back(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
return files;
|
return files;
|
||||||
|
|
Loading…
Reference in a new issue