diff options
author | AnotherTest <ali.mpfard@gmail.com> | 2020-08-17 19:13:15 +0430 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-08-18 12:07:32 +0200 |
commit | afbeb8f977ba5c009e88f702242bba678486480f (patch) | |
tree | 435bd38524670b5828a52561c9412080ce82283d /Libraries/LibCore | |
parent | 117686527692d33d6fb4cf233a4f8df0341fc8fa (diff) | |
download | serenity-afbeb8f977ba5c009e88f702242bba678486480f.zip |
LibCore: Add ConfigFile::get_for_lib()
Diffstat (limited to 'Libraries/LibCore')
-rw-r--r-- | Libraries/LibCore/ConfigFile.cpp | 8 | ||||
-rw-r--r-- | Libraries/LibCore/ConfigFile.h | 1 |
2 files changed, 9 insertions, 0 deletions
diff --git a/Libraries/LibCore/ConfigFile.cpp b/Libraries/LibCore/ConfigFile.cpp index a36d99d3bd..267513e9da 100644 --- a/Libraries/LibCore/ConfigFile.cpp +++ b/Libraries/LibCore/ConfigFile.cpp @@ -34,6 +34,14 @@ namespace Core { +NonnullRefPtr<ConfigFile> 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> 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 6a71ff9b88..24865a0e48 100644 --- a/Libraries/LibCore/ConfigFile.h +++ b/Libraries/LibCore/ConfigFile.h @@ -37,6 +37,7 @@ namespace Core { class ConfigFile : public RefCounted<ConfigFile> { public: + static NonnullRefPtr<ConfigFile> get_for_lib(const String& lib_name); static NonnullRefPtr<ConfigFile> get_for_app(const String& app_name); static NonnullRefPtr<ConfigFile> get_for_system(const String& app_name); static NonnullRefPtr<ConfigFile> open(const String& path); |