@@ -581,42 +581,37 @@ number (or string containing a decimal number):
581
581
582
582
= head2 routine rename
583
583
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 )
586
586
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.
592
590
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 » .
595
593
596
594
= head2 routine copy
597
595
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 )
600
598
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.
605
602
606
603
= head2 routine move
607
604
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 )
610
607
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.
616
612
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.
620
615
621
616
= head2 routine symlink
622
617
0 commit comments