line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Filesys::Virtual; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
########################################################################### |
4
|
|
|
|
|
|
|
### Filesys::Virtual |
5
|
|
|
|
|
|
|
### L.M.Orchard (deus_x@ninjacode.com) |
6
|
|
|
|
|
|
|
### David Davis (xantus@cpan.org) |
7
|
|
|
|
|
|
|
### |
8
|
|
|
|
|
|
|
### Object oriented interface to a filesystem datasource |
9
|
|
|
|
|
|
|
### |
10
|
|
|
|
|
|
|
### Copyright (c) 2001 Leslie Michael Orchard. All Rights Reserved. |
11
|
|
|
|
|
|
|
### This module is free software; you can redistribute it and/or |
12
|
|
|
|
|
|
|
### modify it under the same terms as Perl itself. |
13
|
|
|
|
|
|
|
### |
14
|
|
|
|
|
|
|
### Changes Copyright (c) 2003-2005 David Davis and Teknikill Software |
15
|
|
|
|
|
|
|
########################################################################### |
16
|
|
|
|
|
|
|
|
17
|
1
|
|
|
1
|
|
685
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
49
|
|
18
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
91
|
|
19
|
1
|
|
|
1
|
|
1054
|
use IO::File; |
|
1
|
|
|
|
|
11958
|
|
|
1
|
|
|
|
|
853
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
our $VERSION = '0.06'; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# login: exactly that |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub login { |
26
|
0
|
|
|
0
|
0
|
|
my ($self, $username, $password) = @_; |
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
carp ref($self)."::login() Unimplemented"; |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
return 0; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# size: get a file's size |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub size { |
36
|
0
|
|
|
0
|
0
|
|
my ($self, $mode, $fn) = @_; |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
carp ref($self)."::size() Unimplemented"; |
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
return 0; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# chmod: Change a file's mode |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub chmod { |
46
|
0
|
|
|
0
|
0
|
|
my ($self, $mode, $fn) = @_; |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
carp ref($self)."::chmod() Unimplemented"; |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
return 0; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# modtime: Return the modification time for a given file |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub modtime { |
56
|
0
|
|
|
0
|
0
|
|
my ($self, $fn) = @_; |
57
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
carp ref($self)."::modtime() Unimplemented"; |
59
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
return 0; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# delete: Delete a given file |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub delete { |
66
|
0
|
|
|
0
|
0
|
|
my ($self, $fn) = @_; |
67
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
carp ref($self)."::delete() Unimplemented"; |
69
|
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
return 0; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
# cwd: |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub cwd { |
76
|
0
|
|
|
0
|
0
|
|
my ($self, $cwd) = @_; |
77
|
|
|
|
|
|
|
|
78
|
0
|
|
|
|
|
|
carp ref($self)."::cwd() Unimplemented"; |
79
|
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
|
return 0; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
# chdir: Change the cwd to a new path |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub chdir { |
86
|
0
|
|
|
0
|
0
|
|
my ($self, $dir) = @_; |
87
|
|
|
|
|
|
|
|
88
|
0
|
|
|
|
|
|
carp ref($self)."::chdir() Unimplemented"; |
89
|
|
|
|
|
|
|
|
90
|
0
|
|
|
|
|
|
return 0; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
# mkdir: Create a new directory |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub mkdir { |
96
|
0
|
|
|
0
|
0
|
|
my ($self, $dir) = @_; |
97
|
|
|
|
|
|
|
|
98
|
0
|
|
|
|
|
|
carp ref($self)."::mkdir() Unimplemented"; |
99
|
|
|
|
|
|
|
|
100
|
0
|
|
|
|
|
|
return 0; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
# rmdir: Remove a directory or file |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub rmdir { |
106
|
0
|
|
|
0
|
0
|
|
my ($self, $dir) = @_; |
107
|
|
|
|
|
|
|
|
108
|
0
|
|
|
|
|
|
carp ref($self)."::rmdir() Unimplemented"; |
109
|
|
|
|
|
|
|
|
110
|
0
|
|
|
|
|
|
return 0; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
# list: List files in a path. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub list { |
116
|
0
|
|
|
0
|
0
|
|
my ($self, $dirfile) = @_; |
117
|
|
|
|
|
|
|
|
118
|
0
|
|
|
|
|
|
carp ref($self)."::list() Unimplemented"; |
119
|
|
|
|
|
|
|
|
120
|
0
|
|
|
|
|
|
return undef; |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
# list_details: List files in a path, in full ls -al format. |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
sub list_details { |
126
|
0
|
|
|
0
|
0
|
|
my ($self, $dirfile) = @_; |
127
|
|
|
|
|
|
|
|
128
|
0
|
|
|
|
|
|
carp ref($self)."::list_details() Unimplemented"; |
129
|
|
|
|
|
|
|
|
130
|
0
|
|
|
|
|
|
return undef; |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
# stat: Perform a stat on a given file |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
sub stat { |
136
|
0
|
|
|
0
|
0
|
|
my ($self, $fn) = @_; |
137
|
|
|
|
|
|
|
|
138
|
0
|
|
|
|
|
|
carp ref($self)."::stat() Unimplemented"; |
139
|
|
|
|
|
|
|
|
140
|
0
|
|
|
|
|
|
return undef; |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
# test: Perform a given filesystem test |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
# -r File is readable by effective uid/gid. |
146
|
|
|
|
|
|
|
# -w File is writable by effective uid/gid. |
147
|
|
|
|
|
|
|
# -x File is executable by effective uid/gid. |
148
|
|
|
|
|
|
|
# -o File is owned by effective uid. |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
# -R File is readable by real uid/gid. |
151
|
|
|
|
|
|
|
# -W File is writable by real uid/gid. |
152
|
|
|
|
|
|
|
# -X File is executable by real uid/gid. |
153
|
|
|
|
|
|
|
# -O File is owned by real uid. |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
# -e File exists. |
156
|
|
|
|
|
|
|
# -z File has zero size. |
157
|
|
|
|
|
|
|
# -s File has nonzero size (returns size). |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
# -f File is a plain file. |
160
|
|
|
|
|
|
|
# -d File is a directory. |
161
|
|
|
|
|
|
|
# -l File is a symbolic link. |
162
|
|
|
|
|
|
|
# -p File is a named pipe (FIFO), or Filehandle is a pipe. |
163
|
|
|
|
|
|
|
# -S File is a socket. |
164
|
|
|
|
|
|
|
# -b File is a block special file. |
165
|
|
|
|
|
|
|
# -c File is a character special file. |
166
|
|
|
|
|
|
|
# -t Filehandle is opened to a tty. |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
# -u File has setuid bit set. |
169
|
|
|
|
|
|
|
# -g File has setgid bit set. |
170
|
|
|
|
|
|
|
# -k File has sticky bit set. |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
# -T File is a text file. |
173
|
|
|
|
|
|
|
# -B File is a binary file (opposite of -T). |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
# -M Age of file in days when script started. |
176
|
|
|
|
|
|
|
# -A Same for access time. |
177
|
|
|
|
|
|
|
# -C Same for inode change time. |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
sub test { |
180
|
0
|
|
|
0
|
0
|
|
my ($self, $test, $fn) = @_; |
181
|
|
|
|
|
|
|
|
182
|
0
|
|
|
|
|
|
carp ref($self)."::test() Unimplemented"; |
183
|
|
|
|
|
|
|
|
184
|
0
|
|
|
|
|
|
return undef; |
185
|
|
|
|
|
|
|
} |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
# open_read |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
sub open_read { |
190
|
0
|
|
|
0
|
0
|
|
my ($self, $fin, $create) = @_; |
191
|
|
|
|
|
|
|
|
192
|
0
|
|
|
|
|
|
carp ref($self)."::open_read() Unimplemented"; |
193
|
|
|
|
|
|
|
|
194
|
0
|
|
|
|
|
|
return undef; |
195
|
|
|
|
|
|
|
} |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
# close_read |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
sub close_read { |
200
|
0
|
|
|
0
|
0
|
|
my ($self, $fh) = @_; |
201
|
|
|
|
|
|
|
|
202
|
0
|
|
|
|
|
|
carp ref($self)."::close_read() Unimplemented"; |
203
|
|
|
|
|
|
|
|
204
|
0
|
|
|
|
|
|
return undef; |
205
|
|
|
|
|
|
|
} |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
# open_write |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
sub open_write { |
210
|
0
|
|
|
0
|
0
|
|
my ($self, $fin, $append) = @_; |
211
|
|
|
|
|
|
|
|
212
|
0
|
|
|
|
|
|
carp ref($self)."::open_write() Unimplemented"; |
213
|
|
|
|
|
|
|
|
214
|
0
|
|
|
|
|
|
return undef; |
215
|
|
|
|
|
|
|
} |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
# close_write |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
sub close_write { |
220
|
0
|
|
|
0
|
0
|
|
my ($self, $fh) = @_; |
221
|
|
|
|
|
|
|
|
222
|
0
|
|
|
|
|
|
carp ref($self)."::close_write() Unimplemented"; |
223
|
|
|
|
|
|
|
|
224
|
0
|
|
|
|
|
|
return undef; |
225
|
|
|
|
|
|
|
} |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
# seek: seek, if supported by filesystem... |
228
|
|
|
|
|
|
|
# ie $fh is a filehandle |
229
|
|
|
|
|
|
|
# $fh->seek($first, $second); |
230
|
|
|
|
|
|
|
# see the module Filehandle |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
sub seek { |
233
|
0
|
|
|
0
|
0
|
|
my ($self, $fh, $first, $second) = @_; |
234
|
|
|
|
|
|
|
|
235
|
0
|
|
|
|
|
|
carp ref($self)."::seek() Unimplemented"; |
236
|
|
|
|
|
|
|
|
237
|
0
|
|
|
|
|
|
return undef; |
238
|
|
|
|
|
|
|
} |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
# utime: modify access time and mod time |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
sub utime { |
243
|
0
|
|
|
0
|
0
|
|
my ($self, $atime, $mtime, @fn) = @_; |
244
|
|
|
|
|
|
|
|
245
|
0
|
|
|
|
|
|
carp ref($self)."::utime() Unimplemented"; |
246
|
|
|
|
|
|
|
|
247
|
0
|
|
|
|
|
|
return undef; |
248
|
|
|
|
|
|
|
} |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
1; |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
__END__ |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
=head1 NAME |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
Filesys::Virtual - Perl extension to provide a framework for a virtual filesystem |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
=head1 SYNOPSIS |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
use Filesys::Virtual; |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
=head1 DESCRIPTION |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
This is a base class. See L<SEE ALSO> below. |
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
=head2 EXPORT |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
None by default. |
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
=head2 TODO |
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
Please contact David if you have any suggestions. |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
=head1 AUTHORS |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
David Davis, E<lt>xantus@cpan.orgE<gt>, http://teknikill.net/ |
277
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
L.M.Orchard, E<lt>deus_x@pobox.comE<gt> |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
=head1 LICENSE |
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
283
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
284
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
=head1 SEE ALSO |
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
perl(1), L<Filesys::Virtual>, L<Filesys::Virtual::SSH>, |
288
|
|
|
|
|
|
|
L<Filesys::Virtual::DAAP>, L<POE::Component::Server::FTP>, |
289
|
|
|
|
|
|
|
L<Net::DAV::Server>, L<HTTP::Daemon>, |
290
|
|
|
|
|
|
|
http://perladvent.org/2004/20th/ |
291
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
=cut |