COPASI API  4.40.278
CDirEntry Class Reference

#include <CDirEntry.h>

Static Public Member Functions

static std::string baseName (const std::string &path)
 
static std::vector< std::string > compilePattern (const std::string &pattern)
 
static bool copy (const std::string &from, const std::string &to)
 
static bool createDir (const std::string &dir, const std::string &parent="")
 
static std::string createTmpName (const std::string &dir, const std::string &suffix)
 
static std::string dirName (const std::string &path)
 
static bool exist (const std::string &path)
 
static std::string fileName (const std::string &path)
 
static bool isDir (const std::string &path)
 
static bool isFile (const std::string &path)
 
static bool isReadable (const std::string &path)
 
static bool isRelativePath (const std::string &path)
 
static bool isWritable (const std::string &path)
 
static bool makePathAbsolute (std::string &relativePath, const std::string &absoluteTo)
 
static bool makePathRelative (std::string &absolutePath, const std::string &relativeTo)
 
static bool match (const std::string &name, const std::vector< std::string > &patternList)
 
static bool move (const std::string &from, const std::string &to)
 
static std::string normalize (const std::string &path)
 
static bool remove (const std::string &path)
 
static bool removeFiles (const std::string &pattern, const std::string &dir)
 
static std::string suffix (const std::string &path)
 

Static Public Attributes

static const std::string Separator = "/"
 

Static Private Member Functions

static bool matchInternal (const std::string &name, const std::string pattern, std::string::size_type &at, std::string::size_type &after)
 

Detailed Description

This class provides an OS independent interface to directory entries such as files and directories.

Member Function Documentation

◆ baseName()

std::string CDirEntry::baseName ( const std::string &  path)
static

Returns the base name, i.e., the directory path and the the suffix are removed from 'path'.

Parameters
conststd::string & path
Returns
std::string baseName

References Separator.

Referenced by CDataModel::autoSave(), CDataModel::copyExperimentalDataTo(), CSEDMLExporter::createModel(), CDataModel::exportShinyArchive(), CDataModel::getDefaultFileName(), CDataModel::importSBML(), CDataModel::importSEDML(), CDataModel::loadFromFile(), and CDataModel::loadModel().

◆ compilePattern()

std::vector< std::string > CDirEntry::compilePattern ( const std::string &  pattern)
static

Compiles the pattern to a patternList. Valid wildcards in the pattern are: '*' matches any number of characters and '?' matches exactly one character.

Parameters
conststd::string & pattern
Returns
std::vector< std::string > patternList

References min.

Referenced by removeFiles().

◆ copy()

bool CDirEntry::copy ( const std::string &  from,
const std::string &  to 
)
static

Move a file from. If to is the directory the filename of from is appended.

Parameters
conststd::string & from
conststd::string & to
Returns
bool success

References fileName(), CLocaleString::fromUtf8(), isDir(), isFile(), and Separator.

Referenced by CModelVersionHierarchy::addVersion(), and CModelVersionHierarchy::restoreVersion().

◆ createDir()

bool CDirEntry::createDir ( const std::string &  dir,
const std::string &  parent = "" 
)
static

Create the directory 'dir' in the parent directory 'parent'.

Parameters
conststd::string & dir
conststd::string & parent (Default: current working directory)
Returns
bool success

References CLocaleString::fromUtf8(), isDir(), isWritable(), and Separator.

Referenced by CModelVersionHierarchy::addVersion(), COptions::getConfigDir(), COptions::getTemp(), and CDataModel::openCombineArchive().

◆ createTmpName()

std::string CDirEntry::createTmpName ( const std::string &  dir,
const std::string &  suffix 
)
static

Create a name for a temporary directory entry. The directory entry will be located in the directory given

Parameters
conststd::string & dir
conststd::string & suffix
Returns
std::string tmpName

References C_INT32, CRandom::createGenerator(), CLocaleString::fromUtf8(), CRandom::getRandomU(), isDir(), isWritable(), pdelete, Separator, suffix(), and CLocaleString::toUtf8().

Referenced by CDataModel::loadFromString(), CDataModel::openCombineArchive(), CDataModel::saveModel(), and CModelVersionHierarchy::updateVersionXML().

◆ dirName()

std::string CDirEntry::dirName ( const std::string &  path)
static

◆ exist()

◆ fileName()

◆ isDir()

bool CDirEntry::isDir ( const std::string &  path)
static

Check whether the directory entry specified by 'path' is is a directory.

Parameters
conststd::string & path
Returns
bool isDir

References CLocaleString::fromUtf8().

Referenced by copy(), createDir(), createTmpName(), COptions::getTemp(), makePathAbsolute(), makePathRelative(), move(), and remove().

◆ isFile()

bool CDirEntry::isFile ( const std::string &  path)
static

Check whether the directory entry specified by 'path' is a file.

Parameters
conststd::string & path
Returns
bool isFile

References CLocaleString::fromUtf8().

Referenced by copy(), makePathAbsolute(), makePathRelative(), move(), and remove().

◆ isReadable()

bool CDirEntry::isReadable ( const std::string &  path)
static

Check whether the directory entry specified by 'path' is is readable.

Parameters
conststd::string & path
Returns
bool isReadable

References CLocaleString::fromUtf8().

◆ isRelativePath()

◆ isWritable()

bool CDirEntry::isWritable ( const std::string &  path)
static

◆ makePathAbsolute()

◆ makePathRelative()

bool CDirEntry::makePathRelative ( std::string &  absolutePath,
const std::string &  relativeTo 
)
static

Makes the absolute path relative to the path given in relativeTo

Parameters
std::string& absolutePath
conststd::string & relativeTo
Returns
bool success

References dirName(), isDir(), isFile(), isRelativePath(), min, and normalize().

Referenced by CCopasiXMLInterface::saveParameter(), CCopasiXML::saveSBMLReference(), and CCopasiXML::saveTaskList().

◆ match()

bool CDirEntry::match ( const std::string &  name,
const std::vector< std::string > &  patternList 
)
static

Compare the name against the pattern list and returns whether the name matches. The patternList can be created from a pattern by the compilePattern method.

Parameters
conststd::string & name
conststd::vector< std::string > & patternList
Returns
bool match

References matchInternal().

Referenced by removeFiles().

◆ matchInternal()

bool CDirEntry::matchInternal ( const std::string &  name,
const std::string  pattern,
std::string::size_type &  at,
std::string::size_type &  after 
)
staticprivate

This private methods checks whether the active section matches the secified patter. The section is automatically advanced to allow repeated calls. On the first call 'at' must be 0. The parameters 'at' and 'after' must not be changed outside this method.

Parameters
conststd::string & name
conststd::string pattern
std::string::size_type& at
std::string::size_type& after
Returns
bool match

Referenced by match().

◆ move()

bool CDirEntry::move ( const std::string &  from,
const std::string &  to 
)
static

Move a file from. If to is the directory the filename of from is appended.

Parameters
conststd::string & from
conststd::string & to
Returns
bool success

References exist(), fileName(), CLocaleString::fromUtf8(), isDir(), isFile(), remove(), and Separator.

Referenced by CDataModel::saveModel(), and CModelVersionHierarchy::updateVersionXML().

◆ normalize()

std::string CDirEntry::normalize ( const std::string &  path)
static

This method normalizes the path, i.e., it converts all '\' to '/' (only on WIN32) and collapses '^./' to '^', '/./' to '/', and '[^/]+/../' to '/'

Parameters
conststd::string & path
Returns
std::string normalizedPath

References COptions::getValue().

Referenced by CRecentFiles::addFile(), CDataModel::importSBML(), CDataModel::importSEDML(), isRelativePath(), CDataModel::loadFromFile(), CDataModel::loadModel(), makePathAbsolute(), makePathRelative(), CDataModel::saveModel(), CDataModel::setSBMLFileName(), and CDataModel::setSEDMLFileName().

◆ remove()

bool CDirEntry::remove ( const std::string &  path)
static

◆ removeFiles()

bool CDirEntry::removeFiles ( const std::string &  pattern,
const std::string &  dir 
)
static

Remove files or directories matching the pattern in directory dir.

Parameters
conststd::string & pattern
conststd::string & dir
Returns
bool success

References compilePattern(), CLocaleString::fromUtf8(), match(), remove(), Separator, and CLocaleString::toUtf8().

Referenced by CModelVersionHierarchy::deleteVersion().

◆ suffix()

std::string CDirEntry::suffix ( const std::string &  path)
static

Returns the suffix, i.e., the directory path and the the base name are removed from 'path'.

Parameters
conststd::string & path
Returns
std::string basename

References Separator.

Referenced by createTmpName(), CDataModel::importSBML(), CDataModel::importSEDML(), CDataModel::loadFromFile(), and CDataModel::loadModel().

Member Data Documentation

◆ Separator


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