/* * Copyright (c) 2020, Andreas Kling * * SPDX-License-Identifier: BSD-2-Clause */ #include #include #include #include #include #include #include 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"sv); return LexicalPath::canonicalized_path(builder.to_string()); } String StandardPaths::downloads_directory() { StringBuilder builder; builder.append(home_directory()); builder.append("/Downloads"sv); return LexicalPath::canonicalized_path(builder.to_string()); } String StandardPaths::config_directory() { StringBuilder builder; builder.append(home_directory()); builder.append("/.config"sv); return LexicalPath::canonicalized_path(builder.to_string()); } String StandardPaths::tempfile_directory() { return "/tmp"; } }