| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# SMB-Perl library, Copyright (C) 2014 Mikhael Goikhman, migo@cpan.org |
|
2
|
|
|
|
|
|
|
# |
|
3
|
|
|
|
|
|
|
# This program is free software: you can redistribute it and/or modify |
|
4
|
|
|
|
|
|
|
# it under the terms of the GNU General Public License as published by |
|
5
|
|
|
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or |
|
6
|
|
|
|
|
|
|
# (at your option) any later version. |
|
7
|
|
|
|
|
|
|
# |
|
8
|
|
|
|
|
|
|
# This program is distributed in the hope that it will be useful, |
|
9
|
|
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10
|
|
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11
|
|
|
|
|
|
|
# GNU General Public License for more details. |
|
12
|
|
|
|
|
|
|
# |
|
13
|
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License |
|
14
|
|
|
|
|
|
|
# along with this program. If not, see . |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
package SMB::OpenFile; |
|
17
|
|
|
|
|
|
|
|
|
18
|
3
|
|
|
3
|
|
25
|
use strict; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
98
|
|
|
19
|
3
|
|
|
3
|
|
14
|
use warnings; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
77
|
|
|
20
|
|
|
|
|
|
|
|
|
21
|
3
|
|
|
3
|
|
17
|
use parent 'SMB'; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
19
|
|
|
22
|
|
|
|
|
|
|
|
|
23
|
3
|
|
|
3
|
|
155
|
use Fcntl 'SEEK_SET'; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
164
|
|
|
24
|
3
|
|
|
3
|
|
604
|
use SMB::File; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
783
|
|
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub new ($$$$%) { |
|
27
|
17
|
|
|
17
|
1
|
40
|
my $class = shift; |
|
28
|
17
|
|
50
|
|
|
38
|
my $file = shift || die "No file\n"; |
|
29
|
17
|
|
50
|
|
|
41
|
my $handle = shift || 0; |
|
30
|
17
|
|
50
|
|
|
51
|
my $action = shift || SMB::File::ACTION_NONE; |
|
31
|
17
|
|
|
|
|
33
|
my %options = @_; |
|
32
|
|
|
|
|
|
|
|
|
33
|
17
|
|
|
|
|
78
|
my $self = $class->SUPER::new( |
|
34
|
|
|
|
|
|
|
file => $file, |
|
35
|
|
|
|
|
|
|
handle => $handle, |
|
36
|
|
|
|
|
|
|
action => $action, |
|
37
|
|
|
|
|
|
|
last_index => 0, |
|
38
|
|
|
|
|
|
|
%options, |
|
39
|
|
|
|
|
|
|
); |
|
40
|
|
|
|
|
|
|
|
|
41
|
17
|
|
|
|
|
47
|
return $self; |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub close ($) { |
|
45
|
17
|
|
|
17
|
0
|
10090
|
my $self = shift; |
|
46
|
|
|
|
|
|
|
|
|
47
|
17
|
|
|
|
|
66
|
$self->file->delete_openfile($self); |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub read ($%) { |
|
51
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
52
|
0
|
|
|
|
|
|
my %params = @_; # length offset minlen remain |
|
53
|
|
|
|
|
|
|
|
|
54
|
0
|
0
|
|
|
|
|
my $fh = $self->{handle} or return; |
|
55
|
0
|
0
|
0
|
|
|
|
sysseek($fh, $params{offset} || 0, SEEK_SET) or return; |
|
56
|
|
|
|
|
|
|
|
|
57
|
0
|
|
0
|
|
|
|
my $length = $params{length} // return; |
|
58
|
0
|
|
0
|
|
|
|
my $minlen = $params{minlen} || 0; |
|
59
|
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
my $buffer; |
|
61
|
0
|
|
0
|
|
|
|
sysread($fh, $buffer, $length) // return; |
|
62
|
0
|
0
|
|
|
|
|
return unless length($buffer) < $minlen; |
|
63
|
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
return $buffer; |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
1; |