Path

Represents an absolute or relative file system 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

this
this(string pathstr)

Constructs a Path object by parsing a path string.

this
this(immutable(PathEntry)[] nodes, bool absolute)

Constructs a path object from a list of PathEntry objects.

this
this(PathEntry entry)

Constructs a relative path with one path entry.

Members

Aliases

Segment
alias Segment = PathEntry

Forward compatibility alias for vibe-core

Functions

normalize
void normalize()

Resolves all '.' and '..' path entries as far as possible.

opBinary
Path opBinary(Path rhs)
Undocumented in source. Be warned that the author may not have intended to support it.
opBinary
Path opBinary(string rhs)
Undocumented in source. Be warned that the author may not have intended to support it.
opBinary
Path opBinary(PathEntry rhs)
Undocumented in source. Be warned that the author may not have intended to support it.
opCmp
int opCmp(Path rhs)
Undocumented in source. Be warned that the author may not have intended to support it.
opDollar
size_t opDollar()
Undocumented in source. Be warned that the author may not have intended to support it.
opEquals
bool opEquals(Path rhs)
bool opEquals(Path other)

Tests two paths for equality using '=='.

opIndex
immutable(PathEntry) opIndex(size_t idx)
Undocumented in source. Be warned that the author may not have intended to support it.
opOpAssign
void opOpAssign(string rhs)
Undocumented in source. Be warned that the author may not have intended to support it.
opOpAssign
void opOpAssign(PathEntry rhs)
Undocumented in source. Be warned that the author may not have intended to support it.
opOpAssign
void opOpAssign(immutable(PathEntry)[] rhs)
Undocumented in source. Be warned that the author may not have intended to support it.
opOpAssign
void opOpAssign(Path rhs)
Undocumented in source. Be warned that the author may not have intended to support it.
opSlice
Path opSlice(size_t start, size_t end)
Undocumented in source. Be warned that the author may not have intended to support it.
startsWith
bool startsWith(Path rhs)

Tests if rhs is an anchestor or the same as this path.

toHash
hash_t toHash()
Undocumented in source. Be warned that the author may not have intended to support it.
toNativeString
string toNativeString()

Converts the Path object to a native path string (backslash as path separator on Windows).

toString
string toString()

Converts the Path back to a string representation using slashes.

Properties

absolute
bool absolute [@property getter]

Determines if the path is absolute.

bySegment
immutable(PathEntry)[] bySegment [@property getter]

Forward compatibility property for vibe-code

empty
bool empty [@property getter]

True if the path contains no entries

endsWithSlash
bool endsWithSlash [@property getter]
bool endsWithSlash [@property setter]

Determines if the path ends with a slash (i.e. is a directory)

external
bool external [@property getter]

Determines if this path goes outside of its base path (i.e. begins with '..').

head
immutable(PathEntry) head [@property getter]

The last entry of the path

length
size_t length [@property getter]

The number of path entries of which this path is composed

nodes
immutable(PathEntry)[] nodes [@property getter]

The ist of path entries of which this path is composed

parentPath
Path parentPath [@property getter]

The parent path

Meta