class
Path
Class for storing and manipulating file paths.
Paths may be parsed from and to raw strings according to various platform specific path types.
Public
Constructors
Path
Path
Constructs a path by parsing the provided path string.
Throws exception if provided path is not valid.
- pathStr
- String containing the path. Ideally this should be an UTF-8 encoded string in order to support non-ANSI characters in the path.
- type
- If set to default path will be parsed according to the rules of the platform the application is being compiled to. Otherwise it will be parsed according to provided type.
Path
Constructs a path by parsing the provided path null terminated string.
Throws exception if provided path is not valid.
- pathStr
- Null-terminated string containing the path. Ideally this should be an UTF-8 encoded string in order to support non-ANSI characters in the path.
- type
- If set to default path will be parsed according to the rules of the platform the application is being compiled to. Otherwise it will be parsed according to provided type.
Path
Methods
Assign
Constructs a path by parsing the provided path string.
Throws exception if provided path is not valid.
- pathStr
- String containing the path.
- type
- If set to default path will be parsed according to the rules of the platform the application is being compiled to. Otherwise it will be parsed according to provided type.
Assign
Constructs a path by parsing the provided path null terminated string.
Throws exception if provided path is not valid.
- pathStr
- Null-terminated string containing the path.
- type
- If set to default path will be parsed according to the rules of the platform the application is being compiled to. Otherwise it will be parsed according to provided type.
ToString
Converts the path in a string according to platform path rules.
- type
- If set to default path will be parsed according to the rules of the platform the application is being compiled to. Otherwise it will be parsed according to provided type.
Returns: String representing the path using the UTF8 string encoding.
ToPlatformString
IsDirectory
Checks is the path a directory (contains no file-name).
IsFile
Checks does the path point to a file.
IsAbsolute
Checks is the contained path absolute.
GetParent
Returns parent path.
If current path points to a file the parent path will be the folder where the file is located. Or if it contains a directory the parent will be the parent directory. If no parent exists, same path will be returned.
GetAbsolute
Returns an absolute path by appending the current path to the provided base.
If path was already absolute no changes are made and copy of current path is returned. If base is not absolute, then the returned path will be made relative to base, but will not be absolute.
GetRelative
Returns a relative path by making the current path relative to the provided base.
Base must be a part of the current path. If base is not a part of the path no changes are made and a copy of the current path is returned.
GetDirectory
Returns the path as a path to directory.
If path was pointing to a file, the filename is removed, otherwise no changes are made and exact copy is returned.
MakeParent
Makes the path the parent of the current path.
If current path points to a file the parent path will be the folder where the file is located. Or if it contains a directory the parent will be the parent directory. If no parent exists, same path will be returned.
MakeAbsolute
Makes the current path absolute by appending it to base.
If path was already absolute no changes are made and copy of current path is returned. If base is not absolute, then the returned path will be made relative to base, but will not be absolute.
MakeRelative
Makes the current path relative to the provided base.
Base must be a part of the current path. If base is not a part of the path no changes are made and a copy of the current path is returned.
Includes
Checks if the current path contains the provided path.
Equals
Compares two paths and returns true if they match.
SetFilename
Change or set the filename in the path.
SetBasename
Change or set the base name in the path.
Base name changes the filename by changing its base to the provided value but keeping extension intact.
SetExtension
Change or set the extension of the filename in the path.
- extension
- Extension with a leading ".".
GetFilename
Returns a filename with extension.
GetFilename
Returns a filename in the path.
- extension
- If true, returned filename will contain an extension.
GetExtension
Returns file extension with the leading ".".
GetDirectoryCount
Gets the number of directories in the path.
GetDirectory
Gets a directory name with the specified index from the path.
GetDevice
Returns path device (for example drive, volume, etc.) if one exists in the path.
GetNode
Returns path node (for example network name) if one exists in the path.
GetTail
Gets last element in the path, filename if it exists, otherwise the last directory.
PopTail
Removes the last element in the path: filename if it exists, otherwise the last directory.
Returns the removed value.
GetSubPath
Returns the portion of the path containing the first directories.
PushDirectory
Add new directory to the end of the path.
PopDirectory
Removes the last directory from the end of the path.
Clear
Clears the path to nothing.
IsEmpty
Returns true if no path has been set.
staticComparePathElem
Compares two path elements (filenames, directory names, etc.).
staticCombine
Combines two paths and returns the result.
Right path should be relative.
staticCombine
Combines three paths and returns the result.
Right path should be relative.
staticStripInvalid
Strips invalid characters from the provided string and replaces them with empty spaces.
Operators
operator=
Assigns a path by parsing the provided path string.
Path will be parsed according to the rules of the platform the application is being compiled to.
operator=
Assigns a path by parsing the provided path null terminated string.
Path will be parsed according to the rules of the platform the application is being compiled to.
operator==
Compares two paths and returns true if they match.
Comparison is case insensitive and paths will be compared as-is, without canonization.
operator!=
Compares two paths and returns true if they don't match.
Comparison is case insensitive and paths will be compared as-is, without canonization.
operator[]
Gets a directory name with the specified index from the path.
Private
Methods
Assign
Constructs a path by parsing the provided raw string data.
Throws exception if provided path is not valid.
- pathStr
- String containing the path.
- characterCount
- Number of character in the provided path string.
- type
- If set to default path will be parsed according to the rules of the platform the application is being compiled to. Otherwise it will be parsed according to provided type.
SetNode
SetDevice
BuildWindows
Build a Windows path string from internal path data.
BuildUnix
Build a Unix path string from internal path data.
ReportInvalidPath
Logs a fatal error for an incorrectly formatted path.