vibe.d beta banner
get vibe.d
0.8.6

Asynchronous I/O that doesn’t get in your way, written in D

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

NameDescription
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

NameTypeDescription
absolute[get] boolDetermines if the path is absolute.
bySegment[get] immutable(PathEntry)[]Forward compatibility property for vibe-code
empty[get] boolTrue if the path contains no entries
endsWithSlash[get, set] boolDetermines if the path ends with a slash (i.e. is a directory)
external[get] boolDetermines 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] ulongThe 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] PathThe parent path

Methods

NameDescription
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.

Aliases

NameDescription
Segment Forward compatibility alias for vibe-core
Authors

Sönke Ludwig

Copyright

© 2012-2015 RejectedSoftware e.K.

License

Subject to the terms of the MIT license, as written in the included LICENSE.txt file.