new Path that is relative to base but represent same location as this path.
PathException if base path is not valid or not absolute
import dshould; Path("foo").relativeTo(std.file.getcwd).toString().should.equal("foo"); version(Posix) { auto path1 = Path("/foo/root/child/subchild"); auto root1 = Path("/foo/root"); auto root2 = Path("/moo/root"); auto rpath1 = path1.relativeTo(root1); rpath1.toString.should.equal("child/subchild"); root2.join(rpath1).toString.should.equal("/moo/root/child/subchild"); path1.relativeTo(root2).toString.should.equal("../../foo/root/child/subchild"); // Base path must be absolute, so this should throw error Path("~/my/path/1").relativeTo("~/my").should.throwA!PathException; }
Return this path as relative to base