TOC Index
Platform specific operations on file and directory paths for Cygwin
class IO::Spec::Cygwin is IO::Spec::Unix { }
An object of this type is available via the variable $*SPEC if the Raku interpreter is running on Cygwin.
About this class and its related classes also see IO::Spec.
method abs2rel(IO::Path:D $path, IO::Path:D $base = $*CWD --> Str:D)
Returns a string that represents $path, but relative to $base path. Both $path and $base may be relative paths. $base defaults to $*CWD. Uses IO::Spec::Win32's semantics.
method canonpath(Str() $path, :$parent --> Str:D)
Returns a string that is a canonical representation of $path. If :$parent is set to true, will also clean up references to parent directories. NOTE: the routine does not access the filesystem.
IO::Spec::Cygwin.canonpath(「C:\foo\\..\bar\..\ber」).say;# OUTPUT: «C:/foo/../bar/../ber»IO::Spec::Cygwin.canonpath("foo///./../bar/../ber").say;# OUTPUT: «foo/../bar/../ber»IO::Spec::Cygwin.canonpath("foo///./../bar/../ber", :parent).say;# OUTPUT: «ber»
method catdir (*@parts --> Str:D)
Concatenates multiple path fragments and returns the canonical representation of the resultant path as a string. The @parts are Str objects and are allowed to contain path separators.
IO::Spec::Cygwin.catdir(<foo/bar ber raku>).say;# OUTPUT: «foo/bar/ber/raku»
method catpath (Str:D $volume, Str:D $dir, Str:D $file --> Str:D)
Same as IO::Spec::Win32.catpath, except will also change all backslashes to slashes at the end:
IO::Spec::Cygwin.catpath('C:', '/some/dir', 'foo.txt').say;# OUTPUT: «C:/some/dir/foo.txt»IO::Spec::Cygwin.catpath('C:', '/some/dir', '').say;# OUTPUT: «C:/some/dir»IO::Spec::Cygwin.catpath('', '/some/dir', 'foo.txt').say;# OUTPUT: «/some/dir/foo.txt»IO::Spec::Cygwin.catpath('E:', '', 'foo.txt').say;# OUTPUT: «E:foo.txt»
method is-absolute(Str:D $path --> Bool:D)
Returns True if the $path starts with a slash ("/") or backslash ("\"), even if they have combining character on them, optionally preceded by a volume:
say IO::Spec::Cygwin.is-absolute: "/foo"; # OUTPUT: «True»say IO::Spec::Cygwin.is-absolute: "/\x[308]foo"; # OUTPUT: «True»say IO::Spec::Cygwin.is-absolute: 「C:\foo」; # OUTPUT: «True»say IO::Spec::Cygwin.is-absolute: "bar"; # OUTPUT: «False»
method join(|c)
Same as IO::Spec::Win32.join, except replaces backslashes with slashes in the final result.
method rel2abs(|c --> List:D)
Same as IO::Spec::Win32.rel2abs, except replaces backslashes with slashes in the final result.
method split(IO::Spec::Cygwin: Cool:D $path)
Same as IO::Spec::Win32.split, except it replaces backslashes with slashes in all the values of the final result.
method splitpath(|c --> List:D)
Same as IO::Spec::Win32.splitpath, except replaces backslashes with slashes in all the values of the final result.
method tmpdir(--> IO::Path:D)
Attempts to locate a system's temporary directory by checking several typical directories and environment variables. Uses current directory if no suitable directories are found.