line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
56
|
|
|
56
|
|
371
|
use strict; use warnings; |
|
56
|
|
|
56
|
|
138
|
|
|
56
|
|
|
|
|
1436
|
|
|
56
|
|
|
|
|
300
|
|
|
56
|
|
|
|
|
129
|
|
|
56
|
|
|
|
|
2125
|
|
2
|
|
|
|
|
|
|
package IO::All::Filesys; |
3
|
|
|
|
|
|
|
|
4
|
56
|
|
|
56
|
|
331
|
use IO::All::Base -base; |
|
56
|
|
|
|
|
125
|
|
|
56
|
|
|
|
|
472
|
|
5
|
56
|
|
|
56
|
|
372
|
use Fcntl qw(:flock); |
|
56
|
|
|
|
|
162
|
|
|
56
|
|
|
|
|
21921
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
my %spec_map = ( |
8
|
|
|
|
|
|
|
unix => 'Unix', |
9
|
|
|
|
|
|
|
win32 => 'Win32', |
10
|
|
|
|
|
|
|
vms => 'VMS', |
11
|
|
|
|
|
|
|
mac => 'Mac', |
12
|
|
|
|
|
|
|
os2 => 'OS2', |
13
|
|
|
|
|
|
|
); |
14
|
|
|
|
|
|
|
sub os { |
15
|
23
|
|
|
23
|
0
|
57
|
my ($self, $type) = @_; |
16
|
|
|
|
|
|
|
|
17
|
23
|
|
|
|
|
67
|
my ($v, $d, $f) = $self->_spec_class->splitpath($self->name); |
18
|
23
|
|
|
|
|
182
|
my @d = $self->_spec_class->splitdir($d); |
19
|
|
|
|
|
|
|
|
20
|
23
|
|
|
|
|
164
|
$self->_spec_class($spec_map{$type}); |
21
|
|
|
|
|
|
|
|
22
|
23
|
|
|
|
|
64
|
$self->name( $self->_spec_class->catfile( @d, $f ) ); |
23
|
|
|
|
|
|
|
|
24
|
23
|
|
|
|
|
99
|
return $self |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
0
|
|
|
0
|
0
|
0
|
sub exists { my $self = shift; -e $self->name } |
|
0
|
|
|
|
|
0
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub filename { |
30
|
12
|
|
|
12
|
0
|
24
|
my $self = shift; |
31
|
12
|
|
|
|
|
20
|
my $filename; |
32
|
12
|
|
|
|
|
67
|
(undef, undef, $filename) = $self->splitpath; |
33
|
12
|
|
|
|
|
115
|
return $filename; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub ext { |
37
|
2
|
|
|
2
|
0
|
6
|
my $self = shift; |
38
|
|
|
|
|
|
|
|
39
|
2
|
50
|
|
|
|
10
|
return $1 if $self->filename =~ m/\.([^\.]+)$/ |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
{ |
42
|
56
|
|
|
56
|
|
447
|
no warnings 'once'; |
|
56
|
|
|
|
|
136
|
|
|
56
|
|
|
|
|
12644
|
|
43
|
|
|
|
|
|
|
*extension = \&ext; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub mimetype { |
47
|
0
|
|
|
0
|
0
|
0
|
require File::MimeInfo; |
48
|
0
|
|
|
|
|
0
|
return File::MimeInfo::mimetype($_[0]->filename) |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub is_absolute { |
52
|
372
|
|
|
372
|
0
|
749
|
my $self = shift; |
53
|
372
|
100
|
|
|
|
1001
|
return *$self->{is_absolute} = shift if @_; |
54
|
|
|
|
|
|
|
return *$self->{is_absolute} |
55
|
355
|
100
|
|
|
|
1594
|
if defined *$self->{is_absolute}; |
56
|
151
|
100
|
|
|
|
449
|
*$self->{is_absolute} = IO::All::is_absolute($self) ? 1 : 0; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
0
|
0
|
0
|
sub is_executable { my $self = shift; -x $self->name } |
|
0
|
|
|
|
|
0
|
|
60
|
0
|
|
|
0
|
0
|
0
|
sub is_readable { my $self = shift; -r $self->name } |
|
0
|
|
|
|
|
0
|
|
61
|
0
|
|
|
0
|
0
|
0
|
sub is_writable { my $self = shift; -w $self->name } |
|
0
|
|
|
|
|
0
|
|
62
|
|
|
|
|
|
|
{ |
63
|
56
|
|
|
56
|
|
404
|
no warnings 'once'; |
|
56
|
|
|
|
|
141
|
|
|
56
|
|
|
|
|
26009
|
|
64
|
|
|
|
|
|
|
*is_writeable = \&is_writable; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub pathname { |
68
|
3752
|
|
|
3752
|
0
|
6622
|
my $self = shift; |
69
|
3752
|
100
|
|
|
|
8974
|
return *$self->{pathname} = shift if @_; |
70
|
3745
|
100
|
|
|
|
11650
|
return *$self->{pathname} if defined *$self->{pathname}; |
71
|
3736
|
|
|
|
|
9467
|
return $self->name; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub relative { |
75
|
2
|
|
|
2
|
0
|
6
|
my $self = shift; |
76
|
2
|
100
|
|
|
|
7
|
if (my $base = $_[0]) { |
|
|
50
|
|
|
|
|
|
77
|
1
|
|
|
|
|
4
|
$self->pathname(File::Spec->abs2rel($self->pathname, $base)) |
78
|
|
|
|
|
|
|
} elsif ($self->is_absolute) { |
79
|
1
|
|
|
|
|
4
|
$self->pathname(File::Spec->abs2rel($self->pathname)) |
80
|
|
|
|
|
|
|
} |
81
|
2
|
|
|
|
|
7
|
$self->is_absolute(0); |
82
|
2
|
|
|
|
|
9
|
return $self; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub rename { |
86
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
87
|
0
|
|
|
|
|
0
|
my $new = shift; |
88
|
0
|
0
|
|
|
|
0
|
rename($self->name, "$new") |
|
|
0
|
|
|
|
|
|
89
|
|
|
|
|
|
|
? UNIVERSAL::isa($new, 'IO::All') |
90
|
|
|
|
|
|
|
? $new |
91
|
|
|
|
|
|
|
: $self->_constructor->($new) |
92
|
|
|
|
|
|
|
: undef; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub set_lock { |
96
|
115
|
|
|
115
|
0
|
283
|
my $self = shift; |
97
|
115
|
100
|
|
|
|
580
|
return unless $self->_lock; |
98
|
3
|
|
|
|
|
18
|
my $io_handle = $self->io_handle; |
99
|
3
|
100
|
|
|
|
13
|
my $flag = $self->mode =~ /^>>?$/ |
100
|
|
|
|
|
|
|
? LOCK_EX |
101
|
|
|
|
|
|
|
: LOCK_SH; |
102
|
3
|
|
|
|
|
998287
|
flock $io_handle, $flag; |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub stat { |
106
|
1
|
|
|
1
|
0
|
2
|
my $self = shift; |
107
|
1
|
50
|
|
|
|
4
|
return IO::All::stat($self, @_) |
108
|
|
|
|
|
|
|
if $self->is_open; |
109
|
1
|
|
|
|
|
3
|
CORE::stat($self->pathname); |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub touch { |
113
|
1
|
|
|
1
|
0
|
4
|
my $self = shift; |
114
|
1
|
|
|
|
|
6
|
$self->utime; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub unlock { |
118
|
121
|
|
|
121
|
0
|
309
|
my $self = shift; |
119
|
121
|
100
|
|
|
|
426
|
flock $self->io_handle, LOCK_UN |
120
|
|
|
|
|
|
|
if $self->_lock; |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
sub utime { |
124
|
1
|
|
|
1
|
0
|
2
|
my $self = shift; |
125
|
1
|
|
|
|
|
3
|
my $atime = shift; |
126
|
1
|
|
|
|
|
2
|
my $mtime = shift; |
127
|
1
|
50
|
|
|
|
12
|
$atime = time unless defined $atime; |
128
|
1
|
50
|
|
|
|
5
|
$mtime = $atime unless defined $mtime; |
129
|
1
|
|
|
|
|
3
|
utime($atime, $mtime, $self->name); |
130
|
1
|
|
|
|
|
7
|
return $self; |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
1; |