line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Filesys::Virtual::Async; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
69705
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
41
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
34
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use Carp qw( croak ); |
|
1
|
|
|
|
|
14
|
|
|
1
|
|
|
|
|
1367
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new { |
11
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
12
|
0
|
|
0
|
|
|
|
bless( { |
13
|
|
|
|
|
|
|
cwd => '/', |
14
|
|
|
|
|
|
|
root => '/', |
15
|
|
|
|
|
|
|
@_ |
16
|
|
|
|
|
|
|
}, ref $class || $class ); |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub open { |
20
|
0
|
|
|
0
|
1
|
|
croak 'subclass didn\'t define open'; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub close { |
24
|
0
|
|
|
0
|
1
|
|
croak 'subclass didn\'t define close'; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub read { |
28
|
0
|
|
|
0
|
1
|
|
croak 'subclass didn\'t define read'; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub write { |
32
|
0
|
|
|
0
|
1
|
|
croak 'subclass didn\'t define write'; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub sendfile { |
36
|
0
|
|
|
0
|
1
|
|
croak 'subclass didn\'t define sendfile'; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub readahead { |
40
|
0
|
|
|
0
|
1
|
|
croak 'subclass didn\'t define readahead'; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub stat { |
44
|
0
|
|
|
0
|
1
|
|
croak 'subclass didn\'t define stat'; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub lstat { |
48
|
0
|
|
|
0
|
1
|
|
croak 'subclass didn\'t define lstat'; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub utime { |
52
|
0
|
|
|
0
|
1
|
|
croak 'subclass didn\'t define utime'; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub chown { |
56
|
0
|
|
|
0
|
1
|
|
croak 'subclass didn\'t define chown'; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub truncate { |
60
|
0
|
|
|
0
|
1
|
|
croak 'subclass didn\'t define truncate'; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub chmod { |
64
|
0
|
|
|
0
|
1
|
|
croak 'subclass didn\'t define chmod'; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub unlink { |
68
|
0
|
|
|
0
|
1
|
|
croak 'subclass didn\'t define unlink'; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub mknod { |
72
|
0
|
|
|
0
|
1
|
|
croak 'subclass didn\'t define mknod'; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub link { |
76
|
0
|
|
|
0
|
1
|
|
croak 'subclass didn\'t define link'; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub symlink { |
80
|
0
|
|
|
0
|
1
|
|
croak 'subclass didn\'t define symlink'; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub readlink { |
84
|
0
|
|
|
0
|
1
|
|
croak 'subclass didn\'t define readlink'; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub rename { |
88
|
0
|
|
|
0
|
1
|
|
croak 'subclass didn\'t define rename'; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub mkdir { |
92
|
0
|
|
|
0
|
1
|
|
croak 'subclass didn\'t define mkdir'; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub rmdir { |
96
|
0
|
|
|
0
|
1
|
|
croak 'subclass didn\'t define rmdir'; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub readdir { |
100
|
0
|
|
|
0
|
1
|
|
croak 'subclass didn\'t define readdir'; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub load { |
104
|
0
|
|
|
0
|
1
|
|
croak 'subclass didn\'t define load'; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub copy { |
108
|
0
|
|
|
0
|
1
|
|
croak 'subclass didn\'t define copy'; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub move { |
112
|
0
|
|
|
0
|
1
|
|
croak 'subclass didn\'t define move'; |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub scandir { |
116
|
0
|
|
|
0
|
1
|
|
croak 'subclass didn\'t define scandir'; |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub rmtree { |
120
|
0
|
|
|
0
|
1
|
|
croak 'subclass didn\'t define rmtree'; |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
sub fsync { |
124
|
0
|
|
|
0
|
1
|
|
croak 'subclass didn\'t define fsync'; |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
sub fdatasync { |
128
|
0
|
|
|
0
|
1
|
|
croak 'subclass didn\'t define fdatasync'; |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
sub cwd { |
132
|
0
|
|
|
0
|
1
|
|
my ( $self, $cwd, $callback ) = @_; |
133
|
|
|
|
|
|
|
|
134
|
0
|
0
|
0
|
|
|
|
return $callback->( $self->{cwd} = $cwd ) |
135
|
|
|
|
|
|
|
if ( defined $cwd && defined $callback ); |
136
|
|
|
|
|
|
|
|
137
|
0
|
0
|
|
|
|
|
return $self->{cwd} = ( $cwd ) ? $cwd : '/'; |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
sub root { |
141
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
142
|
|
|
|
|
|
|
|
143
|
0
|
0
|
|
|
|
|
if (@_) { |
144
|
0
|
|
|
|
|
|
my $root = shift; |
145
|
0
|
|
|
|
|
|
$root =~ s/\/$//; |
146
|
0
|
|
|
|
|
|
$self->{root} = $root; |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
|
149
|
0
|
|
|
|
|
|
return $self->{root}; |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
sub _path_from_root { |
153
|
0
|
|
|
0
|
|
|
my $self = shift; |
154
|
|
|
|
|
|
|
|
155
|
0
|
|
|
|
|
|
return $self->{root}.$self->_resolve_path(@_); |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
# resolve a path from the current path |
159
|
|
|
|
|
|
|
sub _resolve_path { |
160
|
0
|
|
|
0
|
|
|
my ( $self, $path ) = @_; |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
# could be a file handle, return it |
163
|
|
|
|
|
|
|
# XXX wth? |
164
|
0
|
0
|
|
|
|
|
return $path if ( ref $path ); |
165
|
|
|
|
|
|
|
|
166
|
0
|
|
0
|
|
|
|
$path ||= ''; |
167
|
|
|
|
|
|
|
|
168
|
0
|
|
|
|
|
|
my $cwd = $self->{cwd}; |
169
|
0
|
|
|
|
|
|
my $path_out = ''; |
170
|
|
|
|
|
|
|
|
171
|
0
|
0
|
|
|
|
|
if ($path eq '') { |
|
|
0
|
|
|
|
|
|
172
|
0
|
|
|
|
|
|
$path_out = $cwd; |
173
|
|
|
|
|
|
|
} elsif ($path eq '/') { |
174
|
0
|
|
|
|
|
|
$path_out = '/'; |
175
|
|
|
|
|
|
|
} else { |
176
|
0
|
|
|
|
|
|
my @real = split(/\//, $cwd); |
177
|
0
|
0
|
|
|
|
|
if ($path =~ m/^\//) { |
178
|
0
|
|
|
|
|
|
@real = (); |
179
|
|
|
|
|
|
|
} |
180
|
|
|
|
|
|
|
|
181
|
0
|
|
|
|
|
|
my @paths = split( /\//,$path ); |
182
|
|
|
|
|
|
|
|
183
|
0
|
0
|
0
|
|
|
|
if (@paths && $paths[0] eq '~' && $self->{home_path}) { |
|
|
|
0
|
|
|
|
|
184
|
0
|
|
|
|
|
|
@real = split(/\//, $self->{home_path}); |
185
|
0
|
|
|
|
|
|
shift @paths; |
186
|
|
|
|
|
|
|
} |
187
|
|
|
|
|
|
|
|
188
|
0
|
|
|
|
|
|
foreach (@paths) { |
189
|
0
|
0
|
|
|
|
|
if ($_ eq '..') { |
|
|
0
|
|
|
|
|
|
190
|
0
|
0
|
|
|
|
|
pop(@real) if ($#real); |
191
|
|
|
|
|
|
|
} elsif ($_ eq '.') { |
192
|
0
|
|
|
|
|
|
next; |
193
|
|
|
|
|
|
|
} else { |
194
|
0
|
|
|
|
|
|
push(@real, $_); |
195
|
|
|
|
|
|
|
} |
196
|
|
|
|
|
|
|
} |
197
|
0
|
|
|
|
|
|
$path_out = join('/', @real); |
198
|
|
|
|
|
|
|
} |
199
|
|
|
|
|
|
|
|
200
|
0
|
0
|
|
|
|
|
return (substr($path_out, 0, 1) eq '/') ? $path_out : '/'.$path_out; |
201
|
|
|
|
|
|
|
} |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
1; |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
__END__ |