IO::Spec::Cygwin Reference
Platform specific operations on file and directory paths for Cygwin
What it is #
Routines #
Signatures are reproduced from the documentation, including their declared return types. A routine listed here is part of the type's published interface; whether Raku++ implements it is a separate question, answered by the examples below.
method abs2rel #
method abs2rel(IO::Path:D $path, IO::Path:D $base = $*CWD --> Str:D)
Returns 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 #
method canonpath(Str() $path, :$parent --> Str:D)
Returns 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.
method catdir #
method catdir (*@parts --> Str:D)
Returns 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.
method catpath #
method catpath (Str:D $volume, Str:D $dir, Str:D $file --> Str:D)
Returns Str:D.
Same as IO::Spec::Win32.catpath, except will also change all backslashes to slashes at the end:
method is-absolute #
method is-absolute(Str:D $path --> Bool:D)
Returns 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:
method join #
method join(|c)
Same as IO::Spec::Win32.join, except replaces backslashes with slashes in the final result.
method rel2abs #
method rel2abs(|c --> List:D)
Returns List:D.
Same as IO::Spec::Win32.rel2abs, except replaces backslashes with slashes in the final result.
method split #
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 #
method splitpath(|c --> List:D)
Returns List:D.
Same as IO::Spec::Win32.splitpath, except replaces backslashes with slashes in all the values of the final result.
method tmpdir #
method tmpdir(--> IO::Path:D)
Returns 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.
Examples, run three ways #
Every example below comes from the official documentation, together with the output that documentation asserts. Each was then executed by Rakudo and by Raku++ when this page was built. Where the three agree, one result is shown; where they do not, all three are — because which of them is wrong is exactly the information worth having.
1 no-output · 9 ok
class IO::Spec::Cygwin is IO::Spec::Unix { }Not executed: the documentation states no expected output for this example.
IO::Spec::Cygwin.canonpath(「C:\foo\\..\bar\..\ber」).say; # OUTPUT: «C:/foo/../bar/../ber»
C:/foo/../bar/../ber
Documentation, Rakudo and Raku++ all agree.
IO::Spec::Cygwin.canonpath("foo///./../bar/../ber").say;
# OUTPUT: «foo/../bar/../ber»foo/../bar/../ber
Documentation, Rakudo and Raku++ all agree.
IO::Spec::Cygwin.canonpath("foo///./../bar/../ber", :parent).say;
# OUTPUT: «ber»ber
Documentation, Rakudo and Raku++ all agree.
IO::Spec::Cygwin.catdir(<foo/bar ber raku>).say; # OUTPUT: «foo/bar/ber/raku»
foo/bar/ber/raku
Documentation, Rakudo and Raku++ all agree.
IO::Spec::Cygwin.catpath('C:', '/some/dir', 'foo.txt').say;
# OUTPUT: «C:/some/dir/foo.txt»C:/some/dir/foo.txt
Documentation, Rakudo and Raku++ all agree.
IO::Spec::Cygwin.catpath('C:', '/some/dir', '').say;
# OUTPUT: «C:/some/dir»C:/some/dir
Documentation, Rakudo and Raku++ all agree.
IO::Spec::Cygwin.catpath('', '/some/dir', 'foo.txt').say;
# OUTPUT: «/some/dir/foo.txt»/some/dir/foo.txt
Documentation, Rakudo and Raku++ all agree.
IO::Spec::Cygwin.catpath('E:', '', 'foo.txt').say;
# OUTPUT: «E:foo.txt»E:foo.txt
Documentation, Rakudo and Raku++ all agree.
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»
True
True
True
False
Documentation, Rakudo and Raku++ all agree.