absolutePath

fnstring absolutePath(return scope const string path, lazy string base = getcwd()) @safe pure

Transforms path into an absolute path.

The following algorithm is used:

  1. If path is empty, return null.
  2. If path is already absolute, return it.
  3. Otherwise, append path to base and return

    the result. If base is not specified, the current working directory is used.

The function allocates memory if and only if it gets to the third stage of this algorithm.

Note that absolutePath will not normalize `..` segments. Use buildNormalizedPath(absolutePath(path)) if that is desired.

Parameters

paththe relative path to transform
basethe 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