| 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
| |||||||||||
| 17 | |||||||||||
| 18 | 12 | ▶ | if ( !@paths ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 19 | 1 | @paths = ($_); | |||||||||
| 20 | } | ||||||||||
| 21 | |||||||||||
| 22 | 12 | local ( $!, $^E ); | |||||||||
| 23 | 12 | ▶ | my $ok = CORE::unlink(@paths) or do { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 24 | 1 | $NS->__THROW( 'Unlink', path => $paths[0] ); | |||||||||
| 25 | }; | ||||||||||
| 26 | |||||||||||
| 27 | 11 | return $ok; | |||||||||
| 28 | } | ||||||||||
| 29 | |||||||||||
| 30 | 7 | 1; | |||||||||