Die/chmod.pm

filter: Statementstmt 91.6% 11 / 12 Branchbran 83.3% 5 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 2 / 2 Podpod 100% 1 / 1 totaltotal 90.4% 19 / 21 CC 4 SCAR 12.3
CC
4
Cov
89%
chmod
4.0
BEGIN
1.0
CRAP 3.4
« Die/utime.pm ↑ Summary Die/select.pm »
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
BranchTrueFalseTotal
if @too_many_args 10 40 50
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
BranchTrueFalseTotal
my $ok = CORE::chmod($mode, $target) or do { if (__is_a_fh($target)) { $NS->__THROW("Chmod", "permissions", $mode); } ; $NS->__THROW("Chmod", "permissions", $mode, "path", $target) } 20 20 40
23 20 ▶ if ( __is_a_fh($target) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (__is_a_fh($target)) 0 20 20
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;
« Die/utime.pm ↑ Summary Die/select.pm »