@@ -528,32 +528,29 @@ contents you will have to do something more complex.
528
528
529
529
See also L < rmtree in File::Directory::Tree|https://github.com/labster/p6-file-directory-tree > .
530
530
531
- = head2 routine chmod
531
+ = head2 method chmod
532
532
533
- sub chmod($mode, *@filenames --> List)
534
- method chmod(IO::Path:D: $mode --> Bool)
533
+ method chmod(IO::Path:D: Int() $mode --> Bool)
535
534
536
- Changes the POSIX permissions of a file (or in the subroutine form, any number
537
- of files) to C < $mode > .
538
-
539
- The subroutine form returns the names of the files for which setting the new
540
- mode was successful. The method form returns True on success, and otherwise
535
+ Changes the POSIX permissions of a file or directory to C < $mode > .
536
+ Returns C < True > on success; on failure,
541
537
L < fails|/routine/fail > with L < X::IO::Chmod > .
542
538
543
539
The mode is expected as an integer following the L < standard numeric notation|
544
540
https://en.wikipedia.org/wiki/File_system_permissions#Numeric_notation > , and is
545
541
best written as an octal number:
546
542
547
543
= for code :skip-test
548
- chmod 0o755, "myfile1", "myfile2"; # make two files executable by the owner
549
- "myfile".IO.chmod(0o444); # make a file read-only
550
- $*CWD.chmod(0o544); # make the working directory read-only
544
+ 'myfile'.IO.chmod(0o444); # make a file read-only
545
+ 'somedir'.IO.chmod(0o777); # set 0777 permissions on a directory
551
546
552
547
Make sure you I < don't > accidentally pass the intended octal digits as a decimal
553
548
number (or string containing a decimal number):
554
549
555
550
= for code :skip-test
556
- chmod '0444', 'myfile'; # BAD!!! (interpreted as mode 0o674)
551
+ chmod '0444', 'myfile'; # BAD!!! (interpreted as mode 0o674)
552
+ chmod '0o444', 'myfile'; # OK (an octal in a string)
553
+ chmod 0o444, 'myfile'; # Also OK (an octal literal)
557
554
558
555
= head2 routine rename
559
556
0 commit comments