mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-13 18:51:29 +00:00
[Crash] Check for directory existence before traversing in CheckForCompatibleQuestPlugins (#4730)
This commit is contained in:
parent
89e3b2c72e
commit
c3b8cc9744
@ -731,37 +731,45 @@ void UpdateWindowTitle(char *iNewTitle)
|
|||||||
|
|
||||||
bool CheckForCompatibleQuestPlugins()
|
bool CheckForCompatibleQuestPlugins()
|
||||||
{
|
{
|
||||||
const std::vector<std::string>& directories = { "lua_modules", "plugins" };
|
const std::vector<std::pair<std::string, bool *>> directories = {
|
||||||
|
{"lua_modules", nullptr},
|
||||||
|
{"plugins", nullptr}
|
||||||
|
};
|
||||||
|
|
||||||
bool lua_found = false;
|
bool lua_found = false;
|
||||||
bool perl_found = false;
|
bool perl_found = false;
|
||||||
|
|
||||||
for (const auto& directory : directories) {
|
try {
|
||||||
for (const auto& file : fs::directory_iterator(path.GetServerPath() + "/" + directory)) {
|
for (const auto &[directory, flag]: directories) {
|
||||||
if (file.is_regular_file()) {
|
std::string dir_path = path.GetServerPath() + "/" + directory;
|
||||||
auto f = file.path().string();
|
if (!File::Exists(dir_path)) { continue; }
|
||||||
if (File::Exists(f)) {
|
|
||||||
auto r = File::GetContents(std::filesystem::path{ f }.string());
|
|
||||||
if (Strings::Contains(r.contents, "CheckHandin")) {
|
|
||||||
if (Strings::EqualFold(directory, "lua_modules")) {
|
|
||||||
lua_found = true;
|
|
||||||
} else if (Strings::EqualFold(directory, "plugins")) {
|
|
||||||
perl_found = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lua_found && perl_found) {
|
for (const auto &file: fs::directory_iterator(dir_path)) {
|
||||||
return true;
|
if (!file.is_regular_file()) { continue; }
|
||||||
}
|
|
||||||
}
|
std::string file_path = file.path().string();
|
||||||
|
if (!File::Exists(file_path)) { continue; }
|
||||||
|
|
||||||
|
auto r = File::GetContents(file_path);
|
||||||
|
if (!Strings::Contains(r.contents, "CheckHandin")) { continue; }
|
||||||
|
|
||||||
|
if (directory == "lua_modules") {
|
||||||
|
lua_found = true;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
perl_found = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lua_found && perl_found) { return true; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (const fs::filesystem_error &ex) {
|
||||||
|
LogError("Failed to check for compatible quest plugins: {}", ex.what());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!lua_found) {
|
if (!lua_found) {
|
||||||
LogError("Failed to find CheckHandin in lua_modules");
|
LogError("Failed to find CheckHandin in lua_modules");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!perl_found) {
|
if (!perl_found) {
|
||||||
LogError("Failed to find CheckHandin in plugins");
|
LogError("Failed to find CheckHandin in plugins");
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user