Support Forum       G3D Web Page     
Static Public Member Functions | List of all members
G3D::FilePath Class Reference

Parsing of file system paths. More...

Static Public Member Functions

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

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

◆ base()

static String G3D::FilePath::base ( const String path)
static

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

'

◆ baseExt()

static String G3D::FilePath::baseExt ( const String path)
static

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

◆ canonicalize()

static String G3D::FilePath::canonicalize ( String  x)
static

Convert all slashes to '/'.

◆ concat()

static String G3D::FilePath::concat ( const String a,
const String b 
)
static

Appends file onto dirname, ensuring a / if needed.

◆ containsWildcards()

static bool G3D::FilePath::containsWildcards ( const String p)
static

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

◆ expandEnvironmentVariables()

static String G3D::FilePath::expandEnvironmentVariables ( const String path)
static

Replaces $VAR and patterns with the corresponding environment variable.

Throws String if the environment variable is not defined.

◆ ext()

static String G3D::FilePath::ext ( const String path)
static

Returns everything to the right of the last '.

'

◆ isLegalFilename()

static bool G3D::FilePath::isLegalFilename ( const String f,
size_t  maxLength = 100000 
)
static

Performs same check as makeLegalFilename but returns true is legal false if not legal.

◆ isRoot()

static bool G3D::FilePath::isRoot ( const 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.

◆ makeLegalFilename()

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

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

◆ mangle()

static String G3D::FilePath::mangle ( const String filename)
static

Converts filename into a legal filename by escaping potentially dangerous characters to have in a filename.

◆ matches()

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

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

◆ parent()

static String G3D::FilePath::parent ( const String path)
static

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

◆ parse()

static void G3D::FilePath::parse ( const String filename,
String drive,
Array< String > &  path,
String base,
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"

◆ removeTrailingSlash()

static String G3D::FilePath::removeTrailingSlash ( const String f)
static

Removes the trailing slash unless f is a filesystem root.

◆ unMangle()

static String G3D::FilePath::unMangle ( const String mangledFilename)
static

unmangles filenames


documentation generated on Wed Nov 24 2021 08:01:55 using doxygen 1.8.15