LibCore: Add StandardPaths thing to retrieve various standard locations

Fixes #1853.
This commit is contained in:
Andreas Kling 2020-04-19 19:57:05 +02:00
parent 3b434068eb
commit c45e16f605
Notes: sideshowbarker 2024-07-19 07:27:23 +09:00
10 changed files with 51 additions and 25 deletions

View file

@ -27,7 +27,7 @@
#include <AK/StringBuilder.h>
#include <LibCore/ConfigFile.h>
#include <LibCore/File.h>
#include <LibCore/UserInfo.h>
#include <LibCore/StandardPaths.h>
#include <pwd.h>
#include <stdio.h>
#include <unistd.h>
@ -36,9 +36,7 @@ namespace Core {
NonnullRefPtr<ConfigFile> ConfigFile::get_for_app(const String& app_name)
{
String home_path = get_current_user_home_path();
if (home_path == "/")
home_path = String::format("/tmp");
String home_path = StandardPaths::home_directory();
auto path = String::format("%s/%s.ini", home_path.characters(), app_name.characters());
return adopt(*new ConfigFile(path));
}