lib/SMB/v2/Command/Close.pm

filter: Statementstmt 35.1% 13 / 37 Branchbran 0.0% 0 / 22 Conditioncond 0.0% 0 / 11 MC/DCmcdc 0.0% 0 / 7 Subroutinesub 57.1% 4 / 7 Podpod 0.0% 0 / 3 totaltotal 19.5% 17 / 87 SCAR 50.4
CC
16
Cov
19%
pack
182.0
parse
20.0
init
2.0
CRAP 154.2
« blib/lib/SMB/v2/Command/QueryDirectory.pm ↑ Summary lib/SMB/File.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::v2::Command::Close;
17  
18 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 1 ▶use parent 'SMB::v2::Command';
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 use constant {
24 1 FLAGS_POSTQUERY_ATTRIB => 1,
25 1 ▶};
Subroutine BEGIN: called CC=1 SCAR=0.0
26  
27 sub init ($) {
28 0 ▶ $_[0]->set(
Subroutine init: not called CC=1 SCAR=6.9
Pod undocumented
29 flags => 0,
30 fid => 0,
31 openfile => undef,
32 )
33 }
34  
35 sub parse ($$) {
36 0 ▶ my $self = shift;
Subroutine parse: not called CC=4 SCAR=30.0
Pod undocumented
37 0 my $parser = shift;
38  
39 0 ▶ if ($self->is_response) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->is_response) { } 0 0 0
40 0 my $openfile = $self->openfile;
41 0 ▶ my $file = $openfile && $openfile->file;
Condition0%0/3
$openfile && $openfile->file
!ll&&!rl&&r
000
MC/DC0%0/2
$openfile && $openfile->file
$openfile $openfile->file
Truth table0%0/3
A && B
A= $openfileB= $openfile->file
ABresult
0X0
100
111
42  
43 0 $self->flags($parser->uint16);
44 0 $parser->uint32; # reserved
45 0 my @values = ((map { $parser->uint64 } 1 .. 6), $parser->uint32);
46 0 ▶ $file->update(@values) if $file;
Branch: 1 branch
BranchTrueFalseTotal
if $file 0 0 0
47 } else {
48 0 $self->flags($parser->uint16);
49 0 $parser->uint32; # reserved
50 0 $self->fid($parser->fid2);
51 }
52  
53 0 return $self;
54 }
55  
56 sub pack ($$) {
57 0 ▶ my $self = shift;
Subroutine pack: not called CC=13 SCAR=52.0
Pod undocumented
58 0 my $packer = shift;
59  
60 0 ▶ if ($self->is_response) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->is_response) { } 0 0 0
61 0 my $openfile = $self->openfile;
62 0 ▶ my $file = $openfile && $openfile->file;
Condition0%0/3
$openfile && $openfile->file
!ll&&!rl&&r
000
MC/DC0%0/2
$openfile && $openfile->file
$openfile $openfile->file
Truth table0%0/3
A && B
A= $openfileB= $openfile->file
ABresult
0X0
100
111
63  
64 0 ▶ return $self->abort_pack($packer, SMB::STATUS_FILE_CLOSED)
Branch: 1 branch
BranchTrueFalseTotal
unless $file and $file->exists 0 0 0
Condition0%0/3
$file and $file->exists
!ll&&!rl&&r
000
MC/DC0%0/2
$file and $file->exists
$file $file->exists
Truth table0%0/3
A and B
A= $fileB= $file->exists
ABresult
0X0
100
111
65 unless $file && $file->exists;
66  
67 0 my $skip_attr = !($self->flags & FLAGS_POSTQUERY_ATTRIB);
68  
69 0 ▶ $packer
Branch: 7 branches
BranchTrueFalseTotal
$skip_attr ? : 0 0 0
$skip_attr ? : 0 0 0
$skip_attr ? : 0 0 0
$skip_attr ? : 0 0 0
$skip_attr ? : 0 0 0
$skip_attr ? : 0 0 0
$skip_attr ? : 0 0 0
70 ->uint16($self->flags)
71 ->uint32(0) # reserved
72 ->uint64($skip_attr ? 0 : $file->creation_time)
73 ->uint64($skip_attr ? 0 : $file->last_access_time)
74 ->uint64($skip_attr ? 0 : $file->last_write_time)
75 ->uint64($skip_attr ? 0 : $file->change_time)
76 ->uint64($skip_attr ? 0 : $file->allocation_size)
77 ->uint64($skip_attr ? 0 : $file->end_of_file)
78 ->uint32($skip_attr ? 0 : $file->attributes)
79 ;
80 } else {
81 0 ▶ $packer
Condition0%0/2
$self->fid || die('No fid set')
l!l
00
MC/DC0%0/1
$self->fid || die('No fid set')
$self->fid
Truth table0%0/2
A
A= $self->fid
Aresult
11
00
82 ->uint16($self->flags)
83 ->uint32(0) # reserved
84 ->fid2($self->fid || die "No fid set")
85 ;
86 }
87 }
88  
89 1 1;
« blib/lib/SMB/v2/Command/QueryDirectory.pm ↑ Summary lib/SMB/File.pm »