Die/chown.pm untested

filter: Statementstmt 0.0% 0 / 11 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 2 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 23 CC 3 SCAR 22.5
CC
3
Cov
0%
chown
12.0
BEGIN
2.0
CRAP 9.5
1 package IO::Die;
2  
3 use strict;
4  
5 #NOTE: This will only chown() one thing at a time. It refuses to support
6 #multiple chown() 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->chown() for @items;
10 #
11 sub chown {
12 my ( $NS, $uid, $gid, $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 die "Only one path at a time!" if @too_many_args;
17  
18 local ( $!, $^E );
19  
20 my $ok = CORE::chown( $uid, $gid, $target ) or do {
21 if ( __is_a_fh($target) ) {
22 $NS->__THROW( 'Chown', uid => $uid, gid => $gid );
23 }
24  
25 $NS->__THROW( 'Chown', uid => $uid, gid => $gid, path => $target );
26 };
27  
28 return $ok;
29 }
30  
31 1;