|
Evo C++ Library v0.5.1
|
#include <evo/filepath.h>
File and directory path helpers.
Static Public Member Functions | |
| static bool | abs (const SubString &path, bool strict=true) |
| Check whether path is an absolute path. More... | |
| static SubString | dirpath (const SubString &path) |
| Get directory path from path. More... | |
| static SubString | drive (const SubString &path) |
| Get Windows drive from path. More... | |
| static SubString | filename (const SubString &path) |
| Get filename from path. More... | |
| static SubString | filename_base (const SubString &path) |
| Get base filename from path, which is the filename without the extension. More... | |
| static SubString | filename_ext (const SubString &path) |
| Get file extension from filename in path. More... | |
| static bool | hasdrive (const SubString &path) |
| Check whether given path has a drive component. More... | |
| static String & | join (String &basepath, const SubString &addpath) |
| Join two paths together. More... | |
| static String & | join_all (String &out, const SubString &drive, const SubString &dirpath, const SubString &filename) |
| Join drive, dirpath, and filename components and write to output string. More... | |
| static String & | join_all (String &out, const SubString &drive, const SubString &dirpath, const SubString &basename, const SubString &ext) |
| Join drive, dirpath, and filename components and write to output string. More... | |
| static String & | join_dirpath (String &out, const SubString &dirpath, const SubString &filename) |
| Join dirpath and filename and write to output string. More... | |
| static String & | join_drive (String &out, const SubString &drive, const SubString &dirpath) |
| Join drive and dirpath and write to output string. More... | |
| static String & | join_filename (String &out, const SubString &basename, const SubString &ext) |
| Join file base name and extension components and write to output string. More... | |
| template<class T > | |
| static String & | join_list (String &out, const T &list) |
| Join list of path components. More... | |
| static String & | normalize (String &outpath, const SubString &path) |
| Normalize path and remove redundant components. More... | |
| static String & | normalize_case (String &outpath, const SubString &path) |
| Normalize path case. More... | |
| static void | split_all (SubString &drive, SubString &dirpath, SubString &filename, const SubString &path) |
| Split input path into drive, dirpath, and filename components. More... | |
| static void | split_all (SubString &drive, SubString &dirpath, SubString &basename, SubString &ext, const SubString &path) |
| Split input path into drive, dirpath, file basename, and file extension components. More... | |
| static SubString | split_dirpath (SubString &outfilename, const SubString &path) |
| Get directory path from path. More... | |
| static SubString | split_drive (SubString &outpath, const SubString &path) |
| Get Windows drive and remaining path from path. More... | |
| static SubString | split_filename (SubString &ext, const SubString &filename) |
| Split filename into base name and extension. More... | |
| template<class T > | |
| static T & | split_list (T &list, const SubString &path) |
| Split path into list of components. More... | |
| static bool | validate (const SubString &path, bool strict=true) |
| Validate whether path is valid. More... | |
| static bool | validate_filename (const SubString &filename, bool strict=true) |
| Validate whether filename is valid. More... | |
Static Public Attributes | |
| static const char | PATH_DELIM = PATH_DELIM_POSIX |
| Path delimiter char for current OS. More... | |
| static const char | PATH_DELIM_POSIX = '/' |
| Path delimiter char for Linux/Unix systems. More... | |
| static const char | PATH_DELIM_WIN32 = '\\' |
| Path delimiter char for Windows systems. More... | |
|
inlinestatic |
Check whether path is an absolute path.
strict=false)c:foo\bar) is relative to the current dir on that drive so is not absolute, unless strict=false| path | Path to check |
| strict | Whether to use strict mode (only used in Windows): false to consider a relative path with a drive as an absolute path (ex: c:foo) |
Get directory path from path.
/C:\ or \| path | Path to extract directory path from |
path, null Get Windows drive from path.
path, if specifiedpath contains a drive (drive letter and colon) then the drive letter and colon are included with the resultpath is a network share (UNC) path then host and share name (everything up to, but not including, the fourth backslash) are all considered the "drive"//) or backslashes (\\), but not a mixture of bothc:\foo the drive is c:c:foo the drive is c:\\host\share\foo the drive is \\host\share\foo or foo the drive is null| path | Path to extract drive from |
Get filename from path.
path ends with a PATH_DELIM (or colon in Windows) then the returned filename will be empty| path | Path to extract filename from |
path, same as path if no path delimiter found Get base filename from path, which is the filename without the extension.
path, then splits on the last '.' to get the base filenamepath ends with a PATH_DELIM (or colon in Windows) then the filename is empty and the base filename will also be empty| path | Path or filename to extract base filename from |
path, null if path is null Get file extension from filename in path.
path, then splits on the last '.' to get the file extensionpath ends with a PATH_DELIM (or colon in Windows) then the filename is empty and the extension will be null| path | Path or filename to extract file extension from |
path, null if no extension found, empty if filename ends with a '.'
|
inlinestatic |
Check whether given path has a drive component.
| path | Path to check |
path has a drive Join two paths together.
addpath to path, but if addpath is an absolute path then it places the current pathaddpath has a drive letter then it replaces path, even if not absolutec:foo is relative to current dir on drive C: while c:\foo is an absolute path – either one replaces path| basepath | Starting path to join to |
| addpath | Additional path to join, appended to path if relative, replaces path if absolute (Windows: or if includes driver letter) |
path
|
inlinestatic |
Join drive, dirpath, and filename components and write to output string.
| out | Output string to write to (appended) [in/out] |
| drive | Drive to join |
| dirpath | Directory path to join |
| filename | Filename to join |
out
|
inlinestatic |
Join drive, dirpath, and filename components and write to output string.
| out | Output string to write to (appended) [in/out] |
| drive | Drive to join |
| dirpath | Directory path to join |
| basename | File base name to join |
| ext | File extension to join |
out
|
inlinestatic |
Join dirpath and filename and write to output string.
| out | Output string to write to (appended) [in/out] |
| dirpath | Directory path to join |
| filename | Filename to join |
out
|
inlinestatic |
Join drive and dirpath and write to output string.
| out | Output string to write to (appended) [in/out] |
| drive | Drive to join |
| dirpath | Directory path to join |
out
|
inlinestatic |
Join file base name and extension components and write to output string.
| out | Output string to write to (appended) [in/out] |
| basename | File base name to join |
| ext | File extension to join |
out Join list of path components.
| out | Output string to write to (appended) [in/out] |
| list | List of path components |
out Normalize path and remove redundant components.
| outpath | Replaced with the resulting output path [out] |
| path | Input path to normalize – ok if this is the object same as outpath |
outpath Normalize path case.
| outpath | Replaced with the resulting output path [out] |
| path | Input path to normalize case – ok if this is the object same as outpath |
outpath
|
inlinestatic |
Split input path into drive, dirpath, and filename components.
| drive | Stores drive from input path, without the rest of the path |
| dirpath | Stores directory path from input path, without drive or filename |
| filename | Stores filename from path, without directory path |
| path | Input path to split |
|
inlinestatic |
Split input path into drive, dirpath, file basename, and file extension components.
| drive | Stores drive from input path, without the rest of the path |
| dirpath | Stores directory path from input path, without drive or filename |
| basename | Stores file base name from filename in path, without file extension or path |
| ext | Stores file extension from filename in path, without base name or path |
| path | Input path to split |
Get directory path from path.
/C:\ or \| outfilename | Stores filename from path, empty if no filename, null if path is null |
| path | Path to extract directory path from |
path, null if path is null Get Windows drive and remaining path from path.
outpathoutpath will be the same as the input path| outpath | Stores remaining path after drive – always same as path if not Windows [out] |
| path | Path to extract drive |
Split filename into base name and extension.
filename is not a path, call filename() to get filename from path| ext | Stores file extension, set to null if no extension [out] |
| filename | Input filename to split |
|
inlinestatic |
Split path into list of components.
strict=false to check if it's an absolute path| list | Stores path components (cleared first), set to null if path is null |
| path | Path to split |
list
|
inlinestatic |
Validate whether path is valid.
<>:"/|?*: is valid after the drive letter (for absolute path), but otherwise invalid"." or ".."| path | Path to validate |
| strict | Whether to enable additional checks for strict mode |
|
inlinestatic |
Validate whether filename is valid.
<>:"/|?*"." or ".."| filename | Filename to validate |
| strict | Whether to enable additional checks for strict mode |
|
static |
Path delimiter char for current OS.
|
static |
Path delimiter char for Linux/Unix systems.
|
static |
Path delimiter char for Windows systems.
1.8.13