Platform specific operations on file and directory paths for 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 , IO::Path = --> Str)
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() , : --> Str)
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 (* --> Str)
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 , Str , Str --> Str)
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 --> Bool)
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)
Same as IO::Spec::Win32.rel2abs
, except replaces backslashes with slashes in the final result.
method split(IO::Spec::Cygwin: Cool )
Same as IO::Spec::Win32.split
, except it replaces backslashes with slashes in all the values of the final result.
method splitpath(|c --> List)
Same as IO::Spec::Win32.splitpath
, except replaces backslashes with slashes in all the values of the final result.
method tmpdir(--> IO::Path)
Attempts to locate a system's temporary directory by checking several typical directories and environmental variables. Uses current directory if no suitable directories are found.