asAbsolutePath

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 the current working directory, which allocates memory.
asAbsolutePath
(
R
)
()
if (
(
isRandomAccessRange!R &&
isSomeChar!(ElementType!R)
||
)
&&
)

Parameters

path R

the relative path to transform

Return Value

Type: auto

the transformed path as a lazy range

Examples

import std.array;
assert(asAbsolutePath(cast(string) null).array == "");
version (Posix)
{
    assert(asAbsolutePath("/foo").array == "/foo");
}
version (Windows)
{
    assert(asAbsolutePath("c:/foo").array == "c:/foo");
}
asAbsolutePath("foo");

See Also

absolutePath which returns an allocated string

Meta