The OpenD Programming Language

chdir

Change directory to pathname. Equivalent to cd on Windows and POSIX.

Parameters

pathname R

the directory to step into

Throws

FileException on error.

Examples

import std.algorithm.comparison : equal;
import std.algorithm.sorting : sort;
import std.array : array;
import std.path : buildPath;

auto cwd = getcwd;
auto dir = deleteme ~ "dir";
dir.mkdir;
scope(exit) cwd.chdir, dir.rmdirRecurse;

dir.buildPath("a").write(".");
dir.chdir; // step into dir
"b".write(".");
assert(dirEntries(".", SpanMode.shallow).array.sort.equal(
    [".".buildPath("a"), ".".buildPath("b")]
));

Meta