txt: ## chdir.md
  chdir
  
  Combined from primary sources listed below.
  
  # [In IO::Path](#___top "go to top of document")[§](#(IO::Path)_method_chdir "direct link")
  
  See primary documentation
  [in context](/type/IO/Path#method_chdir)
  for **method chdir**.
  
  ```raku
  multi method chdir(IO::Path:D: IO $path, |c)
  multi method chdir(IO::Path:D: Str() $path, :$d = True, :$r, :$w, :$x)
  ```
  
  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`](/type/Bool) named arguments; when set to `True`, they'll perform [`.d`](/routine/d), [`.r`](/routine/r), [`.w`](/routine/w), and [`.x`](/routine/x) tests respectively. By default, only `:d` is set to `True`.
  
  # [In Independent routines](#___top "go to top of document")[§](#(Independent_routines)_sub_chdir "direct link")
  
  See primary documentation
  [in context](/type/independent-routines#sub_chdir)
  for **sub chdir**.
  
  ```raku
  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`](/routine/&*chdir)).
  
  Returns [`IO::Path`](/type/IO/Path) representing new `$*CWD` on success. On failure, returns [`Failure`](/type/Failure) and leaves `$*CWD` untouched. The `$path` can be any object with an IO method that returns an [`IO::Path`](/type/IO/Path) object. The available file tests are:
  
  * `:d` — check [`.d`](/routine/d) returns `True`
  * `:r` — check [`.r`](/routine/r) returns `True`
  * `:w` — check [`.w`](/routine/w) returns `True`
  * `:x` — check [`.x`](/routine/x) returns `True`
  
  By default, only `:d` test is performed.
  
  ```raku
  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:
  
  ```raku
  # WRONG! DO NOT DO THIS!
  my $*CWD = chdir '/tmp/';
  
  ```
  
  Use [`indir`](/routine/indir) instead.
  