lib/SMB/OpenFile.pm

filter: Statementstmt 71.4% 25 / 35 Branchbran 0.0% 0 / 6 Conditioncond 21.4% 3 / 14 MC/DCmcdc 0.0% 0 / 7 Subroutinesub 87.5% 7 / 8 Podpod 33.3% 1 / 3 totaltotal 49.3% 36 / 73 SCAR 32.3
CC
11
Cov
51%
read
72.0
new
4.2
BEGIN
1.0
CRAP 25.3
« blib/lib/SMB/v2/Command/SessionSetup.pm ↑ Summary lib/SMB/Packer.pm »
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 <http://www.gnu.org/licenses/>.
15  
16 package SMB::OpenFile;
17  
18 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 3 ▶use parent 'SMB';
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 3 ▶use Fcntl 'SEEK_SET';
Subroutine BEGIN: called CC=1 SCAR=0.0
24 3 ▶use SMB::File;
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 sub new ($$$$%) {
27 17 ▶ my $class = shift;
Subroutine new: called CC=4 SCAR=14.3
Pod documented
28 17 ▶ my $file = shift || die "No file\n";
Condition50%1/2
shift() || die("No file\n")
l!l
170
MC/DC0%0/1
shift() || die("No file\n")
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
29 17 ▶ my $handle = shift || 0;
Condition50%1/2
shift() || 0
l!l
170
MC/DC0%0/1
shift() || 0
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
30 17 ▶ my $action = shift || SMB::File::ACTION_NONE;
Condition50%1/2
shift() || -1
l!l
170
MC/DC0%0/1
shift() || -1
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
31 17 my %options = @_;
32  
33 17 my $self = $class->SUPER::new(
34 file => $file,
35 handle => $handle,
36 action => $action,
37 last_index => 0,
38 %options,
39 );
40  
41 17 return $self;
42 }
43  
44 sub close ($) {
45 17 ▶ my $self = shift;
Subroutine close: called CC=1 SCAR=0.0
Pod undocumented
46  
47 17 $self->file->delete_openfile($self);
48 }
49  
50 sub read ($%) {
51 0 ▶ my $self = shift;
Subroutine read: not called CC=8 SCAR=42.8
Pod undocumented
52 0 my %params = @_; # length offset minlen remain
53  
54 0 ▶ my $fh = $self->{handle} or return;
Branch: 1 branch
BranchTrueFalseTotal
my $fh = $self->{"handle"} or return 0 0 0
55 0 ▶ sysseek($fh, $params{offset} || 0, SEEK_SET) or return;
Branch: 1 branch
BranchTrueFalseTotal
sysseek $fh, $params{"offset"} || 0, 0 or return 0 0 0
Condition0%0/2
$params{'offset'} || 0
l!l
00
MC/DC0%0/1
$params{'offset'} || 0
$params{'offset'}
Truth table0%0/2
A
A= $params{'offset'}
Aresult
11
00
56  
57 0 ▶ my $length = $params{length} // return;
Condition0%0/2
$params{"length"} // (return)
l!l
00
MC/DC0%0/1
$params{"length"} // (return)
$params{"length"}
Truth table0%0/2
A
A= $params{"length"}
Aresult
11
00
58 0 ▶ my $minlen = $params{minlen} || 0;
Condition0%0/2
$params{'minlen'} || 0
l!l
00
MC/DC0%0/1
$params{'minlen'} || 0
$params{'minlen'}
Truth table0%0/2
A
A= $params{'minlen'}
Aresult
11
00
59  
60 0 my $buffer;
61 0 ▶ sysread($fh, $buffer, $length) // return;
Condition0%0/2
sysread($fh, $buffer, $length) // (return)
l!l
00
MC/DC0%0/1
sysread($fh, $buffer, $length) // (return)
sysread($fh, $buffer, $length)
Truth table0%0/2
A
A= sysread($fh, $buffer, $length)
Aresult
11
00
62 0 ▶ return unless length($buffer) < $minlen;
Branch: 1 branch
BranchTrueFalseTotal
unless length $buffer < $minlen 0 0 0
63  
64 0 return $buffer;
65 }
66  
67 3 1;
« blib/lib/SMB/v2/Command/SessionSetup.pm ↑ Summary lib/SMB/Packer.pm »