relative path inside this, to change directory to
import dshould; auto cdir = std.file.getcwd; Path root = createTempPath(); scope(exit) { std.file.chdir(cdir); root.remove(); } std.file.getcwd.should.not.equal(root._path); root.chdir; std.file.getcwd.should.equal(root._path); version(Posix) { // Prepare test dir in user's home directory Path home_tmp = createTempPath("~", "tmp-d-test"); scope(exit) home_tmp.remove(); string tmp_dir_name = home_tmp.baseName; std.file.getcwd.should.not.equal(home_tmp._path); // Change current working directory to tmp-dir-name Path("~", tmp_dir_name).chdir; std.file.getcwd.should.equal(home_tmp._path); }
import dshould; auto cdir = std.file.getcwd; Path root = createTempPath(); scope(exit) { std.file.chdir(cdir); root.remove(); } // Create some directories root.join("my-dir", "some-dir", "some-sub-dir").mkdir(true); root.join("my-dir", "other-dir").mkdir(true); // Check current path is not equal to root Path.current.should.not.equal(root); // Change current working directory to test root, and check that it // was changed root.chdir; Path.current.should.equal(root); // Try to change current working directory to "my-dir" inside our // test root dir root.chdir("my-dir"); Path.current.should.equal(root.join("my-dir")); // Try to change current dir to some-sub-dir, and check if it works root.chdir(Path("my-dir", "some-dir", "some-sub-dir")); Path.current.should.equal( root.join("my-dir", "some-dir", "some-sub-dir"));
Change current working directory to path inside currect path