mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-28 11:49:44 +00:00
LibCore: Add a standard path for application data
This commit is contained in:
parent
4609477ac0
commit
49d74ee288
Notes:
sideshowbarker
2024-07-17 23:07:41 +09:00
Author: https://github.com/trflynn89
Commit: 49d74ee288
Pull-request: https://github.com/SerenityOS/serenity/pull/16358
Reviewed-by: https://github.com/alimpfard
2 changed files with 19 additions and 0 deletions
|
@ -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";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue