Skip to content

Commit

Permalink
[Messaging] Fixing warning reporting config (when messaging config co…
Browse files Browse the repository at this point in the history
…mes 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
  • Loading branch information
VeithMetro authored Dec 5, 2023
1 parent 7ca5f7a commit b658474
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Source/WPEFramework/PluginHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions Source/core/FileSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit b658474

Please sign in to comment.