mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:47:45 +00:00
LibCore: Support XDG_CONFIG_HOME when determing the user's config path
And default to a path commonly used depending on the operating system.
This commit is contained in:
parent
ae0606711c
commit
4609477ac0
1 changed files with 8 additions and 0 deletions
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include <AK/DeprecatedString.h>
|
#include <AK/DeprecatedString.h>
|
||||||
#include <AK/LexicalPath.h>
|
#include <AK/LexicalPath.h>
|
||||||
|
#include <AK/Platform.h>
|
||||||
#include <AK/StringBuilder.h>
|
#include <AK/StringBuilder.h>
|
||||||
#include <LibCore/StandardPaths.h>
|
#include <LibCore/StandardPaths.h>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
|
@ -51,9 +52,16 @@ DeprecatedString StandardPaths::downloads_directory()
|
||||||
|
|
||||||
DeprecatedString StandardPaths::config_directory()
|
DeprecatedString StandardPaths::config_directory()
|
||||||
{
|
{
|
||||||
|
if (auto* config_directory = getenv("XDG_CONFIG_HOME"))
|
||||||
|
return LexicalPath::canonicalized_path(config_directory);
|
||||||
|
|
||||||
StringBuilder builder;
|
StringBuilder builder;
|
||||||
builder.append(home_directory());
|
builder.append(home_directory());
|
||||||
|
#if defined(AK_OS_MACOS)
|
||||||
|
builder.append("/Library/Preferences"sv);
|
||||||
|
#else
|
||||||
builder.append("/.config"sv);
|
builder.append("/.config"sv);
|
||||||
|
#endif
|
||||||
return LexicalPath::canonicalized_path(builder.to_deprecated_string());
|
return LexicalPath::canonicalized_path(builder.to_deprecated_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue