From afbeb8f977ba5c009e88f702242bba678486480f Mon Sep 17 00:00:00 2001 From: AnotherTest Date: Mon, 17 Aug 2020 19:13:15 +0430 Subject: [PATCH] LibCore: Add ConfigFile::get_for_lib() --- Libraries/LibCore/ConfigFile.cpp | 8 ++++++++ Libraries/LibCore/ConfigFile.h | 1 + 2 files changed, 9 insertions(+) diff --git a/Libraries/LibCore/ConfigFile.cpp b/Libraries/LibCore/ConfigFile.cpp index a36d99d3bd3..267513e9da8 100644 --- a/Libraries/LibCore/ConfigFile.cpp +++ b/Libraries/LibCore/ConfigFile.cpp @@ -34,6 +34,14 @@ namespace Core { +NonnullRefPtr ConfigFile::get_for_lib(const String& lib_name) +{ + String directory = StandardPaths::config_directory(); + auto path = String::format("%s/lib/%s.ini", directory.characters(), lib_name.characters()); + + return adopt(*new ConfigFile(path)); +} + NonnullRefPtr ConfigFile::get_for_app(const String& app_name) { String directory = StandardPaths::config_directory(); diff --git a/Libraries/LibCore/ConfigFile.h b/Libraries/LibCore/ConfigFile.h index 6a71ff9b88b..24865a0e488 100644 --- a/Libraries/LibCore/ConfigFile.h +++ b/Libraries/LibCore/ConfigFile.h @@ -37,6 +37,7 @@ namespace Core { class ConfigFile : public RefCounted { public: + static NonnullRefPtr get_for_lib(const String& lib_name); static NonnullRefPtr get_for_app(const String& app_name); static NonnullRefPtr get_for_system(const String& app_name); static NonnullRefPtr open(const String& path);