Path.current

Return current path (as absolute path)

struct Path
@safe static
current
()

Examples

import dshould;
Path root = createTempPath();
scope(exit) root.remove();

// Save current directory
auto cdir = std.file.getcwd;
scope(exit) std.file.chdir(cdir);

// Create directory structure
root.join("dir1", "dir2", "dir3").mkdir(true);
root.join("dir1", "dir2", "dir3").chdir;

// Check that current path is equal to dir1/dir2/dir3 (current dir)
version(OSX) {
    // On OSX we have to resolve symbolic links,
    // because result of createTempPath contains symmbolic links
    // for some reason, but current returns path with symlinks resolved
    Path.current.toString.should.equal(
            root.join("dir1", "dir2", "dir3").realPath.toString);
} else {
    Path.current.toString.should.equal(
            root.join("dir1", "dir2", "dir3").toString);
}

Meta