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)
Path.current.toString.should.equal(root.join("dir1", "dir2", "dir3").toString);

Meta