FileFinder Class Reference

#include <FileFinder.hpp>

Inheritance diagram for FileFinder:

Inheritance graph
[legend]
Collaboration diagram for FileFinder:

Collaboration graph
[legend]

List of all members.

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 = ""


Detailed Description

A helper class for finding files or directories, given paths which can be relative to various locations (e.g. the Chaste source tree root, the current directory, the Chaste test output directory, or an absolute path).

Definition at line 59 of file FileFinder.hpp.


Constructor & Destructor Documentation

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.

Parameters:
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().


Member Function Documentation

void FileFinder::SetPath ( const std::string &  rPath,
RelativeTo::Value  relativeTo 
)

bool FileFinder::Exists (  )  const

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

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.

Parameters:
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 '/'.

Parameters:
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.

Parameters:
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.


Member Data Documentation

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().


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

Generated on Mon Apr 18 11:37:06 2011 for Chaste by  doxygen 1.5.5