Skip to content

Commit dbdc995

Browse files
committed
[io grant] Document IO::Spec::*.catpath
1 parent 9dd7399 commit dbdc995

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed

doc/Type/IO/Spec/Cygwin.pod6

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,25 @@ and are allowed to contain path separators.
5151
IO::Spec::Cygwin.catdir(<foo/bar ber perl>).say;
5252
# OUTPUT: «foo/bar/ber/perl␤»
5353
54+
=head2 method catpath
55+
56+
method catpath (Str:D $volume, Str:D $dirs, Str:D $file --> Str:D)
57+
58+
Same as L«C<IO::Spec::Win32.catpath>|/type/IO::Spec::Win32#method_catpath»,
59+
except will also change all backslashes to slashes at the end:
60+
61+
IO::Spec::Cygwin.catpath('C:', '/some/dir', 'foo.txt').say;
62+
# OUTPUT: «C:/some/dir/foo.txt␤»
63+
64+
IO::Spec::Cygwin.catpath('C:', '/some/dir', '').say;
65+
# OUTPUT: «C:/some/dir␤»
66+
67+
IO::Spec::Cygwin.catpath('', '/some/dir', 'foo.txt').say;
68+
# OUTPUT: «/some/dir/foo.txt␤»
69+
70+
IO::Spec::Cygwin.catpath('E:', '', 'foo.txt').say;
71+
# OUTPUT: «E:foo.txt␤»
72+
5473
=head2 method tmpdir
5574
5675
Defined as:

doc/Type/IO/Spec/Unix.pod6

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,18 @@ and are allowed to contain path separators.
6464
6565
Alias for L«C<catdir>|/routine/catdir».
6666
67+
=head2 method catpath
68+
69+
method catpath ($, Str:D $part1, Str:D $part2 --> Str:D)
70+
71+
Takes two path fragments and concatenates them, adding or removing a path
72+
separator, if necessary. The first argument is ignored (it exists to maintain
73+
consistent interface with other C<IO::Spec> types for systems that have
74+
volumes).
75+
76+
IO::Spec::Unix.catpath($, 'some/dir', 'and/more').say;
77+
# OUTPUT: «some/dir/and/more␤»
78+
6779
=head2 method tmpdir
6880
6981
Defined as:

doc/Type/IO/Spec/Win32.pod6

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,27 @@ and are allowed to contain path separators.
6060
6161
Alias for L«C<catdir>|/routine/catdir».
6262
63+
=head2 method catpath
64+
65+
method catpath (Str:D $volume, Str:D $dirs, Str:D $file --> Str:D)
66+
67+
Concatenates a path from given volume, a chain of directories, and file.
68+
An empty string can be given for any of the three arguments. No attempt to
69+
make the path cannonical is made. Use L«C<canonpath>|/routine/canonpath» for
70+
that purpose.
71+
72+
IO::Spec::Win32.catpath('C:', '/some/dir', 'foo.txt').say;
73+
# OUTPUT: «C:/some/dir\and/more␤»
74+
75+
IO::Spec::Win32.catpath('C:', '/some/dir', '').say;
76+
# OUTPUT: «C:/some/dir␤»
77+
78+
IO::Spec::Win32.catpath('', '/some/dir', 'foo.txt').say;
79+
# OUTPUT: «/some/dir\foo.txt␤»
80+
81+
IO::Spec::Win32.catpath('E:', '', 'foo.txt').say;
82+
# OUTPUT: «E:foo.txt␤»
83+
6384
=head2 method tmpdir
6485
6586
Defined as:

0 commit comments

Comments
 (0)