HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FilePath Class Reference

#include <File.h>

Public Types

enum  Type { TypeRelative = 0, TypeAbsolute = 1, TypeNetwork = 2 }
 
enum  Format { FormatWindows = 0, FormatPosix = 1, FormatNative = FormatPosix }
 

Public Member Functions

 FilePath ()
 
 ~FilePath ()
 
bool operator== (const FilePath &rhs) const
 
bool operator!= (const FilePath &rhs) const
 
Syntactic Operations
 FilePath (const string &str)
 Construct a path from a standard string. More...
 
 FilePath (const char *str)
 Construct a path from a C-style string. More...
 
 operator string () const
 Convert a path to a standard string. More...
 
void assign (const string &str)
 Assign a path from a standard string. More...
 
string asString (Format format=FormatNative) const
 Return this path as a standard string with the given format. More...
 
bool isEmpty () const
 Return true if the given path is empty. More...
 
bool isAbsolute () const
 Return true if the given path is absolute. More...
 
const stringgetBaseName () const
 
FilePath getParentPath () const
 
string getExtension () const
 Return the file extension of the given path. More...
 
void addExtension (const string &ext)
 Add a file extension to the given path. More...
 
void removeExtension ()
 Remove the file extension, if any, from the given path. More...
 
FilePath operator/ (const FilePath &rhs) const
 
size_t size () const
 Return the number of strings in the path. More...
 
string operator[] (size_t index)
 Return the string at the given index. More...
 
const stringoperator[] (size_t index) const
 Return the const string at the given index. More...
 
FilePath getNormalized () const
 
File System Operations
bool exists () const
 Return true if the given path exists on the file system. More...
 
bool isDirectory () const
 Return true if the given path is a directory on the file system. More...
 
FilePathVec getFilesInDirectory (const string &extension) const
 Return a vector of all files in the given directory with the given extension. More...
 
FilePathVec getSubDirectories () const
 Return a vector of all directories at or beneath the given path. More...
 
void createDirectory () const
 Create a directory on the file system at the given path. More...
 
bool setCurrentPath ()
 Set the current working directory of the file system. More...
 

Static Public Member Functions

static FilePath getCurrentPath ()
 Return the current working directory of the file system. More...
 
static FilePath getModulePath ()
 Return the directory containing the executable module. More...
 

Detailed Description

A generic file path, supporting both syntactic and file system operations.

Definition at line 26 of file File.h.

Member Enumeration Documentation

Enumerator
FormatWindows 
FormatPosix 
FormatNative 

Definition at line 36 of file File.h.

Enumerator
TypeRelative 
TypeAbsolute 
TypeNetwork 

Definition at line 29 of file File.h.

Constructor & Destructor Documentation

FilePath::FilePath ( )
inline

Definition at line 48 of file File.h.

FilePath::~FilePath ( )
inline

Definition at line 52 of file File.h.

FilePath::FilePath ( const string str)
inline

Construct a path from a standard string.

Definition at line 68 of file File.h.

FilePath::FilePath ( const char *  str)
inline

Construct a path from a C-style string.

Definition at line 74 of file File.h.

Member Function Documentation

void FilePath::addExtension ( const string ext)
inline

Add a file extension to the given path.

Definition at line 135 of file File.h.

void FilePath::assign ( const string str)

Assign a path from a standard string.

string FilePath::asString ( Format  format = FormatNative) const

Return this path as a standard string with the given format.

void FilePath::createDirectory ( ) const

Create a directory on the file system at the given path.

bool FilePath::exists ( ) const

Return true if the given path exists on the file system.

const string& FilePath::getBaseName ( ) const
inline

Return the base name of the given path, with leading directory information removed.

Definition at line 105 of file File.h.

static FilePath FilePath::getCurrentPath ( )
static

Return the current working directory of the file system.

string FilePath::getExtension ( ) const
inline

Return the file extension of the given path.

Definition at line 127 of file File.h.

FilePathVec FilePath::getFilesInDirectory ( const string extension) const

Return a vector of all files in the given directory with the given extension.

static FilePath FilePath::getModulePath ( )
static

Return the directory containing the executable module.

FilePath FilePath::getNormalized ( ) const

Return a normalized version of the given path, collapsing current path and parent path references so that 'a/./b' and 'c/../d/../a/b' become 'a/b'.

FilePath FilePath::getParentPath ( ) const
inline

Return the parent directory of the given path, if any. If no parent directory is present, then the empty path is returned.

Definition at line 116 of file File.h.

FilePathVec FilePath::getSubDirectories ( ) const

Return a vector of all directories at or beneath the given path.

bool FilePath::isAbsolute ( ) const
inline

Return true if the given path is absolute.

Definition at line 98 of file File.h.

bool FilePath::isDirectory ( ) const

Return true if the given path is a directory on the file system.

bool FilePath::isEmpty ( ) const
inline

Return true if the given path is empty.

Definition at line 92 of file File.h.

FilePath::operator string ( ) const
inline

Convert a path to a standard string.

Definition at line 80 of file File.h.

bool FilePath::operator!= ( const FilePath rhs) const
inline

Definition at line 59 of file File.h.

FilePath FilePath::operator/ ( const FilePath rhs) const

Concatenate two paths with a directory separator, returning the combined path.

bool FilePath::operator== ( const FilePath rhs) const
inline

Definition at line 54 of file File.h.

string FilePath::operator[] ( size_t  index)
inline

Return the string at the given index.

Definition at line 165 of file File.h.

const string& FilePath::operator[] ( size_t  index) const
inline

Return the const string at the given index.

Definition at line 171 of file File.h.

void FilePath::removeExtension ( )
inline

Remove the file extension, if any, from the given path.

Definition at line 141 of file File.h.

bool FilePath::setCurrentPath ( )

Set the current working directory of the file system.

size_t FilePath::size ( void  ) const
inline

Return the number of strings in the path.

Definition at line 159 of file File.h.


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