| 1 | package IO::Die; | ||||||||||
| 2 | |||||||||||
| 3 | 10 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | #NOTE: This will only chmod() one thing at a time. It refuses to support | ||||||||||
| 6 | #multiple chmod() operations within the same call. This is in order to provide | ||||||||||
| 7 | #reliable error reporting. | ||||||||||
| 8 | # | ||||||||||
| 9 | #You, of course, can still do: IO::Die->chmod() for @items; | ||||||||||
| 10 | # | ||||||||||
| 11 | 50 | ▶ | sub chmod { | ||||||||
|
Subroutine
chmod: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||
| 12 | 50 | my ( $NS, $mode, $target, @too_many_args ) = @_; | |||||||||
| 13 | |||||||||||
| 14 | #This is here because it’s impossible to do reliable error-checking when | ||||||||||
| 15 | #you operate on >1 filesystem node at once. | ||||||||||
| 16 | 50 | ▶ | die "Only one path at a time!" if @too_many_args; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 17 | |||||||||||
| 18 | #NOTE: This breaks chmod’s error reporting when a file handle is passed in. | ||||||||||
| 19 | #cf. https://rt.perl.org/Ticket/Display.html?id=122703 | ||||||||||
| 20 | 40 | local ( $!, $^E ); | |||||||||
| 21 | |||||||||||
| 22 | 40 | ▶ | my $ok = CORE::chmod( $mode, $target ) or do { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 23 | 20 | ▶ | if ( __is_a_fh($target) ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 24 | 0 | $NS->__THROW( 'Chmod', permissions => $mode ); | |||||||||
| 25 | } | ||||||||||
| 26 | |||||||||||
| 27 | 20 | $NS->__THROW( 'Chmod', permissions => $mode, path => $target ); | |||||||||
| 28 | }; | ||||||||||
| 29 | |||||||||||
| 30 | 20 | return $ok; | |||||||||
| 31 | } | ||||||||||
| 32 | |||||||||||
| 33 | 1 | 1; | |||||||||