1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 22:28:11 +00:00

LibCore: Add a standard path for application data

This commit is contained in:
Timothy Flynn 2022-12-05 12:46:53 -05:00 committed by Andreas Kling
parent 4609477ac0
commit 49d74ee288
2 changed files with 19 additions and 0 deletions

View file

@ -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";

View file

@ -18,6 +18,7 @@ public:
static DeprecatedString downloads_directory();
static DeprecatedString tempfile_directory();
static DeprecatedString config_directory();
static DeprecatedString data_directory();
};
}