mirror of
https://github.com/SerenityOS/serenity
synced 2026-05-05 22:52:10 +02:00
LibCore: Add a standard path for application data
This commit is contained in:
committed by
Andreas Kling
parent
4609477ac0
commit
49d74ee288
@@ -65,6 +65,24 @@ DeprecatedString StandardPaths::config_directory()
|
||||
return LexicalPath::canonicalized_path(builder.to_deprecated_string());
|
||||
}
|
||||
|
||||
DeprecatedString StandardPaths::data_directory()
|
||||
{
|
||||
if (auto* data_directory = getenv("XDG_DATA_HOME"))
|
||||
return LexicalPath::canonicalized_path(data_directory);
|
||||
|
||||
StringBuilder builder;
|
||||
builder.append(home_directory());
|
||||
#if defined(AK_OS_SERENITY)
|
||||
builder.append("/.data"sv);
|
||||
#elif defined(AK_OS_MACOS)
|
||||
builder.append("/Library/Application Support"sv);
|
||||
#else
|
||||
builder.append("/.local/share"sv);
|
||||
#endif
|
||||
|
||||
return LexicalPath::canonicalized_path(builder.to_deprecated_string());
|
||||
}
|
||||
|
||||
DeprecatedString StandardPaths::tempfile_directory()
|
||||
{
|
||||
return "/tmp";
|
||||
|
||||
@@ -18,6 +18,7 @@ public:
|
||||
static DeprecatedString downloads_directory();
|
||||
static DeprecatedString tempfile_directory();
|
||||
static DeprecatedString config_directory();
|
||||
static DeprecatedString data_directory();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user