# class IO::Path::Cygwin

## method raku

Defined as:

Returns a string that, when given passed through EVAL gives the original invocant back.

## (IO::Path) method ACCEPTS

Defined as:

Coerces the argument to IO::Path, if necessary. Returns True if .absolute method on both paths returns the same string. NOTE: it's possible for two paths that superficially point to the same resource to NOT smartmatch as True, if they were constructed differently and were never fully resolved:

The reason is the two paths above may point to different resources when fully resolved (e.g. if foo is a symlink). Resolve the paths before smartmatching to check they point to same resource:

## (IO::Path) method basename

Defined as:

Returns the basename part of the path object, which is the name of the filesystem object itself that is referenced by the path.

Note that in IO::Spec::Win32 semantics, the basename of a Windows share is \, not the name of the share itself:

Defined as:

Concatenates a path fragment to the invocant and returns the resultant IO::Path. If adding ../ to paths that end with a file, you may need to call resolve for the resultant path to be accessible by other IO::Path methods like dir or open. See also sibling and parent.

## (IO::Path) method child

Defined as:

Alias for .add.

## (IO::Path) method cleanup

Defined as:

Returns a new path that is a canonical representation of the invocant path, cleaning up any extraneous path parts:

Note that no filesystem access is made. See also resolve.

## (IO::Path) method comb

Defined as:

Opens the file and processes its contents the same way Str.comb does, taking the same arguments. Implementations may slurp the file in its entirety when this method is called.

## (IO::Path) method split

Defined as:

Opens the file and processes its contents the same way Str.split does, taking the same arguments. Implementations may slurp the file in its entirety when this method is called.

## (IO::Path) method extension

Defined as:

Returns the extension consisting of $parts parts (defaults to 1), where a "part" is defined as a dot followed by possibly-empty string up to the end of the string, or previous part. That is "foo.tar.gz" has an extension of two parts: first part is "gz" and second part is "tar" and calling "foo.tar.gz".IO.extension: :2parts gives "tar.gz". If an extension with the specified number of $parts is not found, returns an empty string.

$parts can be a Range, specifying the minimum number of parts and maximum number of parts the extension should have. The routine will attempt to much the most parts it can. If $parts range's endpoints that are smaller than 0 they'll be treated as 0; implementations may treat endpoints larger than 2⁶³-1 as 2⁶³-1. Ranges with NaN or Str endpoints will cause an exception to be thrown.

## (IO::Path) method gist

Defined as:

Returns a string, part of which contains either the value of .absolute (if path is absolute) or .path. Note that no escaping of special characters is made, so e.g. "\b" means a path contains a backslash and letter "b", not a backspace.

Defined as:

## (IO::Path) method relative

Defined as:

Returns a new Str object with the path relative to the $base. If $base is not provided, $*CWD is used in its place. If the invocant is not an absolute path, it's first made to be absolute using the .CWD attribute the object was created with, and then is made relative to $base.

## (IO::Path) method parent

Defined as:

Returns the parent path of the invocant. Note that no actual filesystem access is made, so the returned parent is physical and not the logical parent of symlinked directories.

If $level is specified, the call is equivalent to calling .parent() $level times:

## (IO::Path) method resolve

Defined as:

Returns a new IO::Path object with all symbolic links and references to the parent directory (..) resolved. This means that the filesystem is examined for each directory in the path, and any symlinks found are followed.

If :$completely, which defaults to False, is set to a true value, the method will fail with X::IO::Resolve if it cannot completely resolve the path, otherwise, it will resolve as much as possible, and will merely perform cleanup of the rest of the path. The last part of the path does NOT have to exist to :$completely resolve the path.

NOTE: Currently (April 2017) this method doesn't work correctly on all platforms, e.g. Windows, since resolve assumes POSIX semantics.

## (IO::Path) routine dir

Defined as:

Returns the contents of a directory as a lazy list of IO::Path objects representing relative paths, filtered by smartmatching their names (as strings) against the :test parameter. The path of returned files will be absolute or relative depending on what $path is. Since the tests are performed against Str arguments, not IO, the tests are executed in the $*CWD, instead of the target directory. When testing against file test operators, this won't work:

while this will:

NOTE: a dir call opens a directory for reading, which counts towards maximum per-process open files for your program. Be sure to exhaust returned Seq before doing something like recursively performing more dir calls. You can exhaust it by assigning to a @-sigiled variable or simply looping over it. Note how examples below push further dirs to look through into an Array, rather than immediately calling dir on them. See also IO::Dir module that gives you finer control over closing dir handles.

Examples:

An example program that lists all files and directories recursively:

A lazy way to find the first three files ending in ".p6" recursively starting from the current directory:

## (IO::Path) method e

Defined as:

Returns True if the invocant is a path that exists.

## (IO::Path) method d

Defined as:

Returns True if the invocant is a path that exists and is a directory. The method will fail with X::IO::DoesNotExist if the path points to a non-existent filesystem entity.

## (IO::Path) method f

Defined as:

Returns True if the invocant is a path that exists and is a file. The method will fail with X::IO::DoesNotExist if the path points to a non-existent filesystem entity.

## (IO::Path) method s

Defined as:

Returns the file size in bytes. May be called on paths that are directories, in which case the reported size is dependent on the operating system. The method will fail with X::IO::DoesNotExist if the path points to a non-existent filesystem entity.

## (IO::Path) method l

Defined as:

Returns True if the invocant is a path that exists and is a symlink. The method will fail with X::IO::DoesNotExist if the path points to a non-existent filesystem entity.

## (IO::Path) method r

Defined as:

Returns True if the invocant is a path that exists and is accessible. The method will fail with X::IO::DoesNotExist if the path points to a non-existent filesystem entity.

## (IO::Path) method w

Defined as:

Returns True if the invocant is a path that exists and is writable. The method will fail with X::IO::DoesNotExist if the path points to a non-existent filesystem entity.

## (IO::Path) method rw

Defined as:

Returns True if the invocant is a path that exists and is readable and writable. The method will fail with X::IO::DoesNotExist if the path points to a non-existent filesystem entity.

## (IO::Path) method x

Defined as:

Returns True if the invocant is a path that exists and is executable. The method will fail with X::IO::DoesNotExist if the path points to a non-existent filesystem entity.

NOTE: If the file is a script (an executable text file and not a native executable), and the file has only executable permissions and no read permissions, this method will return True but trying to execute will fail. That is a limitation of the operating system.

## (IO::Path) method rwx

Defined as:

Returns True if the invocant is a path that exists and is executable, readable, and writable. The method will fail with X::IO::DoesNotExist if the path points to a non-existent filesystem entity.

## (IO::Path) method z

Defined as:

Returns True if the invocant is a path that exists and has size of 0. May be called on paths that are directories, in which case the reported file size (and thus the result of this method) is dependent on the operating system. The method will fail with X::IO::DoesNotExist if the path points to a non-existent filesystem entity.

## (IO::Path) method sibling

Defined as:

Allows to reference a sibling file or directory. Returns a new IO::Path based on the invocant, with the .basename changed to $sibling. The $sibling is allowed to be a multi-part path fragment; see also .add.

## (IO::Path) method words

Defined as:

Opens the invocant and returns its words.

The behavior is equivalent to opening the file specified by the invocant, forwarding the :$chomp, :$enc, and :$nl-in arguments to IO::Handle.open, then calling IO::Handle.words on that handle, forwarding any of the remaining arguments to that method, and returning the resultant Seq. NOTE: words are lazily read. The handle used under the hood is not closed until the returned Seq is fully reified, and this could lead to leaking open filehandles. It is possible to avoid leaking open filehandles using the $limit argument to cut down the Seq of words to be generated.

## (IO::Path) method lines

Defined as:

Opens the invocant and returns its lines.

The behavior is equivalent to opening the file specified by the invocant, forwarding the :$chomp, :$enc, and :$nl-in arguments to IO::Handle.open, then calling IO::Handle.lines on that handle, forwarding any of the remaining arguments to that method, and returning the resultant Seq. NOTE: the lines are ready lazily and the handle used under the hood won't get closed until the returned Seq is fully reified, so ensure it is, or you'll be leaking open filehandles. (TIP: use the $limit argument)

Defined as:

Read all of the file's content and return it as either Buf, if :$bin is True, or if not, as Str decoded with :$enc encoding, which defaults to utf8. File will be closed afterwards. See &open for valid values for :$enc. ## (IO::Path) method spurt Defined as: Opens the path for writing, and writes all of the $data into it. File will be closed afterwards. Will fail if it cannot succeed for any reason. The $data can be any Cool type or any Blob type. Arguments are as follows: • :$enc — character encoding of the data. Takes same values as :$enc in IO::Handle.open. Defaults to utf8. Ignored if $data is a Blob.

• :$append — open the file in append mode, preserving existing contents, and appending data to the end of the file. • :$createonlyfail if the file already exists.

Defined as:

## (IO::Path) routine rmdir

Defined as:

Remove the invocant, or in sub form, all of the provided directories in the given list, which can contain any Cool object. Only works on empty directories.

Method form returns True on success and returns a Failure of type X::IO::Rmdir if the directory cannot be removed (e.g. the directory is not empty, or the path is not a directory). Subroutine form returns a list of directories that were successfully deleted.

To delete non-empty directory, see rmtree in File::Directory::Tree module.

Defined as:

Changes the POSIX permissions of a file or directory to $mode. Returns True on success; on failure, fails with X::IO::Chmod. The mode is expected as an integer following the standard numeric notation, and is best written as an octal number: Make sure you don't accidentally pass the intended octal digits as a decimal number (or string containing a decimal number): ## (IO::Path) routine rename Defined as: Renames a file or directory. Returns True on success; fails with X::IO::Rename if :$createonly is True and the $to path already exists or if the operation failed for some other reason. Note: some renames will always fail, such as when the new name is on a different storage device. See also: move. ## (IO::Path) routine copy Defined as: Copies a file. Returns True on success; fails with X::IO::Copy if :$createonly is True and the $to path already exists or if the operation failed for some other reason, such as when $to and $from are the same file. ## (IO::Path) routine move Defined as: Copies a file and then removes the original. If removal fails, it's possible to end up with two copies of the file. Returns True on success; fails with X::IO::Move if :$createonly is True and the $to path already exists or if the operation failed for some other reason, such as when $to and $from are the same file. To avoid copying, you can use rename, if the files are on the same storage device. It also works with directories, while move does not. ## (IO::Path) method Numeric Defined as: Coerces .basename to Numeric. Fails with X::Str::Numeric if base name is not numerical. ## (IO::Path) method Int Defined as: Coerces .basename to Int. Fails with X::Str::Numeric if base name is not numerical. Defined as: Create a new symbolic link $link to existing $target. Returns True on success; fails with X::IO::Symlink if the symbolic link could not be created. If $target does not exist, creates a dangling symbolic link.

symlink creates a symbolic link using an absolute path by default. To create a relative symlink set the absolute parameter to False e.g. :!absolute. This flag was introduced in Rakudo version 2020.11.

To create a hard link, see link.

Note: on Windows, creation of symbolic links may require escalated privileges.

Defined as:

Create a new hard link $link to existing $target. Returns True on success; fails with X::IO::Link if the hard link could not be created. To create a symbolic link, see symlink.

Defined as:

Delete all specified ordinary files, links, or symbolic links for which there are privileges to do so. See rmdir to delete directories.

The subroutine form returns the names of all the files in the list, excluding those for which the filesystem raised some error; since trying to delete a file that does not exist does not raise any error at that level, this list will include the names of the files in the list that do not exist.

The method form returns True on success, or fails with X::IO::Unlink if the operation could not be completed. If the file to be deleted does not exist, the routine treats it as success.

## (IO::Path) method IO

Defined as:

Returns the invocant.

## (IO::Path) method SPEC

Defined as:

Returns the IO::Spec object that was (implicitly) specified at object creation time.

## (IO::Path) method modified

Returns an Instant object indicating when the content of the file was last modified. Compare with changed.

## (IO::Path) method accessed

Return an Instant object representing the timestamp when the file was last accessed. Note: depending on how the filesystem was mounted, the last accessed time may not update on each access to the file, but only on the first access after modifications.

## (IO::Path) method changed

Returns an Instant object indicating the metadata of the file or directory was last changed (e.g. permissions, or files created/deleted in directory). Compare with modified.

## (IO::Path) method mode

Return an IntStr object representing the POSIX permissions of a file. The Str part of the result is the octal representation of the file permission, like the form accepted by the chmod(1) utility.

The result of this can be used in the other methods that take a mode as an argument.

# Routines supplied by class Cool

IO::Path::Cygwin inherits from class Cool, which provides the following routines:

## (Cool) routine abs

Defined as:

Coerces the invocant (or in the sub form, the argument) to Numeric and returns the absolute value (that is, a non-negative number).

## (Cool) method conj

Defined as:

Coerces the invocant to Numeric and returns the complex conjugate (that is, the number with the sign of the imaginary part negated).

Defined as:

## (Cool) routine sec

Defined as:

Coerces the invocant (or in sub form, its argument) to Numeric, interprets it as radians, returns its secant, that is, the reciprocal of its cosine.

## (Cool) routine asec

Defined as:

Coerces the invocant (or in sub form, its argument) to Numeric, and returns its arc-secant in radians.

## (Cool) routine cosec

Defined as:

Coerces the invocant (or in sub form, its argument) to Numeric, interprets it as radians, returns its cosecant, that is, the reciprocal of its sine.

## (Cool) routine acosec

Defined as:

Coerces the invocant (or in sub form, its argument) to Numeric, and returns its arc-cosecant in radians.

## (Cool) routine cotan

Defined as:

Coerces the invocant (or in sub form, its argument) to Numeric, interprets it as radians, returns its cotangent, that is, the reciprocal of its tangent.

## (Cool) routine acotan

Defined as:

Coerces the invocant (or in sub form, its argument) to Numeric, and returns its arc-cotangent in radians.

## (Cool) routine sinh

Defined as:

Coerces the invocant (or in method form, its argument) to Numeric, and returns its Sine hyperbolicus.

## (Cool) routine asinh

Defined as:

Coerces the invocant (or in sub form, its argument) to Numeric, and returns its Inverse Sine hyperbolicus.

## (Cool) routine cosh

Defined as:

Coerces the invocant (or in sub form, its argument) to Numeric, and returns its Cosine hyperbolicus.

## (Cool) routine acosh

Defined as:

Coerces the invocant (or in sub form, its argument) to Numeric, and returns its Inverse Cosine hyperbolicus.

## (Cool) routine tanh

Defined as:

Coerces the invocant (or in sub form, its argument) to Numeric, interprets it as radians and returns its Tangent hyperbolicus.

## (Cool) routine atanh

Defined as:

Coerces the invocant (or in sub form, its argument) to Numeric, and returns its Inverse tangent hyperbolicus.

## (Cool) routine sech

Defined as:

Coerces the invocant (or in sub form, its argument) to Numeric, and returns its Secant hyperbolicus.

## (Cool) routine asech

Defined as:

Coerces the invocant (or in sub form, its argument) to Numeric, and returns its Inverse hyperbolic secant.

## (Cool) routine cosech

Defined as:

Coerces the invocant (or in sub form, its argument) to Numeric, and returns its Hyperbolic cosecant.

## (Cool) routine acosech

Defined as:

Coerces the invocant (or in sub form, its argument) to Numeric, and returns its Inverse hyperbolic cosecant.

## (Cool) routine cotanh

Defined as:

Coerces the invocant (or in sub form, its argument) to Numeric, and returns its Hyperbolic cotangent.

## (Cool) routine acotanh

Defined as:

Coerces the invocant (or in sub form, its argument) to Numeric, and returns its Inverse hyperbolic cotangent.

## (Cool) routine cis

Defined as:

Coerces the invocant (or in sub form, its argument) to Numeric, and returns cos(argument) + i*sin(argument).

Defined as:

## (Cool) routine ceiling

Defined as:

Coerces the invocant (or in sub form, its argument) to Numeric, and rounds it upwards to the nearest integer.

## (Cool) routine truncate

Defined as:

Coerces the invocant (or in sub form, its argument) to Numeric, and rounds it towards zero.

## (Cool) routine ord

Defined as:

Coerces the invocant (or in sub form, its argument) to Str, and returns the Unicode code point number of the first code point.

The inverse operation is chr.

Mnemonic: returns an ordinal number

## (Cool) method path

Defined as:

DEPRECATED. It's been deprecated as of the 6.d version. Will be removed in the next ones.

Stringifies the invocant and converts it to IO::Path object. Use the .IO method instead.

## (Cool) routine chr

Defined as:

Coerces the invocant (or in sub form, its argument) to Int, interprets it as a Unicode code points, and returns a string made of that code point.

The inverse operation is ord.

Mnemonic: turns an integer into a character.

## (Cool) routine chars

Defined as:

Coerces the invocant (or in sub form, its argument) to Str, and returns the number of characters in the string. Please note that on the JVM, you currently get codepoints instead of graphemes.

If the string is native, the number of chars will be also returned as a native int.

Graphemes are user visible characters. That is, this is what the user thinks of as a “character”.

Graphemes can contain more than one codepoint. Typically the number of graphemes and codepoints differs when Prepend or Extend characters are involved (also known as Combining characters), but there are many other cases when this may happen. Another example is \c[ZWJ] (Zero-width joiner).

You can check Grapheme_Cluster_Break property of a character in order to see how it is going to behave:

You can read more about graphemes in the Unicode Standard, which Raku tightly follows, using a method called NFG, normal form graphemes for efficiently representing them.

## (Cool) routine codes

Defined as:

Coerces the invocant (or in sub form, its argument) to Str, and returns the number of Unicode code points.

The same result will be obtained with

ords first obtains the actual codepoints, so there might be a difference in speed.

## (Cool) routine flip

Defined as:

Coerces the invocant (or in sub form, its argument) to Str, and returns a reversed version.

## (Cool) routine trim

Defined as:

Coerces the invocant (or in sub form, its argument) to Str, and returns the string with both leading and trailing whitespace stripped.

Defined as:

Coerces the invocant (or in sub form, its argument) to Str, and returns the string with leading whitespace stripped.

## (Cool) routine trim-trailing

Defined as:

Coerces the invocant (or in sub form, its argument) to Str, and returns the string with trailing whitespace stripped.

## (Cool) routine lc

Defined as:

Coerces the invocant (or in sub form, its argument) to Str, and returns it case-folded to lower case.

## (Cool) routine uc

Defined as:

Coerces the invocant (or in sub form, its argument) to Str, and returns it case-folded to upper case (capital letters).

## (Cool) routine fc

Defined as:

Coerces the invocant (or in sub form, its argument) to Str, and returns the result a Unicode "case fold" operation suitable for doing caseless string comparisons. (In general, the returned string is unlikely to be useful for any purpose other than comparison.)

## (Cool) routine tc

Defined as:

Coerces the invocant (or in sub form, its argument) to Str, and returns it with the first letter case-folded to title case (or where not available, upper case).

## (Cool) routine tclc

Defined as:

Coerces the invocant (or in sub form, its argument) to Str, and returns it with the first letter case-folded to title case (or where not available, upper case), and the rest of the string case-folded to lower case.

Defined as:

Coerces the invocant (or in sub form, the first argument) to Str, and filters each word that smartmatches against $where through the &filter. With the default filter (first character to upper case, rest to lower) and matcher (which accepts everything), this title-cases each word: With a matcher: With a customer filter too: ## (Cool) routine samecase Defined as: Coerces the invocant (or in sub form, the first argument) to Str, and calls Str.samecase on it. ## (Cool) routine uniprop Defined as: Returns the unicode property of the first character. If no property is specified returns the General Category. Returns a Bool for Boolean properties. A uniprops routine can be used to get the property for every character in a string. ## (Cool) sub uniprops Defined as: Interprets the invocant as a Str, and returns the unicode property for each character as a Seq. If no property is specified returns the General Category. Returns a Bool for Boolean properties. Similar to uniprop, but for each character in the passed string. ## (Cool) routine uniname Defined as: Interprets the invocant or first argument as a Str, and returns the Unicode codepoint name of the first codepoint of the first character. See uninames for a routine that works with multiple codepoints, and uniparse for the opposite direction. ## (Cool) routine uninames Defined as: Returns of a Seq of Unicode names for the all the codepoints in the Str provided. Note this example, which gets a Seq where each element is a Seq of all the codepoints in that character. See uniparse for the opposite direction. ## (Cool) routine unimatch Defined as: Checks if the given integer codepoint or the first letter of the given string has a unicode property equal to the value you give. If you supply the Unicode property to be checked it will only return True if that property matches the given value. The last property corresponds to "lowercase letter", which explains why it returns false. ## (Cool) routine chop Defined as: Coerces the invocant (or in sub form, its argument) to Str, and returns it with the last character removed. ## (Cool) routine chomp Defined as: Coerces the invocant (or in sub form, its argument) to Str, and returns it with the last character removed, if it is a logical newline. ## (Cool) routine substr Defined as: Coerces the invocant (or in the sub form, the first argument) to Str, and calls Str.substr with the arguments. ## (Cool) routine substr-rw Defined as: Coerces the invocant (or in the sub form, the first argument) to Str, and calls Str.substr-rw with the arguments. ## (Cool) routine ords Defined as: Coerces the invocant (or in the sub form, the first argument) to Str, and returns a list of Unicode codepoints for each character. This is the list-returning version of ord. The inverse operation in chrs. If you are only interested in the number of codepoints, codes is a possibly faster option. ## (Cool) routine chrs Defined as: Coerces the invocant (or in the sub form, the argument list) to a list of integers, and returns the string created by interpreting each integer as a Unicode codepoint, and joining the characters. This is the list-input version of chr. The inverse operation is ords. ## (Cool) routine split Defined as: [1] Coerces the invocant (or in the sub form, the second argument) to Str, splits it into pieces based on delimiters found in the string and returns the result as a Seq. If $delimiter is a string, it is searched for literally and not treated as a regex. You can also provide multiple delimiters by specifying them as a list, which can mix Cool and Regex objects.

By default, split omits the matches, and returns a list of only those parts of the string that did not match. Specifying one of the :k, :v, :kv, :p adverbs changes that. Think of the matches as a list that is interleaved with the non-matching parts.

The :v interleaves the values of that list, which will be either Match objects, if a Regex was used as a matcher in the split, or Str objects, if a Cool was used as matcher. If multiple delimiters are specified, Match objects will be generated for all of them, unless all of the delimiters are Cool.

:k interleaves the keys, that is, the indexes:

:kv adds both indexes and matches:

and :p adds them as Pairs, using the same types for values as :v does:

You can only use one of the :k, :v, :kv, :p adverbs in a single call to split.

Note that empty chunks are not removed from the result list. For that behavior, use the :skip-empty named argument:

## (Cool) routine lines

Defined as:

Coerces the invocant (and in sub form, the argument) to Str, decomposes it into lines (with the newline characters stripped), and returns the list of lines.

This method can be used as part of an IO::Path to process a file line-by-line, since IO::Path objects inherit from Cool, e.g.:

For example

## (Cool) method subst

Defined as:

Coerces the invocant to Stringy and calls Str.subst.

## (Cool) method trans

Defined as:

Coerces the invocant to Str and calls Str.trans

## (Cool) method IO

Defined as:

Coerces the invocant to IO::Path.

## (Cool) method sprintf

Defined as:

Returns a string according to a series format directives that are common in many languages; the object will be the format string, while the supplied arguments will be what's going to be formatted according to it.

## (Cool) method printf

Defined as:

Uses the object, as long as it is a format string, to format and print the arguments

## (Cool) method Complex

Defined as:

Coerces the invocant to a Numeric and calls its .Complex method. Fails if the coercion to a Numeric cannot be done.

## (Cool) method FatRat

Defined as:

Coerces the invocant to a Numeric and calls its .FatRat method. Fails if the coercion to a Numeric cannot be done.

## (Cool) method Int

Defined as:

Coerces the invocant to a Numeric and calls its .Int method. Fails if the coercion to a Numeric cannot be done.

## (Cool) method Num

Defined as:

Coerces the invocant to a Numeric and calls its .Num method. Fails if the coercion to a Numeric cannot be done.

## (Cool) method Rat

Defined as:

Coerces the invocant to a Numeric and calls its .Rat method. Fails if the coercion to a Numeric cannot be done.

## (Cool) method Real

Defined as:

Coerces the invocant to a Numeric and calls its .Real method. Fails if the coercion to a Numeric cannot be done.

## (Cool) method UInt

Defined as:

Coerces the invocant to an Int. Fails if the coercion to an Int cannot be done or if the Int the invocant had been coerced to is negative.