patterns: Fixed #include not properly searching all include folders

This commit is contained in:
WerWolv 2021-10-19 21:42:04 +02:00
parent 929437c159
commit 7562e8b172
1 changed files with 7 additions and 5 deletions

View File

@ -63,17 +63,19 @@ namespace hex::pl {
}
offset += 1;
std::string includePath = includeFile;
if (includeFile[0] != '/') {
std::string tempPath = includeFile;
for (const auto &dir : hex::getPath(ImHexPath::PatternsInclude)) {
tempPath = hex::format("{0}/{1}", dir.c_str(), includeFile.c_str());
if (std::filesystem::exists(includeFile))
std::string tempPath = hex::format("{0}/{1}", dir.c_str(), includeFile.c_str());
if (std::filesystem::exists(tempPath)) {
includePath = tempPath;
break;
}
}
includeFile = tempPath;
}
File file(includeFile, File::Mode::Read);
File file(includePath, File::Mode::Read);
if (!file.isValid())
throwPreprocessorError(hex::format("{0}: No such file or directory", includeFile.c_str()), lineNumber);