diff --git a/source/plugin/PluginDataFactory.cpp b/source/plugin/PluginDataFactory.cpp index 6987f6b..bfa06ef 100644 --- a/source/plugin/PluginDataFactory.cpp +++ b/source/plugin/PluginDataFactory.cpp @@ -40,23 +40,21 @@ std::forward_list> 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()); } } diff --git a/source/utils/logger.h b/source/utils/logger.h index 2052e1d..aaa3ef6 100644 --- a/source/utils/logger.h +++ b/source/utils/logger.h @@ -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);