srctree

Robin Linden parent e4e4c50a 5bec3a61
os/xdg: Add macOS-specific font paths

os/BUILD added: 35, removed: 3, total 32
@@ -89,7 +89,7 @@ cc_library(
name = "xdg",
srcs = select({
"@platforms//os:linux": ["xdg_linux.cpp"],
"@platforms//os:macos": ["xdg_linux.cpp"],
"@platforms//os:macos": ["xdg_macos.cpp"],
"@platforms//os:windows": ["xdg_windows.cpp"],
}),
hdrs = ["xdg.h"],
 
filename was Deleted added: 35, removed: 3, total 32
@@ -0,0 +1,32 @@
// SPDX-FileCopyrightText: 2024 Robin Lindén <dev@robinlinden.eu>
//
// SPDX-License-Identifier: BSD-2-Clause
 
#include "os/xdg.h"
 
#include <cstdlib>
#include <string>
#include <vector>
 
using namespace std::literals;
 
namespace os {
 
// This is okay as long as we don't call e.g. setenv(), unsetenv(), or putenv().
// NOLINTBEGIN(concurrency-mt-unsafe)
 
std::vector<std::string> font_paths() {
std::vector<std::string> paths{};
 
if (char const *home = std::getenv("HOME"); home != nullptr) {
paths.push_back(home + "/Library/Fonts"s);
}
 
paths.push_back("/Library/Fonts"s);
paths.push_back("/System/Library/Fonts"s);
return paths;
}
 
// NOLINTEND(concurrency-mt-unsafe)
 
} // namespace os