mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-30 00:31:14 +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
Notes:
sideshowbarker
2024-07-17 03:38:18 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/4609477ac0 Pull-request: https://github.com/SerenityOS/serenity/pull/16358 Reviewed-by: https://github.com/alimpfard
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <AK/Platform.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <LibCore/StandardPaths.h>
|
||||
#include <pwd.h>
|
||||
|
@ -51,9 +52,16 @@ DeprecatedString StandardPaths::downloads_directory()
|
|||
|
||||
DeprecatedString StandardPaths::config_directory()
|
||||
{
|
||||
if (auto* config_directory = getenv("XDG_CONFIG_HOME"))
|
||||
return LexicalPath::canonicalized_path(config_directory);
|
||||
|
||||
StringBuilder builder;
|
||||
builder.append(home_directory());
|
||||
#if defined(AK_OS_MACOS)
|
||||
builder.append("/Library/Preferences"sv);
|
||||
#else
|
||||
builder.append("/.config"sv);
|
||||
#endif
|
||||
return LexicalPath::canonicalized_path(builder.to_deprecated_string());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue