Utopia  2
Framework for studying models of complex & adaptive systems.
Functions
Filesystem
Collaboration diagram for Filesystem:

Functions

std::string Utopia::DataIO::expanduser (const std::string &path)
 Expands a path with a leading ~ character into an absolute path. More...
 
std::string Utopia::DataIO::get_abs_filepath (const Config &cfg)
 Extracts an absolute file path from a configuration. More...
 

Detailed Description

Filesystem tools

The Filesystem module contains tools that make interacting with the filesystem more convenient, e.g. to generate file paths from the configuration.

Function Documentation

◆ expanduser()

std::string Utopia::DataIO::expanduser ( const std::string &  path)

Expands a path with a leading ~ character into an absolute path.

This function uses the environment variable HOME and replaces a leading ~ character with that path. If there was no leading ~ character, the given path is returned.

Parameters
pathThe path to expand
Exceptions
Ifthe given path needs expansion but no HOME environment variable was set.

◆ get_abs_filepath()

std::string Utopia::DataIO::get_abs_filepath ( const Config cfg)

Extracts an absolute file path from a configuration.

Expected keys: filename, base_dir (optional). If no base_dir key is present, will prepend the current working directory.

If the base directory or the filename specify a relative directory, the resulting absolute path will start from the current working directory.

Furthermore, this function will call expanduser to allow using the ~ character to refer to the home directory.

Parameters
cfgThe configuration node with required key filename and optional key base_dir.