mirror of
https://github.com/wiiu-env/WiiUPluginLoaderBackend.git
synced 2024-11-05 20:45:07 +01:00
Ignore files that don't end with ".wps" or start with "." or "_"
This commit is contained in:
parent
9dc58d389f
commit
616fc832d1
@ -40,23 +40,21 @@ std::forward_list<std::shared_ptr<PluginData>> PluginDataFactory::loadDir(const
|
||||
}
|
||||
|
||||
while ((dp = readdir(dfd)) != nullptr) {
|
||||
struct stat stbuf {};
|
||||
auto full_file_path = string_format("%s/%s", path.c_str(), dp->d_name);
|
||||
if (stat(full_file_path.c_str(), &stbuf) == -1) {
|
||||
DEBUG_FUNCTION_LINE_ERR("Unable to stat file: %s", full_file_path.c_str());
|
||||
if (dp->d_type == DT_DIR) {
|
||||
continue;
|
||||
}
|
||||
if (std::string_view(dp->d_name).starts_with('.') || std::string_view(dp->d_name).starts_with('_') || !std::string_view(dp->d_name).ends_with(".wps")) {
|
||||
DEBUG_FUNCTION_LINE_WARN("Skip file %s/%s", path.c_str(), dp->d_name);
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((stbuf.st_mode & S_IFMT) == S_IFDIR) { // Skip directories
|
||||
continue;
|
||||
auto full_file_path = string_format("%s/%s", path.c_str(), dp->d_name);
|
||||
DEBUG_FUNCTION_LINE("Loading plugin: %s", full_file_path.c_str());
|
||||
auto pluginData = load(full_file_path);
|
||||
if (pluginData) {
|
||||
result.push_front(std::move(pluginData.value()));
|
||||
} else {
|
||||
DEBUG_FUNCTION_LINE("Loading plugin: %s", full_file_path.c_str());
|
||||
auto pluginData = load(full_file_path);
|
||||
if (pluginData) {
|
||||
result.push_front(std::move(pluginData.value()));
|
||||
} else {
|
||||
DEBUG_FUNCTION_LINE_ERR("Failed to load plugin: %s", full_file_path.c_str());
|
||||
}
|
||||
DEBUG_FUNCTION_LINE_ERR("Failed to load plugin: %s", full_file_path.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,7 @@ extern "C" {
|
||||
#define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...) LOG(WHBLogWritef, FMT, ##ARGS)
|
||||
|
||||
#define DEBUG_FUNCTION_LINE_ERR(FMT, ARGS...) LOG_EX_DEFAULT(WHBLogPrintf, "##ERROR## ", "", FMT, ##ARGS)
|
||||
#define DEBUG_FUNCTION_LINE_WARN(FMT, ARGS...) LOG_EX_DEFAULT(WHBLogPrintf, "##WARN ## ", "", FMT, ##ARGS)
|
||||
|
||||
#define DEBUG_FUNCTION_LINE_ERR_LAMBDA(FILENAME, FUNCTION, LINE, FMT, ARGS...) LOG_EX(FILENAME, FUNCTION, LINE, WHBLogPrintf, "##ERROR## ", "", FMT, ##ARGS);
|
||||
|
||||
@ -52,6 +53,7 @@ extern "C" {
|
||||
#define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...) while (0)
|
||||
|
||||
#define DEBUG_FUNCTION_LINE_ERR(FMT, ARGS...) LOG_EX_DEFAULT(OSReport, "##ERROR## ", "\n", FMT, ##ARGS)
|
||||
#define DEBUG_FUNCTION_LINE_WARN(FMT, ARGS...) LOG_EX_DEFAULT(OSReport, "##WARN ## ", "\n", FMT, ##ARGS)
|
||||
|
||||
#define DEBUG_FUNCTION_LINE_ERR_LAMBDA(FILENAME, FUNCTION, LINE, FMT, ARGS...) LOG_EX(FILENAME, FUNCTION, LINE, OSReport, "##ERROR## ", "\n", FMT, ##ARGS);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user