Support Forum       Library Source       SourceForge Page       G3D Web Page     
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Static Public Member Functions | List of all members
G3D::FilePath Class Reference

Parsing of file system paths. More...

Static Public Member Functions

static std::string base (const std::string &path)
 Returns everything between the right-most slash and the following '.
 
static std::string baseExt (const std::string &path)
 Returns everything to the right of the last slash (or, on Windows, the last ':')
 
static std::string canonicalize (std::string x)
 Convert all slashes to '/'.
 
static std::string concat (const std::string &a, const std::string &b)
 Appends file onto dirname, ensuring a / if needed.
 
static bool containsWildcards (const std::string &p)
 Returns true if '*' or '?' appear in the filename.
 
static std::string expandEnvironmentVariables (const std::string &path)
 Replaces $VAR and patterns with the corresponding environment variable.
 
static std::string ext (const std::string &path)
 Returns everything to the right of the last '.
 
static bool isRoot (const std::string &f)
 Returns true if f specifies a path that parses as root of the filesystem.
 
static std::string makeLegalFilename (const std::string &f, size_t maxLength=100000)
 Replaces characters that are illegal in a filename with legal equivalents.
 
static bool matches (const std::string &path, const std::string &pattern, bool caseSensitive=true)
 Returns true if path matches pattern, with standard filesystem wildcards.
 
static std::string parent (const std::string &path)
 Returns everything to the left of the right-most slash.
 
static void parse (const std::string &filename, std::string &drive, Array< std::string > &path, std::string &base, std::string &ext)
 Parses a filename into four useful pieces.
 
static std::string removeTrailingSlash (const std::string &f)
 Removes the trailing slash unless f is a filesystem root.
 

Detailed Description

Parsing of file system paths.

None of these routines touch the disk–they are purely string manipulation.

In "/a/b/base.ext",

Member Function Documentation

static std::string G3D::FilePath::base ( const std::string path)
static

Returns everything between the right-most slash and the following '.

'

static std::string G3D::FilePath::baseExt ( const std::string path)
static

Returns everything to the right of the last slash (or, on Windows, the last ':')

static std::string G3D::FilePath::canonicalize ( std::string  x)
static

Convert all slashes to '/'.

static std::string G3D::FilePath::concat ( const std::string a,
const std::string b 
)
static

Appends file onto dirname, ensuring a / if needed.

static bool G3D::FilePath::containsWildcards ( const std::string p)
static

Returns true if '*' or '?' appear in the filename.

static std::string G3D::FilePath::expandEnvironmentVariables ( const std::string path)
static

Replaces $VAR and patterns with the corresponding environment variable.

Throws std::string if the environment variable is not defined.

static std::string G3D::FilePath::ext ( const std::string path)
static

Returns everything to the right of the last '.

'

static bool G3D::FilePath::isRoot ( const std::string f)
static

Returns true if f specifies a path that parses as root of the filesystem.

On OS X and other Unix-based operating systems, "/" is the only root. On Windows, drive letters and shares are roots, e.g., "c:\", "\\foo\". Does not check on Windows to see if the root is actually mounted or a legal drive letter–this is a purely string based test.

static std::string G3D::FilePath::makeLegalFilename ( const std::string f,
size_t  maxLength = 100000 
)
static

Replaces characters that are illegal in a filename with legal equivalents.

static bool G3D::FilePath::matches ( const std::string path,
const std::string pattern,
bool  caseSensitive = true 
)
static

Returns true if path matches pattern, with standard filesystem wildcards.

static std::string G3D::FilePath::parent ( const std::string path)
static

Returns everything to the left of the right-most slash.

static void G3D::FilePath::parse ( const std::string filename,
std::string drive,
Array< std::string > &  path,
std::string base,
std::string ext 
)
static

Parses a filename into four useful pieces.

Examples:

c:\a\b\d.e root = "c:\\" path = "a" "b" base = "d" ext = "e"

/a/b/d.e root = "/" path = "a" "b" base = "d" ext = "e"

/a/b root = "/" path = "a" base = "b" ext = "e"

static std::string G3D::FilePath::removeTrailingSlash ( const std::string f)
static

Removes the trailing slash unless f is a filesystem root.


documentation generated on Sat Jan 12 2013 22:49:54 using doxygen 1.8.2