Stride Reference Manual  - generated for commit 9643b11
stride::util::FileSys Class Reference

Utilities for interaction with filesystem. More...

#include <FileSys.h>

Collaboration diagram for stride::util::FileSys:
Collaboration graph

Classes

struct  Dirs
 Using this to avoid global variables & their initialization. More...
 

Static Public Member Functions

static bool IsDirectoryString (const std::string &s)
 String represents a directory path (relative or absolute) iff it contains at least one / (may be a trailing one). More...
 
static bool CreateDirectory (std::string s)
 Create a directory relative to the current directory with the given path, returns if it was succesful. More...
 
static filesys::path BuildPath (const std::string &output_prefix, const std::string &filename)
 Interpret prefix (directory or filename prefix) and return appropriate path. More...
 
static boost::property_tree::ptree ReadPtreeFile (const filesys::path &f_p)
 Read ptree from file at path. More...
 
static boost::property_tree::ptree ReadPtreeFile (const std::string &f_n)
 Read ptree from file specifified by name string. More...
 
static void WritePtreeFile (const filesys::path &f_p, const boost::property_tree::ptree &pt)
 Write ptree to file at path. More...
 
static void WritePtreeFile (const std::string &f_n, const boost::property_tree::ptree &pt)
 Write ptree to file specifified by name string. More...
 
static filesys::path GetCurrentDir ()
 Get path to the current directory. More...
 
static filesys::path GetExecPath ()
 Get path of the executable. More...
 
static bool CheckInstallEnv (std::function< void(const std::string &)> logger=std::function< void(const std::string &)>())
 Verify that current dir is root dir and all install dirs are present. More...
 
static filesys::path GetBinDir ()
 Return bin dir (only relevant when use_install_dirs mode is active) More...
 
static filesys::path GetConfigDir ()
 Return config dir (only relevant when use_install_dirs mode is active) More...
 
static filesys::path GetDataDir ()
 /// Return data dir (only relevant when use_install_dirs mode is active) More...
 
static filesys::path GetRootDir ()
 Return install root dir (only relevant when use_install_dirs mode is active) More...
 
static filesys::path GetTestsDir ()
 Return tests dir (only relevant when use_install_dirs mode is active) More...
 

Static Private Member Functions

static Dirs Initialize ()
 Initialize all paths. More...
 
static DirsGet ()
 Return paths. More...
 

Detailed Description

Utilities for interaction with filesystem.

Definition at line 42 of file FileSys.h.

Member Function Documentation

bool stride::util::FileSys::IsDirectoryString ( const std::string &  s)
static

String represents a directory path (relative or absolute) iff it contains at least one / (may be a trailing one).

Definition at line 193 of file FileSys.cpp.

Referenced by BuildPath(), and stride::ControlHelper::CheckOutputPrefix().

Here is the caller graph for this function:

bool stride::util::FileSys::CreateDirectory ( std::string  s)
static

Create a directory relative to the current directory with the given path, returns if it was succesful.

Definition at line 199 of file FileSys.cpp.

Referenced by stride::ControlHelper::CheckOutputPrefix().

Here is the caller graph for this function:

filesys::path stride::util::FileSys::BuildPath ( const std::string &  output_prefix,
const std::string &  filename 
)
static

Interpret prefix (directory or filename prefix) and return appropriate path.

Definition at line 52 of file FileSys.cpp.

References IsDirectoryString().

Referenced by stride::GenPopController::Control(), stride::StanController::Control(), stride::Population::Create(), stride::output::InfectedFile::InfectedFile(), stride::output::SummaryFile::Initialize(), stride::output::PersonsFile::Initialize(), and stride::ControlHelper::InstallLogger().

Here is the call graph for this function:

Here is the caller graph for this function:

ptree stride::util::FileSys::ReadPtreeFile ( const filesys::path &  f_p)
static

Read ptree from file at path.

Definition at line 208 of file FileSys.cpp.

Referenced by stride::SimBuilder::ReadAgeContactPtree(), stride::SimBuilder::ReadDiseasePtree(), and stride::DiseaseSeeder::Vaccinate().

Here is the caller graph for this function:

ptree stride::util::FileSys::ReadPtreeFile ( const std::string &  f_n)
static

Read ptree from file specifified by name string.

Definition at line 227 of file FileSys.cpp.

void stride::util::FileSys::WritePtreeFile ( const filesys::path &  f_p,
const boost::property_tree::ptree &  pt 
)
static

Write ptree to file at path.

Definition at line 229 of file FileSys.cpp.

void stride::util::FileSys::WritePtreeFile ( const std::string &  f_n,
const boost::property_tree::ptree &  pt 
)
static

Write ptree to file specifified by name string.

Definition at line 240 of file FileSys.cpp.

static filesys::path stride::util::FileSys::GetCurrentDir ( )
inlinestatic

Get path to the current directory.

Definition at line 69 of file FileSys.h.

References Get(), and stride::util::FileSys::Dirs::m_current_dir.

Referenced by stride::ControlHelper::LogStartup().

Here is the call graph for this function:

Here is the caller graph for this function:

static filesys::path stride::util::FileSys::GetExecPath ( )
inlinestatic

Get path of the executable.

Definition at line 72 of file FileSys.h.

References CheckInstallEnv(), Get(), and stride::util::FileSys::Dirs::m_exec_path.

Referenced by stride::ControlHelper::LogStartup().

Here is the call graph for this function:

Here is the caller graph for this function:

bool stride::util::FileSys::CheckInstallEnv ( std::function< void(const std::string &)>  logger = std::function<void(const std::string&)>())
static

Verify that current dir is root dir and all install dirs are present.

Parameters
loggerlogger verification finds failures; defaults to no-op.
Returns
staus true iff everything verifies ok.

There has to be a config dir in the install root dir.

There has to be a data dir in the install root dir.

There has to be a data dir in the install root dir.

Definition at line 65 of file FileSys.cpp.

Referenced by stride::ControlHelper::CheckEnv(), and GetExecPath().

Here is the caller graph for this function:

static filesys::path stride::util::FileSys::GetBinDir ( )
inlinestatic

Return bin dir (only relevant when use_install_dirs mode is active)

Definition at line 82 of file FileSys.h.

References Get(), and stride::util::FileSys::Dirs::m_bin_dir.

Here is the call graph for this function:

static filesys::path stride::util::FileSys::GetConfigDir ( )
inlinestatic

Return config dir (only relevant when use_install_dirs mode is active)

Definition at line 85 of file FileSys.h.

References Get(), and stride::util::FileSys::Dirs::m_config_dir.

Referenced by stride::ControlHelper::LogStartup().

Here is the call graph for this function:

Here is the caller graph for this function:

static filesys::path stride::util::FileSys::GetDataDir ( )
inlinestatic
static filesys::path stride::util::FileSys::GetRootDir ( )
inlinestatic

Return install root dir (only relevant when use_install_dirs mode is active)

Definition at line 91 of file FileSys.h.

References Get(), and stride::util::FileSys::Dirs::m_root_dir.

Referenced by stride::ControlHelper::LogStartup().

Here is the call graph for this function:

Here is the caller graph for this function:

static filesys::path stride::util::FileSys::GetTestsDir ( )
inlinestatic

Return tests dir (only relevant when use_install_dirs mode is active)

Definition at line 94 of file FileSys.h.

References Get(), and stride::util::FileSys::Dirs::m_tests_dir.

Here is the call graph for this function:

FileSys::Dirs & stride::util::FileSys::Get ( )
staticprivate

Return paths.

Definition at line 96 of file FileSys.cpp.

Referenced by GetBinDir(), GetConfigDir(), GetCurrentDir(), GetDataDir(), GetExecPath(), GetRootDir(), and GetTestsDir().

Here is the caller graph for this function:


The documentation for this class was generated from the following files: