| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# -*- perl -*- |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Net::FTPServer A Perl FTP Server |
|
4
|
|
|
|
|
|
|
# Copyright (C) 2000 Bibliotech Ltd., Unit 2-3, 50 Carnwath Road, |
|
5
|
|
|
|
|
|
|
# London, SW6 3EG, United Kingdom. |
|
6
|
|
|
|
|
|
|
# |
|
7
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or modify |
|
8
|
|
|
|
|
|
|
# it under the terms of the GNU General Public License as published by |
|
9
|
|
|
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or |
|
10
|
|
|
|
|
|
|
# (at your option) any later version. |
|
11
|
|
|
|
|
|
|
# |
|
12
|
|
|
|
|
|
|
# This program is distributed in the hope that it will be useful, |
|
13
|
|
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14
|
|
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15
|
|
|
|
|
|
|
# GNU General Public License for more details. |
|
16
|
|
|
|
|
|
|
# |
|
17
|
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License |
|
18
|
|
|
|
|
|
|
# along with this program; if not, write to the Free Software |
|
19
|
|
|
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=pod |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 NAME |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
Net::FTPServer::Handle - A generic Net::FTPServer file or directory handle. |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
use Net::FTPServer::Handle; |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 METHODS |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=cut |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
package Net::FTPServer::Handle; |
|
36
|
|
|
|
|
|
|
|
|
37
|
75
|
|
|
75
|
|
439
|
use strict; |
|
|
75
|
|
|
|
|
133
|
|
|
|
75
|
|
|
|
|
2161
|
|
|
38
|
|
|
|
|
|
|
|
|
39
|
75
|
|
|
75
|
|
370
|
use vars qw($VERSION); |
|
|
75
|
|
|
|
|
148
|
|
|
|
75
|
|
|
|
|
20713
|
|
|
40
|
|
|
|
|
|
|
( $VERSION ) = '$Revision: 1.1 $ ' =~ /\$Revision:\s+([^\s]+)/; |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=pod |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=over 4 |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=item $handle = Net::FTPServer::Handle->new ($ftps); |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
Create a new handle. You would normally call this from |
|
49
|
|
|
|
|
|
|
a derived class. |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=cut |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub new |
|
54
|
|
|
|
|
|
|
{ |
|
55
|
205
|
|
|
205
|
1
|
369
|
my $class = shift; |
|
56
|
205
|
|
|
|
|
316
|
my $ftps = shift; |
|
57
|
|
|
|
|
|
|
|
|
58
|
205
|
|
|
|
|
628
|
my $self = { ftps => $ftps }; |
|
59
|
|
|
|
|
|
|
|
|
60
|
205
|
|
|
|
|
648
|
return bless $self, $class; |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=pod |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=item $rv = $handle->equals ($other_handle); |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Decide if two handles refer to the same thing (file or directory). |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=cut |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub equals |
|
72
|
|
|
|
|
|
|
{ |
|
73
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
|
74
|
0
|
|
|
|
|
0
|
my $other = shift; |
|
75
|
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
0
|
return $self->{_pathname} eq $other->{_pathname}; |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=pod |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=item ($mode, $perms, $nlink, $user, $group, $size, $time) = $handle->status; |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Return the file or directory status. The fields returned are: |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
$mode Mode 'd' = directory, |
|
86
|
|
|
|
|
|
|
'f' = file, |
|
87
|
|
|
|
|
|
|
and others as with |
|
88
|
|
|
|
|
|
|
the find(1) -type option. |
|
89
|
|
|
|
|
|
|
$perms Permissions Permissions in normal octal numeric format. |
|
90
|
|
|
|
|
|
|
$nlink Link count |
|
91
|
|
|
|
|
|
|
$user Username In printable format. |
|
92
|
|
|
|
|
|
|
$group Group name In printable format. |
|
93
|
|
|
|
|
|
|
$size Size File size in bytes. |
|
94
|
|
|
|
|
|
|
$time Time Time (usually mtime) in Unix time_t format. |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
In derived classes, some of this status information may well be |
|
97
|
|
|
|
|
|
|
synthesized, since virtual filesystems will often not contain |
|
98
|
|
|
|
|
|
|
information in a Unix-like format. |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=cut |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub status |
|
103
|
|
|
|
|
|
|
{ |
|
104
|
0
|
|
|
0
|
1
|
0
|
die "virtual function"; |
|
105
|
|
|
|
|
|
|
} |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=pod |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=item $name = $handle->pathname; |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Return the full path of this file or directory. The path consists of |
|
112
|
|
|
|
|
|
|
all components separated by "/" characters. |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
If the object is a directory, then the pathname will have |
|
115
|
|
|
|
|
|
|
a "/" character at the end. |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=cut |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub pathname |
|
120
|
|
|
|
|
|
|
{ |
|
121
|
451
|
|
|
451
|
1
|
735
|
my $self = shift; |
|
122
|
|
|
|
|
|
|
|
|
123
|
451
|
|
|
|
|
2408
|
return $self->{_pathname}; |
|
124
|
|
|
|
|
|
|
} |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=pod |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=item $name = $handle->filename; |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Return the filename part of the path. If the file is a directory, |
|
131
|
|
|
|
|
|
|
then this function returns "". |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=cut |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
sub filename |
|
136
|
|
|
|
|
|
|
{ |
|
137
|
8
|
|
|
8
|
1
|
16
|
my $self = shift; |
|
138
|
|
|
|
|
|
|
|
|
139
|
8
|
|
|
|
|
61
|
$self->{_pathname} =~ m,/([^/]*)$,; |
|
140
|
8
|
|
|
|
|
34
|
return $1; |
|
141
|
|
|
|
|
|
|
} |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=pod |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=item $name = $handle->dirname; |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
Return the directory name part of the path. The directory name |
|
148
|
|
|
|
|
|
|
always has a trailing "/" character. |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=cut |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
sub dirname |
|
153
|
|
|
|
|
|
|
{ |
|
154
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
155
|
|
|
|
|
|
|
|
|
156
|
0
|
|
|
|
|
|
$self->{_pathname} =~ m,^(.*/)([^/]*)$,; |
|
157
|
0
|
|
|
|
|
|
return $1; |
|
158
|
|
|
|
|
|
|
} |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=pod |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=item $rv = $handle->move ($dirh, $filename); |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
Move the current file (or directory) into directory C<$dirh> and |
|
165
|
|
|
|
|
|
|
call it C<$filename>. If the operation is successful, return 0, |
|
166
|
|
|
|
|
|
|
else return -1. |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
Underlying filesystems may impose limitations on moves: for example, |
|
169
|
|
|
|
|
|
|
it may not be possible to move a directory; it may not be possible |
|
170
|
|
|
|
|
|
|
to move a file to another directory; it may not be possible to |
|
171
|
|
|
|
|
|
|
move a file across filesystems. |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=cut |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
sub move |
|
176
|
|
|
|
|
|
|
{ |
|
177
|
0
|
|
|
0
|
1
|
|
die "virtual function"; |
|
178
|
|
|
|
|
|
|
} |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=item $rv = $handle->delete; |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
Delete the current file or directory. If the delete command was |
|
183
|
|
|
|
|
|
|
successful, then return 0, else if there was an error return -1. |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
Different underlying file systems may impose restrictions on |
|
186
|
|
|
|
|
|
|
this command: for example, it may not be possible to delete |
|
187
|
|
|
|
|
|
|
directories, or only if they are empty. |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
This is a virtual function which is actually implemented in |
|
190
|
|
|
|
|
|
|
one of the subclasses. |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=cut |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
sub delete |
|
195
|
|
|
|
|
|
|
{ |
|
196
|
0
|
|
|
0
|
1
|
|
die "virtual function"; |
|
197
|
|
|
|
|
|
|
} |
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
1 # So that the require or use succeeds. |
|
200
|
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
__END__ |