File tree Expand file tree Collapse file tree 1 file changed +21
-4
lines changed Expand file tree Collapse file tree 1 file changed +21
-4
lines changed Original file line number Diff line number Diff line change @@ -152,13 +152,30 @@ An example that lists all files and directories recursively:
152
152
}
153
153
}
154
154
155
- = head2 method chmod
155
+ = head2 routine chmod
156
156
157
- method chmod(IO::Path:D: Int:D $mode)
157
+ sub chmod($mode, *@filenames --> @success-filenames)
158
+ method chmod(IO::Path:D: $mode --> Bool)
158
159
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 > .
160
162
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)
162
179
163
180
= head2 method rename
164
181
You can’t perform that action at this time.
0 commit comments