FileFinder Class Reference

#include <FileFinder.hpp>

Inherited by HeartFileFinder.

Collaboration diagram for FileFinder:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 FileFinder ()
 FileFinder (const std::string &rPath, RelativeTo::Value relativeTo)
 FileFinder (const std::string &rLeafName, const FileFinder &rParentOrSibling)
void SetPath (const std::string &rPath, RelativeTo::Value relativeTo)
void SetPath (const std::string &rLeafName, const FileFinder &rParentOrSibling)
bool Exists () const
bool IsFile () const
bool IsDir () const
std::string GetAbsolutePath () const
bool IsNewerThan (const FileFinder &rOtherEntity) const
std::string GetLeafName () const
FileFinder GetParent () 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 45 of file FileFinder.cpp.

Referenced by GetParent().

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 50 of file FileFinder.cpp.

References SetPath().

FileFinder::FileFinder ( const std::string &  rLeafName,
const FileFinder rParentOrSibling 
)

Find a file (or folder) relative to some file or directory. If the second argument is a directory, we look for the given leaf name within it. If the second argument is a file, then we look for a sibling. An exception is raised if rParentOrSibling does not exist.

Parameters:
rLeafName the leaf name of the file/dir to find
rParentOrSibling where to look for it

Definition at line 55 of file FileFinder.cpp.

References SetPath().


Member Function Documentation

bool FileFinder::Exists (  )  const
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 206 of file FileFinder.cpp.

References msFakePath, msFakeWhat, and msFaking.

std::string FileFinder::GetAbsolutePath (  )  const
std::string FileFinder::GetLeafName (  )  const

Get the leaf name of this file or directory.

Definition at line 184 of file FileFinder.cpp.

References EXCEPT_IF_NOT, and GetAbsolutePath().

Referenced by OutputFileHandler::CopyFileTo().

FileFinder FileFinder::GetParent (  )  const

Get a finder for the folder containing this file or directory.

Definition at line 192 of file FileFinder.cpp.

References RelativeTo::Absolute, EXCEPT_IF_NOT, FileFinder(), and GetAbsolutePath().

Referenced by SetPath().

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 201 of file FileFinder.cpp.

Referenced by ExtendedBidomainProblem< DIM >::load(), AbstractCardiacProblem< ELEMENT_DIM, ELEMENT_DIM, 1 >::load(), ArchiveLocationInfo::SetMeshPathname(), and SetPath().

bool FileFinder::IsDir (  )  const
bool FileFinder::IsFile (  )  const

Are we pointing at a file?

Definition at line 135 of file FileFinder.cpp.

References GetAbsolutePath().

Referenced by OutputFileHandler::CopyFileTo().

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 174 of file FileFinder.cpp.

References Exists(), and GetAbsolutePath().

Referenced by CellMLToSharedLibraryConverter::Convert().

void FileFinder::SetPath ( const std::string &  rLeafName,
const FileFinder rParentOrSibling 
)

Change this FileFinder to point at a new location, relative to some file or directory.

Parameters:
rLeafName the leaf name of the file/dir to find
rParentOrSibling where to look for it

Definition at line 112 of file FileFinder.cpp.

References RelativeTo::Absolute, EXCEPTION, Exists(), GetAbsolutePath(), GetParent(), IsDir(), and SetPath().

void FileFinder::SetPath ( const std::string &  rPath,
RelativeTo::Value  relativeTo 
)
void FileFinder::StopFaking (  )  [static]

Stop faking one of the fixed paths.

Definition at line 213 of file FileFinder.cpp.

References msFaking.


Member Data Documentation

std::string FileFinder::mAbsPath [private]

The absolute path to our file.

Definition at line 64 of file FileFinder.hpp.

Referenced by GetAbsolutePath(), and SetPath().

std::string FileFinder::msFakePath = "" [static, private]

The fake value of the faked path.

Definition at line 73 of file FileFinder.hpp.

Referenced by FakePath(), and SetPath().

RelativeTo::Value FileFinder::msFakeWhat = RelativeTo::Absolute [static, private]

Which path to fake.

Definition at line 70 of file FileFinder.hpp.

Referenced by FakePath(), and SetPath().

bool FileFinder::msFaking = false [static, private]

Whether to fake one of the fixed paths, e.g. ChasteSourceRoot.

Definition at line 67 of file FileFinder.hpp.

Referenced by FakePath(), SetPath(), and StopFaking().


The documentation for this class was generated from the following files:
Generated on Thu Dec 22 13:05:19 2011 for Chaste by  doxygen 1.6.3