The OpenD Programming Language

rootName

Returns the root directory of the specified path, or null if the path is not rooted.

  1. auto rootName(R path)
  2. auto rootName(C[] path)

Parameters

path R

A path name.

Return Value

Type: auto

A slice of path.

Examples

assert(rootName("") is null);
assert(rootName("foo") is null);
assert(rootName("/") == "/");
assert(rootName("/foo/bar") == "/");

version (Windows)
{
    assert(rootName("d:foo") is null);
    assert(rootName(`d:\foo`) == `d:\`);
    assert(rootName(`\\server\share\foo`) == `\\server\share`);
    assert(rootName(`\\server\share`) == `\\server\share`);
}

Meta