In IO::Spec::Unix§

See primary documentation in context for method catpath

method catpath ($Str:D $part1Str:D $part2 --> Str:D)

Takes two path fragments and concatenates them, adding or removing a path separator, if necessary. The first argument is ignored (it exists to maintain consistent interface with other IO::Spec types for systems that have volumes).

IO::Spec::Unix.catpath($'some/dir''and/more').say;
# OUTPUT: «some/dir/and/more␤»

In IO::Spec::Cygwin§

See primary documentation in context for method catpath

method catpath (Str:D $volumeStr:D $dirStr: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␤»

In IO::Spec::Win32§

See primary documentation in context for method catpath

method catpath (Str:D $volumeStr:D $dirStr:D $file --> Str:D)

Concatenates a path from given volume, a chain of directories, and file. An empty string can be given for any of the three arguments. No attempt to make the path canonical is made. Use canonpath for that purpose.

IO::Spec::Win32.catpath('C:''/some/dir''foo.txt').say;
# OUTPUT: «C:/some/dir\foo.txt␤» 
 
IO::Spec::Win32.catpath('C:''/some/dir''').say;
# OUTPUT: «C:/some/dir␤» 
 
IO::Spec::Win32.catpath('''/some/dir''foo.txt').say;
# OUTPUT: «/some/dir\foo.txt␤» 
 
IO::Spec::Win32.catpath('E:''''foo.txt').say;
# OUTPUT: «E:foo.txt␤»