Skip to content

Commit d59d2b3

Browse files
committed
Merge &rename, &move, &unlink documentation into /type/IO/Path.pod
1 parent e6928eb commit d59d2b3

File tree

2 files changed

+38
-48
lines changed

2 files changed

+38
-48
lines changed

lib/Type/IO.pod

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -306,42 +306,6 @@ C<False>.
306306
spurt "file_already_exists", "new text", :createonly;
307307
File 'test' already exists, and :createonly was specified
308308
309-
=head2 sub rename
310-
311-
sub rename($from, $to, :$SPEC = $*SPEC, :$CWD = $*CWD, :$createonly);
312-
313-
Moves a file, as indicated by the first positional parameter, by renaming it
314-
to the destination specified. If C<:createonly> is set to C<True>, the rename fails
315-
if a file already exists in the destination. Returns C<True> upon success, or
316-
an appropriate C<Failure> if the operation could not be completed.
317-
318-
Please use L</move()> if a file could not be moved by renaming (usually because
319-
the destination is on a different physical storage device).
320-
321-
=head2 sub move
322-
323-
sub move($from, $to, :$createonly);
324-
325-
Moves a file, as indicated by the first positional parameter, by copying its
326-
contents to the destination specified, and then removing the file at the
327-
original location. If C<:createonly> is set to C<True>, the move fails if a file
328-
already exists in the destination. Returns C<True> upon success, or an
329-
appropriate C<Failure> if the operation could not be completed.
330-
331-
Please use L</rename()> if a file can be moved by renaming (which is usually
332-
possible if the destination is on the same different physical storage device).
333-
Alternately, the C<move()> function is free to try the C<rename()> first,
334-
and if that (silently) fails, do it the hard way.
335-
336-
B<NOTE>: This function has not yet been implemented in Rakudo.
337-
338-
=head2 sub unlink
339-
340-
sub unlink(*@filenames, :$SPEC = $*SPEC, :$CWD = $*CWD);
341-
342-
Delete all specified ordinary files, links, or symbolic links. Returns the
343-
names of the files that were successfully deleted.
344-
345309
=head2 sub run
346310
347311
sub run(*@args ($, *@)) returns Proc::Status:D

lib/Type/IO/Path.pod

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ L<IO::Path::Cygwin>, L<IO::Path::QNX>.
2424
The rest of this document silently assumes Unix semantics in its examples,
2525
unless when stated otherwise.
2626
27+
=comment TODO: Investigate if the $SPEC = $*SPEC, :$CWD = $*CWD params that
28+
a bunch of these routines have in their signature in Rakudo, are
29+
"official" Perl 6 API, and if so, document them here in a central
30+
place so all the routine documentations can link to it without
31+
having to repeat it.
2732
2833
=head1 Methods
2934
@@ -201,8 +206,7 @@ Changes the POSIX permissions of a file (or in the subroutine form, any number
201206
of files) to C<$mode>.
202207
203208
The subroutine form returns the names of the files for which setting the new
204-
mode was successful. The method form returns True on success, and otherwise a
205-
C<Failure> (wrapping an C<X::IO::Chmod> exception).
209+
mode was successful. The method form returns True on success, and otherwise L<fails|/routine/fail> with L<X::IO::Chmod>.
206210
207211
The mode is expected as an integer following the L<standard numeric notation|
208212
http://en.wikipedia.org/wiki/File_system_permissions#Numeric_notation>, and is
@@ -217,24 +221,46 @@ number (or string containing a decimal number):
217221
218222
chmod '0444', 'myfile'; # BAD!!! (interpreted as mode 0o674)
219223
220-
=head2 method rename
224+
=head2 routine rename
221225
222-
multi method rename(IO::Path:D: IO::Path:D $to, :$createonly);
226+
method rename(IO::Path:D: $to, :$createonly --> Bool);
227+
sub rename($from, $to, :$createonly --> Bool);
223228
224-
Like L</routine/rename()>, but with L</.absolute> as the first parameter.
229+
Renames a file. Both C<$from> (the file to be renamed) and C<$to> (the
230+
destination) can take arbitrary paths. If C<:createonly> is set to C<True>, the
231+
rename fails if a file already exists in the destination. Returns C<True> upon
232+
success, or L<fails|/routine/fail> with L<X::IO::Rename> if the operation could
233+
not be completed.
225234
226-
=head2 method move
235+
Please use L<move|/routine/move> if a file could not be moved by renaming (usually
236+
because the destination is on a different physical storage device).
227237
228-
method move(IO::Path:D $to, :$createonly)
238+
=head2 routine move
229239
230-
Like L</routine/move()>, but with L</.absolute> as the first parameter.
240+
method move(IO::Path:D: $to, :$createonly)
241+
sub move($from, $to, :$createonly);
231242
232-
=head2 method unlink
243+
Moves a file. Both C<$from> (the file to be moved) and C<$to> (the destination)
244+
can take arbitrary paths. If C<:createonly> is set to C<True>, the move fails
245+
if a file already exists in the destination. Returns C<True> upon success, or
246+
L<fails|/routine/fail> with L<X::IO::Move> if the operation could not be
247+
completed.
233248
234-
method unlink(IO::Path:D:);
249+
Please use L<rename|/routine/rename> if a file can be moved by renaming (which is
250+
usually possible if the destination is on the same different physical storage
251+
device).
235252
236-
Like L</routine/unlink()>, but with L</.absolute> as the first parameter.
237-
Returns C<True> on success or an appropriate C<Failure>.
253+
B<NOTE>: This function has not yet been implemented in Rakudo.
254+
255+
=head2 routine unlink
256+
257+
method unlink(IO::Path:D: --> Bool);
258+
sub unlink(*@filenames --> @success-filenames);
259+
260+
Delete all specified ordinary files, links, or symbolic links.
261+
262+
The subroutine form returns the names of the files that were successfully
263+
deleted. The method form returns C<True> on success, or L<fails|/routine/fail> with L<X::IO::Unlink> if the operation could not be completed.
238264
239265
=head1 Related roles and classes
240266

0 commit comments

Comments
 (0)