mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-24 18:32:28 -05:00
1682f0b760
SPDX License Identifiers are a more compact / standardized way of representing file license information. See: https://spdx.dev/resources/use/#identifiers This was done with the `ambr` search and replace tool. ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
57 lines
1.3 KiB
C++
57 lines
1.3 KiB
C++
/*
|
|
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <AK/LexicalPath.h>
|
|
#include <AK/String.h>
|
|
#include <AK/StringBuilder.h>
|
|
#include <LibCore/StandardPaths.h>
|
|
#include <pwd.h>
|
|
#include <stdlib.h>
|
|
#include <unistd.h>
|
|
|
|
namespace Core {
|
|
|
|
String StandardPaths::home_directory()
|
|
{
|
|
if (auto* home_env = getenv("HOME"))
|
|
return LexicalPath::canonicalized_path(home_env);
|
|
|
|
auto* pwd = getpwuid(getuid());
|
|
String path = pwd ? pwd->pw_dir : "/";
|
|
endpwent();
|
|
return LexicalPath::canonicalized_path(path);
|
|
}
|
|
|
|
String StandardPaths::desktop_directory()
|
|
{
|
|
StringBuilder builder;
|
|
builder.append(home_directory());
|
|
builder.append("/Desktop");
|
|
return LexicalPath::canonicalized_path(builder.to_string());
|
|
}
|
|
|
|
String StandardPaths::downloads_directory()
|
|
{
|
|
StringBuilder builder;
|
|
builder.append(home_directory());
|
|
builder.append("/Downloads");
|
|
return LexicalPath::canonicalized_path(builder.to_string());
|
|
}
|
|
|
|
String StandardPaths::config_directory()
|
|
{
|
|
StringBuilder builder;
|
|
builder.append(home_directory());
|
|
builder.append("/.config");
|
|
return LexicalPath::canonicalized_path(builder.to_string());
|
|
}
|
|
|
|
String StandardPaths::tempfile_directory()
|
|
{
|
|
return "/tmp";
|
|
}
|
|
|
|
}
|