Skip to content

Commit 89c2bc8

Browse files
committed
Document &chmod
1 parent bd9f7a3 commit 89c2bc8

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

lib/Type/IO/Path.pod

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,30 @@ An example that lists all files and directories recursively:
152152
}
153153
}
154154
155-
=head2 method chmod
155+
=head2 routine chmod
156156
157-
method chmod(IO::Path:D: Int:D $mode)
157+
sub chmod($mode, *@filenames --> @success-filenames)
158+
method chmod(IO::Path:D: $mode --> Bool)
158159
159-
Changes the POSIX permissions of a file to C<$mode>.
160+
Changes the POSIX permissions of a file (or in the subroutine form, any number
161+
of files) to C<$mode>.
160162
161-
"myfile".IO.chmod(0o755);
163+
The subroutine form returns the names of the files for which setting the new
164+
mode was successful. The method form returns True on success, and otherwise a
165+
C<Failure> (wrapping an C<X::IO::Chmod> exception).
166+
167+
The mode is expected as an integer following the L<standard numeric notation|
168+
https://en.wikipedia.org/wiki/File_system_permissions#Numeric_notation>, and is
169+
best written as an octal number:
170+
171+
chmod 0o755, "myfile1", "myfile2"; # make two files executable by the owner
172+
"myfile".IO.chmod(0o444); # make a file read-only
173+
$*CWD.chmod(0o544); # make the working directory read-only
174+
175+
Make sure you I<don't> accidentally pass the intended octal digits as a decimal
176+
number (or string containing a decimal number):
177+
178+
chmod '0444', 'myfile'; # BAD!!! (interpreted as mode 0o674)
162179
163180
=head2 method rename
164181

0 commit comments

Comments
 (0)