See Original text in context
sub chdir(IO() , : = True, :, :, : --> IO::Path)
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:
:d
— check .d
returns True
:r
— check .r
returns True
:w
— check .w
returns True
:x
— check .x
returns True
By default, only :d
test is performed.
chdir '/tmp'; # change $*CWD to '/tmp' and check its .d is Truechdir :r, :w, '/tmp'; # … check its .r and .w are Truechdir '/not-there'; # returns Failure
Note that the following construct is a mistake:
# WRONG! DO NOT DO THIS!my = chdir '/tmp/';
Use indir
instead.
See Original text in context
multi method chdir(IO::Path: IO , |c)multi method chdir(IO::Path: Str() , : = True, :, :, :)
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
.