1#ifndef DATAIO_FILESYSTEM_HH
2#define DATAIO_FILESYSTEM_HH
8#include "../core/exceptions.hh"
9#include "../core/types.hh"
43 using namespace std::string_literals;
45 if (path.empty()
or path.substr(0, 1) !=
"~"s) {
49 const std::string
HOME = std::getenv(
"HOME");
51 throw std::invalid_argument(
52 "Cannot expand path because the environment variable 'HOME' was "
53 "not set! Use an absolute path to specify the given path: "
57 return HOME + path.substr(1, std::string::npos);
74 using std::filesystem::path;
75 using std::filesystem::current_path;
80 if (cfg[
"base_dir"]) {
// end of group DataIO
YAML::Node Config
Type of a variadic dictionary-like data structure used throughout Utopia.
Definition types.hh:71
Container select_entities(const Manager &mngr, const DataIO::Config &sel_cfg)
Select entities according to parameters specified in a configuration.
Definition select.hh:213
std::string expanduser(const std::string &path)
Expands a path with a leading ~ character into an absolute path.
Definition filesystem.hh:42
std::string get_abs_filepath(const Config &cfg)
Extracts an absolute file path from a configuration.
Definition filesystem.hh:73