ant
A2 ant: class-based analysis framework
ant::std_ext::system Struct Reference

#include <system.h>

Static Public Member Functions

static bool isInteractive ()
 Check if running an interactive shell / if a TTY is attached to stdin. More...
 
static std::string buildCmdLine (int argc, const char *const *argv)
 buildCmdLine little helper to reconstruct cmd line string from main(...) args More...
 
static std::list< std::string > lsFiles (const std::string &folder=".", const std::string &extension="", bool ignoreDotDirs=false, bool doNotPrependFolder=false)
 list files in a directory More...
 
static bool testopen (const std::string &filename, std::string &errmsg)
 testopen a given file More...
 
static bool testopen (const std::string &filename)
 
static std::string exec (const std::string &cmd)
 execute given cmd and return stdout (stderr is suppressed) More...
 
static std::string getCwd ()
 getCwd determines current working directory (cwd) More...
 
static std::string absolutePath (const std::string &path, const std::string &cwd=getCwd())
 absolutePath returns the absolute path of relative path w.r.t. given cwd More...
 
static bool isDeadLink (const std::string &filename)
 Check if filename is a dead symlink. More...
 
static bool path_exists (const std::string &path)
 Check if a path/file exists. For symlinks: only check the link itself, independent from destination. More...
 

Member Function Documentation

◆ absolutePath()

string system::absolutePath ( const std::string &  path,
const std::string &  cwd = getCwd() 
)
static

absolutePath returns the absolute path of relative path w.r.t. given cwd

Parameters
pathrelative path
cwdif empty, the current working dir is used
Returns
absolute path

◆ buildCmdLine()

string system::buildCmdLine ( int  argc,
const char *const *  argv 
)
static

buildCmdLine little helper to reconstruct cmd line string from main(...) args

Parameters
argc
argv
Returns
properly build string from argc and argv

◆ exec()

string system::exec ( const std::string &  cmd)
static

execute given cmd and return stdout (stderr is suppressed)

Parameters
cmdthe command to execute
Returns
stdout of cmd

◆ getCwd()

string system::getCwd ( )
static

getCwd determines current working directory (cwd)

Returns
properly constructed std::string containing cwd

◆ isDeadLink()

bool ant::std_ext::system::isDeadLink ( const std::string &  filename)
static

Check if filename is a dead symlink.

Parameters
filename
Returns

◆ isInteractive()

bool system::isInteractive ( )
static

Check if running an interactive shell / if a TTY is attached to stdin.

Returns

◆ lsFiles()

list< string > system::lsFiles ( const std::string &  folder = ".",
const std::string &  extension = "",
bool  ignoreDotDirs = false,
bool  doNotPrependFolder = false 
)
static

list files in a directory

Parameters
folderPath to directory to list
extensionFile extension to look for. all files if empty.
Returns
a list of all filenames with path prepended

◆ path_exists()

bool ant::std_ext::system::path_exists ( const std::string &  path)
static

Check if a path/file exists. For symlinks: only check the link itself, independent from destination.

Parameters
path
Returns

◆ testopen() [1/2]

bool ant::std_ext::system::testopen ( const std::string &  filename,
std::string &  errmsg 
)
static

testopen a given file

Parameters
filenameto open as test
errmsgnon-empty if unsuccessful open
Returns
true if file can be opened for reading

◆ testopen() [2/2]

bool system::testopen ( const std::string &  filename)
static

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