Skip to content

Commit 28b6283

Browse files
committed
[io grant] Document IO::Spec::*.canonpath
1 parent a1cb80b commit 28b6283

File tree

4 files changed

+68
-0
lines changed

4 files changed

+68
-0
lines changed

doc/Type/IO/Spec/Cygwin.pod6

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,23 @@ Returns a string that represents C<$path>, but relative to C<$base> path.
2323
Both C<$path> and C<$base> may be relative paths C<$bar> defaults to C<$*CWD>.
2424
Uses L«C<IO::Spec::Win32>|/type/IO::Spec::Win32»'s semantics.
2525
26+
=head2 method canonpath
27+
28+
method canonpath(Str() $path, :$parent --> Str:D)
29+
30+
Returns a string that is a canonical representation of C<$path>. If C<:$parent>
31+
is set to true, will also clean up references to parent directories. B<NOTE:>
32+
the routine does not access the filesystem.
33+
34+
IO::Spec::Cygwin.canonpath(「C:\foo\\..\bar\..\ber」).say;
35+
# OUTPUT: «C:/foo/../bar/../ber␤»
36+
37+
IO::Spec::Cygwin.canonpath("foo///./../bar/../ber").say;
38+
# OUTPUT: «foo/../bar/../ber␤»
39+
40+
IO::Spec::Cygwin.canonpath("foo///./../bar/../ber", :parent).say;
41+
# OUTPUT: «ber␤»
42+
2643
=head2 method tmpdir
2744
2845
Defined as:

doc/Type/IO/Spec/QNX.pod6

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,23 @@ need to use C<IO::Spec::*>. Use L«C<IO::Path>|/type/IO::Path» instead.
1515
1616
=head1 Methods
1717
18+
=head2 method canonpath
19+
20+
method canonpath(Str() $path, :$parent --> Str:D)
21+
22+
Returns a string that is a canonical representation of C<$path>. If C<:$parent>
23+
is set to true, will also clean up references to parent directories. B<NOTE:>
24+
the routine does not access the filesystem, so no symlinks are followed.
25+
26+
IO::Spec::QNX.canonpath("foo//../bar/../ber").say;
27+
# OUTPUT: «foo/../bar/../ber␤»
28+
29+
IO::Spec::QNX.canonpath("foo///./../bar/../ber").say;
30+
# OUTPUT: «foo/../bar/../ber␤»
31+
32+
IO::Spec::QNX.canonpath("foo///./../bar/../ber", :parent).say;
33+
# OUTPUT: «ber␤»
34+
1835
=end pod
1936

2037
# vim: expandtab shiftwidth=4 ft=perl6

doc/Type/IO/Spec/Unix.pod6

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,23 @@ slash:
3333
IO::Spec::Unix.basename("foo/bar/.").perl.say; # OUTPUT: «"."␤»
3434
IO::Spec::Unix.basename("foo/bar") .perl.say; # OUTPUT: «"bar"␤»
3535
36+
=head2 method canonpath
37+
38+
method canonpath(Str() $path, :$parent --> Str:D)
39+
40+
Returns a string that is a canonical representation of C<$path>. If C<:$parent>
41+
is set to true, will also clean up references to parent directories. B<NOTE:>
42+
the routine does not access the filesystem, so no symlinks are followed.
43+
44+
IO::Spec::Unix.canonpath("foo//../bar/../ber").say;
45+
# OUTPUT: «foo/../bar/../ber␤»
46+
47+
IO::Spec::Unix.canonpath("foo///./../bar/../ber").say;
48+
# OUTPUT: «foo/../bar/../ber␤»
49+
50+
IO::Spec::Unix.canonpath("foo///./../bar/../ber", :parent).say;
51+
# OUTPUT: «ber␤»
52+
3653
=head2 method tmpdir
3754
3855
Defined as:

doc/Type/IO/Spec/Win32.pod6

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,23 @@ slash or backslash:
2828
IO::Spec::Win32.basename("foo/bar/.").perl.say; # OUTPUT: «"."␤»
2929
IO::Spec::Win32.basename("foo/bar") .perl.say; # OUTPUT: «"bar"␤»
3030
31+
=head2 method canonpath
32+
33+
method canonpath(Str() $path, :$parent --> Str:D)
34+
35+
Returns a string that is a canonical representation of C<$path>. If C<:$parent>
36+
is set to true, will also clean up references to parent directories. B<NOTE:>
37+
the routine does not access the filesystem.
38+
39+
IO::Spec::Win32.canonpath("C:/foo//../bar/../ber").say;
40+
# OUTPUT: «C:\foo\..\bar\..\ber␤»
41+
42+
IO::Spec::Win32.canonpath("C:/foo///./../bar/../ber").say;
43+
# OUTPUT: «C:\foo\..\bar\..\ber␤»
44+
45+
IO::Spec::Win32.canonpath("C:/foo///./../bar/../ber", :parent).say;
46+
# OUTPUT: «C:\ber␤»
47+
3148
=head2 method tmpdir
3249
3350
Defined as:

0 commit comments

Comments
 (0)