Struct Path
Represents an absolute or relative file system path.
struct Path
;
This struct allows to do safe operations on paths, such as concatenation and sub paths. Checks are done to disallow invalid operations such as concatenating two absolute paths. It also validates path strings and allows for easy checking of malicious relative paths.
Constructors
Name | Description |
---|---|
this
(pathstr)
|
Constructs a Path object by parsing a path string. |
this
(nodes, absolute)
|
Constructs a path object from a list of PathEntry objects. |
this
(entry)
|
Constructs a relative path with one path entry. |
Properties
Name | Type | Description |
---|---|---|
absolute [get]
|
bool | Determines if the path is absolute. |
empty [get]
|
bool | True if the path contains no entries |
endsWithSlash [get, set]
|
bool | Determines if the path ends with a slash (i.e. is a directory) |
external [get]
|
bool | Determines if this path goes outside of its base path (i.e. begins with '..'). |
head [get]
|
immutable(PathEntry) | The last entry of the path |
length [get]
|
ulong | The number of path entries of which this path is composed |
nodes [get]
|
immutable(PathEntry)[] | The ist of path entries of which this path is composed |
parentPath [get]
|
Path | The parent path |
Methods
Name | Description |
---|---|
normalize
()
|
Resolves all '.' and '..' path entries as far as possible. |
opBinary
(rhs)
|
|
opBinary
(rhs)
|
|
opBinary
(rhs)
|
|
opCmp
(rhs)
|
|
opDollar
()
|
|
opEquals
(rhs)
|
Tests two paths for equality using '=='. |
opIndex
(idx)
|
|
opOpAssign
(rhs)
|
|
opOpAssign
(rhs)
|
|
opOpAssign
(rhs)
|
|
opOpAssign
(rhs)
|
|
opSlice
(start, end)
|
|
startsWith
(rhs)
|
Tests if rhs is an anchestor or the same as this path.
|
toHash
()
|
|
toNativeString
()
|
Converts the Path object to a native path string (backslash as path separator on Windows). |
toString
()
|
Converts the Path back to a string representation using slashes. |