Skip to content

Commit 81900cb

Browse files
committed
[io grant] Finish off IO::Path.parent
- Add more examples - Add note about symlinked dirs
1 parent acf4040 commit 81900cb

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

doc/Type/IO/Path.pod6

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -414,12 +414,19 @@ attribute the object was created with, and then is made relative to C<$base>.
414414
415415
Defined as:
416416
417-
method parent(IO::Path:D: --> IO::Path)
418-
419-
Removes the last portion of the path and returns the result as a new C<IO::Path>.
420-
421-
my $io = IO::Path.new( "/etc/passwd" );
422-
say $io.parent; # OUTPUT: «"/etc".IO␤»
417+
method parent(IO::Path:D: --> IO::Path:D)
418+
419+
Returns the parent path of the invocant. Note that no file system access
420+
is made, so the returned parent parent is physical and not the logical parent of
421+
symlinked directories.
422+
423+
'/etc/foo'.IO.parent.say; # OUTPUT: «"/etc".IO␤»
424+
'/etc/..' .IO.parent.say; # OUTPUT: «"/etc".IO␤»
425+
'/etc/../'.IO.parent.say; # OUTPUT: «"/etc".IO␤»
426+
'./' .IO.parent.say; # OUTPUT: «"..".IO␤»
427+
'foo' .IO.parent.say; # OUTPUT: «".".IO␤»
428+
'/' .IO.parent.say; # OUTPUT: «"/".IO␤»
429+
IO::Path::Win32.new('C:/').parent.say; # OUTPUT: «"C:/".IO␤»
423430
424431
=head2 method resolve
425432

0 commit comments

Comments
 (0)