new instance of Path that represents current path converted to absolute path. Also, this method will automatically do tilde expansion and normalization of path.
Exception if the specified base directory is not absolute.
import dshould; version(Posix) { auto cdir = std.file.getcwd; scope(exit) std.file.chdir(cdir); // Change current working directory to /tmp" std.file.chdir("/tmp"); version(OSX) { // On OSX /tmp is symlink to /private/tmp Path("/tmp").realPath.should.equal(Path("/private/tmp")); Path("foo/moo").toAbsolute.toString.should.equal( "/private/tmp/foo/moo"); Path("../my-path").toAbsolute.toString.should.equal("/private/my-path"); } else { Path("foo/moo").toAbsolute.toString.should.equal("/tmp/foo/moo"); Path("../my-path").toAbsolute.toString.should.equal("/my-path"); } Path("/a/path").toAbsolute.toString.should.equal("/a/path"); string home_path = "~".expandTilde; home_path[0].should.equal('/'); Path("~/my/path").toAbsolute.toString.should.equal("%s/my/path".format(home_path)); }
Convert path to absolute path.