absolutePath
fn
string absolutePath(return scope const string path, lazy string base = getcwd()) @safe pureTransforms path into an absolute path.
The following algorithm is used:
- If
pathis empty, returnnull. - If
pathis already absolute, return it. - Otherwise, append
pathtobaseand returnthe result. If
baseis not specified, the current working directory is used.
Note that absolutePath will not normalize `..` segments. Use buildNormalizedPath(absolutePath(path)) if that is desired.
Parameters
path | the relative path to transform |
base | the base directory of the relative path |
Returns
string of transformed path
Throws
Exception if the specified _base directory is not absolute.See Also
asAbsolutePath which does not allocate