Struct 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

Name Description
this Constructs a Path object by parsing a path string.
this Constructs a path object from a list of PathEntry objects.
this Constructs a relative path with one path entry.

Methods

Name Description
absolute Determines if the path is absolute.
normalize Resolves all '.' and '..' path entries as far as possible.
toString Converts the Path back to a string representation using slashes.
toNativeString Converts the Path object to a native path string (backslash as path separator on Windows).
startsWith Tests if `rhs` is an anchestor or the same as this path.
relativeTo Computes the relative path from `parentPath` to this path.
head The last entry of the path
parentPath The parent path
nodes The ist of path entries of which this path is composed
length The number of path entries of which this path is composed
empty True if the path contains no entries
endsWithSlash Determines if the path ends with a slash (i.e. is a directory)
external Determines if this path goes outside of its base path (i.e. begins with '..').
opIndex
opSlice
opDollar
opBinary
opBinary
opBinary
opOpAssign
opOpAssign
opOpAssign
opEquals Tests two paths for equality using '=='.
opCmp

Authors

Sönke Ludwig

Copyright

© 2012 RejectedSoftware e.K.

License

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