#include <FileFinder.hpp>
Public Member Functions | |
FileFinder () | |
FileFinder (const std::string &rPath, RelativeTo::Value relativeTo) | |
void | SetPath (const std::string &rPath, RelativeTo::Value relativeTo) |
bool | Exists () const |
bool | IsFile () const |
bool | IsDir () const |
std::string | GetAbsolutePath () const |
bool | IsNewerThan (const FileFinder &rOtherEntity) const |
std::string | GetLeafName () const |
Static Public Member Functions | |
static bool | IsAbsolutePath (const std::string &rPath) |
static void | FakePath (RelativeTo::Value fakeWhat, const std::string &rFakePath) |
static void | StopFaking () |
Private Attributes | |
std::string | mAbsPath |
Static Private Attributes | |
static bool | msFaking = false |
static RelativeTo::Value | msFakeWhat = RelativeTo::Absolute |
static std::string | msFakePath = "" |
Definition at line 59 of file FileFinder.hpp.
FileFinder::FileFinder | ( | ) |
Default constructor for subclasses to use. They must call SetAbsolutePath() in their constructor.
This also allows classes to store a FileFinder instance that hasn't been properly set up yet, and assign to it later using operator=.
Definition at line 48 of file FileFinder.cpp.
FileFinder::FileFinder | ( | const std::string & | rPath, | |
RelativeTo::Value | relativeTo | |||
) |
Main constructor.
rPath | the path to the file/dir to find | |
relativeTo | how to interpret this path |
Definition at line 53 of file FileFinder.cpp.
References SetPath().
void FileFinder::SetPath | ( | const std::string & | rPath, | |
RelativeTo::Value | relativeTo | |||
) |
Change this FileFinder to point at a new location.
rPath | the path to the file/dir to find | |
relativeTo | how to interpret this path |
Definition at line 59 of file FileFinder.cpp.
References RelativeTo::Absolute, RelativeTo::AbsoluteOrCwd, ChasteBuildRootDir(), RelativeTo::ChasteSourceRoot, RelativeTo::ChasteTestOutput, RelativeTo::CWD, OutputFileHandler::GetChasteTestOutputDirectory(), IsAbsolutePath(), IsDir(), mAbsPath, msFakePath, msFakeWhat, msFaking, and NEVER_REACHED.
Referenced by HeartConfig::CopySchema(), FileFinder(), and HeartFileFinder::HeartFileFinder().
bool FileFinder::Exists | ( | ) | const |
Test whether we exist.
Definition at line 111 of file FileFinder.cpp.
References GetAbsolutePath().
Referenced by ColumnDataReader::ColumnDataReader(), Hdf5DataReader::CommonConstructor(), CellMLToSharedLibraryConverter::Convert(), HeartConfig::CopySchema(), BidomainTissue< SPACE_DIM >::CreateExtracellularConductivityTensors(), AbstractCardiacTissue< ELEMENT_DIM, SPACE_DIM >::CreateIntracellularConductivityTensor(), IsNewerThan(), CardiacSimulationArchiver< PROBLEM_CLASS >::Migrate(), and AbstractCardiacTissue< SPACE_DIM >::save().
bool FileFinder::IsFile | ( | ) | const |
Are we pointing at a file?
Definition at line 118 of file FileFinder.cpp.
References GetAbsolutePath().
Referenced by OutputFileHandler::CopyFileTo().
bool FileFinder::IsDir | ( | ) | const |
Are we pointing at a directory?
Definition at line 135 of file FileFinder.cpp.
References GetAbsolutePath().
Referenced by ColumnDataReader::ColumnDataReader(), Hdf5DataReader::CommonConstructor(), CardiacSimulationArchiver< PROBLEM_CLASS >::Migrate(), and SetPath().
std::string FileFinder::GetAbsolutePath | ( | ) | const |
Get the absolute path to this file/dir.
If this is a directory that exists, the absolute path is guaranteed to end in a '/'. If the directory doesn't exist, it will depend on what was supplied to the constructor.
Definition at line 152 of file FileFinder.cpp.
References mAbsPath.
Referenced by ColumnDataReader::ColumnDataReader(), Hdf5DataReader::CommonConstructor(), CellMLToSharedLibraryConverter::Convert(), OutputFileHandler::CopyFileTo(), HeartConfig::CopySchema(), Exists(), FibreReader< DIM >::FibreReader(), GetLeafName(), DynamicModelLoaderRegistry::GetLoader(), IsDir(), IsFile(), IsNewerThan(), CardiacSimulationArchiver< PROBLEM_CLASS >::Migrate(), AbstractCardiacTissue< SPACE_DIM >::save(), and ArchiveLocationInfo::SetArchiveDirectory().
bool FileFinder::IsNewerThan | ( | const FileFinder & | rOtherEntity | ) | const |
Test whether this file/dir is newer than another file/dir. Compares modification times.
rOtherEntity | the entity to test against. |
Definition at line 157 of file FileFinder.cpp.
References Exists(), and GetAbsolutePath().
Referenced by CellMLToSharedLibraryConverter::Convert().
std::string FileFinder::GetLeafName | ( | ) | const |
Get the leaf name of this file or directory.
Definition at line 167 of file FileFinder.cpp.
References GetAbsolutePath().
Referenced by OutputFileHandler::CopyFileTo().
bool FileFinder::IsAbsolutePath | ( | const std::string & | rPath | ) | [static] |
Test whether a path is absolute. Currently just checks whether the first character is '/'.
rPath | The path to test |
Definition at line 175 of file FileFinder.cpp.
Referenced by AbstractCardiacProblem< ELEMENT_DIM, ELEMENT_DIM, 1 >::load(), ArchiveLocationInfo::SetMeshPathname(), and SetPath().
void FileFinder::FakePath | ( | RelativeTo::Value | fakeWhat, | |
const std::string & | rFakePath | |||
) | [static] |
For testing purposes, fake the value of one of the normally fixed paths, e.g. ChasteSourceRoot.
fakeWhat | which path to fake | |
rFakePath | its fake value |
Definition at line 180 of file FileFinder.cpp.
References msFakePath, msFakeWhat, and msFaking.
void FileFinder::StopFaking | ( | ) | [static] |
Stop faking one of the fixed paths.
Definition at line 187 of file FileFinder.cpp.
References msFaking.
std::string FileFinder::mAbsPath [private] |
The absolute path to our file
Definition at line 63 of file FileFinder.hpp.
Referenced by GetAbsolutePath(), and SetPath().
bool FileFinder::msFaking = false [static, private] |
Whether to fake one of the fixed paths, e.g. ChasteSourceRoot
Definition at line 66 of file FileFinder.hpp.
Referenced by FakePath(), SetPath(), and StopFaking().
RelativeTo::Value FileFinder::msFakeWhat = RelativeTo::Absolute [static, private] |
Which path to fake
Definition at line 69 of file FileFinder.hpp.
Referenced by FakePath(), and SetPath().
std::string FileFinder::msFakePath = "" [static, private] |
The fake value of the faked path
Definition at line 72 of file FileFinder.hpp.
Referenced by FakePath(), and SetPath().