Skip to content

Commit aeeec94

Browse files
committed
[io grant] Straighten up copy, move, rename
- Shorten and unify prose - List new type constraints as implemented in rakudo/rakudo@ff97083419
1 parent fff866f commit aeeec94

File tree

1 file changed

+20
-25
lines changed

1 file changed

+20
-25
lines changed

doc/Type/IO/Path.pod6

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -581,42 +581,37 @@ number (or string containing a decimal number):
581581
582582
=head2 routine rename
583583
584-
method rename(IO::Path:D: $to, :$createonly --> Bool)
585-
sub rename($from, $to, :$createonly --> Bool)
584+
method rename(IO::Path:D: IO() $to, :$createonly = False --> Bool:D)
585+
sub rename(IO() $from, IO() $to, :$createonly = False --> Bool:D)
586586
587-
Renames a file. Both C<$from> (the file to be renamed) and C<$to> (the
588-
destination) can take arbitrary paths. If C<:createonly> is set to C<True>,
589-
the rename fails if a file already exists in the destination. Returns
590-
C<True> upon success, or L<fails|/routine/fail> with L<X::IO::Rename> if the
591-
operation could not be completed.
587+
Renames a file or directory. Returns C<True> on success; L<fails|/routine/fail>
588+
with L<X::IO::Rename> if C<:$createonly> is C<True> and the C<$to> path already
589+
exists or if the operation failed for some other reason.
592590
593-
Please use L<move|/routine/move> if a file could not be moved by renaming
594-
(usually because the destination is on a different physical storage device).
591+
B<Note:> some renames will always fail, such as when the new name is on a
592+
different storage device. See also: L«C<move>|/routine/move».
595593
596594
=head2 routine copy
597595
598-
method copy(IO::Path:D: $to, :$createonly)
599-
sub copy($from, $to, :$createonly)
596+
method copy(IO::Path:D: IO() $to, :$createonly --> Bool:D)
597+
sub copy(IO() $from, IO() $to, :$createonly --> Bool:D)
600598
601-
Copies a file, as indicated by C<$from> or the invocant, to the
602-
destination specified. If C<:createonly> is set to C<True>, copy fails if a file
603-
already exists in the destination. Returns C<True> upon success, or an
604-
appropriate C<Failure> if the operation could not be completed.
599+
Copies a file. Returns C<True> on success; L<fails|/routine/fail>
600+
with L<X::IO::Rename> if C<:$createonly> is C<True> and the C<$to> path already
601+
exists or if the operation failed for some other reason.
605602
606603
=head2 routine move
607604
608-
method move(IO::Path:D: $to, :$createonly)
609-
sub move($from, $to, :$createonly)
605+
method move(IO::Path:D: IO() $to, :$createonly --> Bool:D)
606+
sub move(IO() $from, IO() $to, :$createonly --> Bool:D)
610607
611-
Moves a file. Both C<$from> (the file to be moved) and C<$to> (the
612-
destination) can take arbitrary paths. If C<:createonly> is set to C<True>,
613-
the move fails if a file already exists in the destination. Returns C<True>
614-
upon success, or L<fails|/routine/fail> with L<X::IO::Move> if the operation
615-
could not be completed.
608+
Copies a file and then removes the original. If removal fails, it's possible
609+
to end up with two copies of the file. Returns C<True> on success;
610+
L<fails|/routine/fail> with L<X::IO::Rename> if C<:$createonly> is C<True> and
611+
the C<$to> path already exists or if the operation failed for some other reason.
616612
617-
Please use L<rename|/routine/rename> if a file can be moved by renaming
618-
(which is usually possible if the destination is on the same different
619-
physical storage device).
613+
To avoid copying, you can use L«C<rename>|/routine/rename», if the files are on
614+
the same storage device. It also works with directories, while C<move> does not.
620615
621616
=head2 routine symlink
622617

0 commit comments

Comments
 (0)