fwt_software/include/fgc/Paths.h

30 lines
1.1 KiB
C++

#pragma once
#include <optional>
#include <string>
#include <vector>
namespace fgc::paths {
// Expand a leading "~" (to $HOME) and any "$VAR" / "${VAR}" environment
// references in `path`. Returns the expanded path (unchanged if nothing to do).
std::string expandUser(const std::string& path);
// Absolute directory containing the running executable (via /proc/self/exe).
// Returns empty string if it cannot be determined.
std::string executableDir();
// The ordered list of locations searched for a config file, given an optional
// explicit --config argument. Exposed so callers can report what was tried.
std::vector<std::string> configSearchPaths(const std::string& cliArg = "");
// Resolve the config file path using configSearchPaths(): the first existing,
// readable file wins. Returns nullopt if none is found.
std::optional<std::string> resolveConfigPath(const std::string& cliArg = "");
// Default image output directory when none is configured
// ($XDG_DATA_HOME/fire_gimbal_control/images, else ~/.local/share/...).
std::string defaultOutputDir();
} // namespace fgc::paths