Documentation for routine chdir

Documentation for routine chdir, assembled from the following types:

role IO

From IO

(IO) sub chdir

Defined as:

sub chdir(IO() $path:$d = True:$r:$w:$x --> IO::Path:D)

Changes value of $*CWD variable to the provided $path, optionally ensuring the new path passes several file tests. NOTE: that this routine does NOT alter the process's current directory (see &*chdir).

Returns IO::Path representing new $*CWD on success. On failure, returns Failure and leaves $*CWD untouched. The $path can be any object with an IO method that returns an IO::Path object. The available file tests are:

By default, only :d test is performed.

    chdir         '/tmp'# change $*CWD to '/tmp' and check its .d is True 
    chdir :r:w'/tmp'# … check its .r and .w are True 
    chdir '/not-there';   # returns Failure 

Note that the following construct is a mistake:

    # WRONG! DO NOT DO THIS! 
    my $*CWD = chdir '/tmp/';

Use indir instead.

class IO::Path

From IO::Path

(IO::Path) method chdir

Defined as:

multi method chdir(IO::Path:D: Str() $path:$d = True:$r:$w:$x)

DEPRECATION NOTICE: this method will be deprecated in 6.d language. Do not use it for new code. Instead, create a new path or use add method. For altering current working directory see &chdir and &*chdir subroutines.

Contrary to the name, the .chdir method does not change any directories, but merely concatenates the given $path to the invocant and returns the resultant IO::Path. Optional file tests can be performed by providing :d, :r, :w, or :x Bool named arguments; when set to True, they'll perform .d, .r, .w, and .x tests respectively. By default, only :d is set to True.