Skip to content

Commit 1973010

Browse files
committed
[io grant] Document IO::Path.ACCEPTS
N.B. currently refers to undocumented `:completely` arg to .resolve. It's not a mistake; the argument will be implemented and documented as part of IO grant work.
1 parent cc62dd2 commit 1973010

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

doc/Type/IO/Path.pod6

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,24 @@ Creates a new C<IO::Path> object from a path string (which is being parsed for
4242
volume, directory name and basename), or from volume, directory name and
4343
basename passed as named arguments.
4444
45+
=head2 method ACCEPTS
46+
47+
multi method ACCEPTS(IO::Path:D: Cool:D $other --> Bool:D)
48+
49+
Coerces the argument to C<IO::Path>, if necessary. Returns C<True> if
50+
L«C<.absolute>|/routine/absolute» method on both paths returns the same string.
51+
B<NOTE:> it's possible for two paths that superficially point to the same
52+
resource to NOT smartmatch as C<True>, if they were constructed differently and
53+
were never fully resolved:
54+
55+
say "foo/../bar".IO ~~ "bar".IO # False
56+
57+
The reason is the two paths above may point to different resources when fully
58+
resolved (e.g. if C<foo> is a symlink). Resolve the paths before smartmatching
59+
to check they point to same resource:
60+
61+
say "foo/../bar".IO.resolve(:completely) ~~ "bar".IO.resolve(:completely) # True
62+
4563
=head2 method basename
4664
4765
method basename(IO::Path:D:)

0 commit comments

Comments
 (0)