| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#!/usr/bin/perl -w |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Exception::ThrowUnless; |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
require Exporter; |
|
6
|
4
|
|
|
4
|
|
65767
|
use strict; |
|
|
4
|
|
|
|
|
9
|
|
|
|
4
|
|
|
|
|
165
|
|
|
7
|
4
|
|
|
4
|
|
3159
|
use File::Spec::Functions; |
|
|
4
|
|
|
|
|
3400
|
|
|
|
4
|
|
|
|
|
5635
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our(@ISA)=qw(Exporter); |
|
10
|
|
|
|
|
|
|
our $VERSION = "1.11"; |
|
11
|
|
|
|
|
|
|
our @EXPORT_OK = qw( |
|
12
|
|
|
|
|
|
|
schdir schmod sclose sexec sfork slink |
|
13
|
|
|
|
|
|
|
smkdir sopen sopendir spipe sreadlink srename |
|
14
|
|
|
|
|
|
|
srename_nc srmdir ssocketpair sspit ssuck ssymlink |
|
15
|
|
|
|
|
|
|
sunlink |
|
16
|
|
|
|
|
|
|
); |
|
17
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( 'all' => \@EXPORT_OK ); |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub _throw(@) { |
|
20
|
5
|
|
|
5
|
|
453
|
eval q[ |
|
|
2
|
|
|
2
|
|
23
|
|
|
|
2
|
|
|
1
|
|
11
|
|
|
|
2
|
|
|
1
|
|
3137
|
|
|
|
1
|
|
|
1
|
|
17
|
|
|
|
1
|
|
|
|
|
7
|
|
|
|
1
|
|
|
|
|
119
|
|
|
|
1
|
|
|
|
|
9
|
|
|
|
1
|
|
|
|
|
38
|
|
|
|
1
|
|
|
|
|
79
|
|
|
|
1
|
|
|
|
|
10
|
|
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
88
|
|
|
21
|
|
|
|
|
|
|
use Carp; |
|
22
|
|
|
|
|
|
|
*Exception::_throw = \&Carp::confess; |
|
23
|
|
|
|
|
|
|
]; |
|
24
|
5
|
|
|
|
|
1713
|
goto &Carp::confess; |
|
25
|
0
|
|
|
|
|
0
|
die "$@"; |
|
26
|
|
|
|
|
|
|
}; |
|
27
|
|
|
|
|
|
|
sub _checktrue($@) { |
|
28
|
13
|
100
|
|
13
|
|
91
|
_throw splice(@_,1) unless $_[0]; |
|
29
|
10
|
|
|
|
|
74
|
$_[0]; |
|
30
|
|
|
|
|
|
|
}; |
|
31
|
|
|
|
|
|
|
sub _checkdef($@) { |
|
32
|
10010
|
100
|
|
10010
|
|
22146
|
_throw splice(@_,1) unless defined $_[0]; |
|
33
|
10009
|
|
|
|
|
26844
|
$_[0]; |
|
34
|
|
|
|
|
|
|
}; |
|
35
|
|
|
|
|
|
|
sub schdir($){ |
|
36
|
7
|
|
|
7
|
0
|
7848
|
_checktrue(chdir($_[0]),"chdir:$_[0]:$!"); |
|
37
|
|
|
|
|
|
|
}; |
|
38
|
|
|
|
|
|
|
sub srmdir(;$) { |
|
39
|
3
|
100
|
|
3
|
0
|
6318
|
local $_ = shift if @_; |
|
40
|
3
|
|
|
|
|
320
|
_checktrue(rmdir($_),"rmdir:$_:$!\n"); |
|
41
|
|
|
|
|
|
|
}; |
|
42
|
|
|
|
|
|
|
sub schmod(@) { |
|
43
|
2
|
|
|
2
|
0
|
2047
|
local $"=','; |
|
44
|
2
|
100
|
|
|
|
67
|
return @_-1 if ( chmod(@_) == @_-1 ); |
|
45
|
1
|
|
|
|
|
16
|
_throw("chmod:@_:$!"); |
|
46
|
|
|
|
|
|
|
}; |
|
47
|
|
|
|
|
|
|
sub sclose(*){ |
|
48
|
2
|
|
|
2
|
0
|
436
|
local $_ = shift; |
|
49
|
2
|
100
|
|
|
|
18
|
return 1 if close($_); |
|
50
|
1
|
|
|
|
|
10
|
die "close:$_:$!"; |
|
51
|
|
|
|
|
|
|
}; |
|
52
|
|
|
|
|
|
|
sub sexec(@){ |
|
53
|
0
|
|
|
0
|
0
|
0
|
exec @_; |
|
54
|
0
|
|
|
|
|
0
|
die _throw "exec (@_):$!"; |
|
55
|
|
|
|
|
|
|
}; |
|
56
|
|
|
|
|
|
|
sub sfork() { |
|
57
|
0
|
|
|
0
|
0
|
0
|
_checkdef(fork,"fork:$!"); |
|
58
|
|
|
|
|
|
|
}; |
|
59
|
|
|
|
|
|
|
sub slink($$) { |
|
60
|
0
|
|
|
0
|
0
|
0
|
my ($f,$t) = @_; |
|
61
|
0
|
|
|
|
|
0
|
_checkdef(link($f, $t),"link:$f,$t:$!"); |
|
62
|
|
|
|
|
|
|
}; |
|
63
|
|
|
|
|
|
|
sub smkdir($$) { |
|
64
|
5
|
|
|
5
|
0
|
20953
|
my ( $dir, $mode ) = @_; |
|
65
|
5
|
|
|
|
|
772
|
my $res = mkdir $dir, $mode; |
|
66
|
5
|
50
|
|
|
|
648
|
return $res if $res; |
|
67
|
0
|
0
|
0
|
|
|
0
|
return $res if -d $dir && $! == 17; |
|
68
|
0
|
0
|
|
|
|
0
|
_throw "smkdir:$dir:$! and is not a directory" if $! == 17; |
|
69
|
0
|
|
|
|
|
0
|
_throw "smkdir:$dir:$!"; |
|
70
|
|
|
|
|
|
|
}; |
|
71
|
|
|
|
|
|
|
sub sopen(\*$) { |
|
72
|
4
|
|
|
4
|
0
|
8574
|
_checkdef(open($_[0],$_[1]),"open:$_[0],$_[1]:$!"); |
|
73
|
|
|
|
|
|
|
}; |
|
74
|
|
|
|
|
|
|
sub sopendir(\*$){ |
|
75
|
0
|
|
|
0
|
0
|
0
|
_checkdef(opendir($_[0],$_[1]),"opendir:$_[0],$_[1]:$!\n"); |
|
76
|
|
|
|
|
|
|
}; |
|
77
|
|
|
|
|
|
|
sub spipe(\*\*){ |
|
78
|
10003
|
|
|
10003
|
0
|
845928
|
_checkdef(pipe($_[0],$_[1]),"pipe:@_:$!"); |
|
79
|
|
|
|
|
|
|
}; |
|
80
|
|
|
|
|
|
|
sub sreadlink($) { |
|
81
|
1
|
|
|
1
|
0
|
18
|
_checkdef(readlink($_[0]),"readlink:$_[0]:$!"); |
|
82
|
|
|
|
|
|
|
}; |
|
83
|
|
|
|
|
|
|
sub srename($$) { |
|
84
|
0
|
|
|
0
|
0
|
0
|
my ($f,$t) = @_; |
|
85
|
0
|
|
|
|
|
0
|
_checkdef(rename($f,$t),"rename:$f,$t:$!"); |
|
86
|
|
|
|
|
|
|
}; |
|
87
|
|
|
|
|
|
|
sub srename_nc($$) { |
|
88
|
0
|
|
|
0
|
0
|
0
|
my ($f,$t) = @_; |
|
89
|
0
|
0
|
0
|
|
|
0
|
-e $t || -l $t && _throw "won't clobber '$t'"; |
|
90
|
0
|
|
|
|
|
0
|
srename($f,$t); |
|
91
|
|
|
|
|
|
|
}; |
|
92
|
|
|
|
|
|
|
sub ssocketpair(\*\*$$$) { |
|
93
|
2
|
|
|
2
|
0
|
1077
|
_checkdef(socketpair($_[0],$_[1],$_[2],$_[3],$_[4]),"socketpair:@_:$!"); |
|
94
|
|
|
|
|
|
|
}; |
|
95
|
|
|
|
|
|
|
sub ssuck(@); |
|
96
|
|
|
|
|
|
|
sub ssuck(@){ |
|
97
|
0
|
0
|
|
0
|
0
|
0
|
warn "useless ssuck in void context" unless defined wantarray; |
|
98
|
0
|
0
|
|
|
|
0
|
return join("",ssuck(@_)) unless wantarray; |
|
99
|
0
|
|
|
|
|
0
|
map { local $_="<$_"; sopen(local *F,$_); $_=[]; sclose(*F);@$_; } @_; |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
100
|
|
|
|
|
|
|
}; |
|
101
|
|
|
|
|
|
|
sub ssymlink($$) { |
|
102
|
3
|
|
|
3
|
0
|
1917
|
_checktrue(symlink($_[0],$_[1]),"symlink:$_[0],$_[1]:$!"); |
|
103
|
|
|
|
|
|
|
}; |
|
104
|
|
|
|
|
|
|
sub sunlink(@) { |
|
105
|
2
|
100
|
|
2
|
0
|
70
|
unlink(@_) == @_ && return scalar(@_); |
|
106
|
1
|
|
|
|
|
3
|
for ( @_ ) { |
|
107
|
1
|
50
|
33
|
|
|
22
|
-l $_ || -e $_ || next; |
|
108
|
0
|
0
|
|
|
|
0
|
unlink($_) && next; |
|
109
|
0
|
|
|
|
|
0
|
_throw "unlink:$_:$!"; |
|
110
|
|
|
|
|
|
|
} |
|
111
|
1
|
|
|
|
|
5
|
return scalar(@_); |
|
112
|
|
|
|
|
|
|
}; |
|
113
|
|
|
|
|
|
|
{ |
|
114
|
4
|
|
|
4
|
|
34
|
no warnings 'once'; |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
229
|
|
|
115
|
|
|
|
|
|
|
eval join("",) unless caller; |
|
116
|
|
|
|
|
|
|
} |
|
117
|
|
|
|
|
|
|
1; |
|
118
|
|
|
|
|
|
|
__DATA__ |