From b658474b6aed38070eee4384184ad707d6ebe427 Mon Sep 17 00:00:00 2001 From: Mateusz Daniluk <121170681+VeithMetro@users.noreply.github.com> Date: Tue, 5 Dec 2023 10:57:27 +0100 Subject: [PATCH] [Messaging] Fixing warning reporting config (when messaging config comes from a separate file) (#1458) * Fixing warning reporting config when obtained from a separate file * Adding a IsPathAbsolute() inline static method for Core::File, using it for messaging config * Using [] instead of at() and checking the size before so that no exception is thrown --- Source/WPEFramework/PluginHost.cpp | 11 +++++++++-- Source/core/FileSystem.h | 8 ++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Source/WPEFramework/PluginHost.cpp b/Source/WPEFramework/PluginHost.cpp index a52940406..4bee98786 100644 --- a/Source/WPEFramework/PluginHost.cpp +++ b/Source/WPEFramework/PluginHost.cpp @@ -576,7 +576,14 @@ POP_WARNING() if (_config->MessagingCategoriesFile()) { - messagingSettings = Core::Directory::Normalize(Core::File::PathName(options.configFile)) + _config->MessagingCategories(); + string messagingCategories = _config->MessagingCategories(); + + if (Core::File::IsPathAbsolute(messagingCategories)) { + messagingSettings = messagingCategories; + } + else { + messagingSettings = Core::Directory::Normalize(Core::File::PathName(options.configFile)) + messagingCategories; + } std::ifstream inputFile (messagingSettings, std::ifstream::in); std::stringstream buffer; @@ -641,7 +648,7 @@ POP_WARNING() ReportingSettings WarningReporting; } gc; - gc.FromString(_config->MessagingCategories()); + gc.FromString(messagingSettings); WarningReporting::WarningReportingUnit::Instance().Defaults(gc.WarningReporting.Settings.Value()); #endif diff --git a/Source/core/FileSystem.h b/Source/core/FileSystem.h index 1e5c9aa40..03b8b414d 100644 --- a/Source/core/FileSystem.h +++ b/Source/core/FileSystem.h @@ -198,6 +198,14 @@ namespace Core { return (result); } + inline static bool IsPathAbsolute(const string& path) + { +#ifdef __WINDOWS__ + return ((path.size() > 0 && (path[0] == '\\' || path[0] == '/')) || (path.size() > 2 && path[1] == ':' && (path[2] == '\\' || path[2] == '/'))); +#else + return (path.size() > 0 && path[0] == '/'); +#endif + } inline static string Extension(const string& name) { string result;