Path.parent

determine parent path of this path

struct Path
const
parent
()

Return Value

Type: Path

Absolute Path to parent directory.

Examples

import dshould;
version(Posix) {
    Path("/tmp").parent.toString.should.equal("/");
    Path("/").parent.toString.should.equal("/");
    Path("/tmp/parent/child").parent.toString.should.equal("/tmp/parent");

    Path("parent/child").parent.toString.should.equal(
        Path(std.file.getcwd).join("parent").toString);

    auto cdir = std.file.getcwd;
    scope(exit) std.file.chdir(cdir);

    std.file.chdir("/tmp");

    Path("parent/child").parent.toString.should.equal("/tmp/parent");

    Path("~/test-dir").parent.toString.should.equal(
        "~".expandTilde);
}

Meta