obu-firmware builds against vanetza-idf from microbu-esp32c5/external, but that tree was gitignored, so a clone of this repository could not build the firmware it ships. It is now committed here as ordinary files in its own folder, microbu-esp32c5/: the colleague's commit cf4b99f plus the V2X2MAP bridge's signature verification (--trust) used on the bench. Nothing is fetched from or pushed to the colleague's repository; this repository and its remotes carry everything. The folder's own .gitignore keeps build output, downloaded components and private key material out, as it did there; the committed file set is identical to that repository's tracked files. The ESP32-C5 is still flashed from obu-firmware/, which only takes vanetza-idf from microbu-esp32c5/, so the two stay separate folders. FLASHING.md says how to take a newer version of the colleague's tree (copy it over the folder, rebuild, test, commit).
62 lines
1.2 KiB
C++
62 lines
1.2 KiB
C++
#include "xdg.hpp"
|
|
#include <cstdlib>
|
|
#include <pwd.h>
|
|
#include <stdexcept>
|
|
#include <unistd.h>
|
|
|
|
namespace vanetza
|
|
{
|
|
namespace pki
|
|
{
|
|
|
|
namespace
|
|
{
|
|
|
|
std::filesystem::path lookup_xdg_env(const char* env)
|
|
{
|
|
const char* env_value = std::getenv(env);
|
|
if (env_value) {
|
|
return std::filesystem::path(env_value);
|
|
} else {
|
|
return std::filesystem::path {};
|
|
}
|
|
}
|
|
|
|
std::filesystem::path lookup_home()
|
|
{
|
|
const char* home_value = std::getenv("HOME");
|
|
if (home_value && home_value[0] != '\0') {
|
|
return std::filesystem::path { home_value };
|
|
}
|
|
|
|
const passwd* pw = ::getpwuid(getuid());
|
|
if (pw && pw->pw_dir) {
|
|
return std::filesystem::path { pw->pw_dir };
|
|
}
|
|
|
|
throw std::runtime_error("cannot determine home directory");
|
|
}
|
|
|
|
} // namespace
|
|
|
|
std::filesystem::path xdg_config_home()
|
|
{
|
|
auto config_home = lookup_xdg_env("XDG_CONFIG_HOME");
|
|
if (config_home.empty()) {
|
|
config_home = lookup_home() / ".config";
|
|
}
|
|
return config_home;
|
|
}
|
|
|
|
std::filesystem::path xdg_data_home()
|
|
{
|
|
auto data_home = lookup_xdg_env("XDG_DATA_HOME");
|
|
if (data_home.empty()) {
|
|
data_home = lookup_home() / ".local/share";
|
|
}
|
|
return data_home;
|
|
}
|
|
|
|
} // namespace pki
|
|
} // namespace vanetza
|