Die/unlink.pm

filter: Statementstmt 100% 12 / 12 Branchbran 100% 6 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 2 / 2 Podpod n/a totaltotal 100% 20 / 20 CC 4 SCAR 12.2
CC
4
Cov
100%
unlink
4.0
BEGIN
1.0
CRAP 3.4
« Die/rmdir.pm ↑ Summary Die/kill.pm »
1 package IO::Die;
2  
3 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 #NOTE: This will only unlink() one file at a time. It refuses to support
6 #multiple unlink() 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->unlink() for @files;
10 #
11 13 ▶sub unlink {
Subroutine unlink: called CC=4 SCAR=13.9
12 13 my ( $NS, @paths ) = @_;
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 13 ▶ die "Only one path at a time!" if @paths > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @paths > 1 1 12 13
17  
18 12 ▶ if ( !@paths ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@paths) 1 11 12
19 1 @paths = ($_);
20 }
21  
22 12 local ( $!, $^E );
23 12 ▶ my $ok = CORE::unlink(@paths) or do {
Branch: 1 branch
BranchTrueFalseTotal
my $ok = CORE::unlink(@paths) or do { $NS->__THROW("Unlink", "path", $paths[0]) } 11 1 12
24 1 $NS->__THROW( 'Unlink', path => $paths[0] );
25 };
26  
27 11 return $ok;
28 }
29  
30 7 1;
« Die/rmdir.pm ↑ Summary Die/kill.pm »