SFTP/Attributes.pm

filter: Statementstmt 28.7% 19 / 66 Branchbran 0.0% 0 / 22 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 55.5% 5 / 9 Podpod 66.6% 2 / 3 totaltotal 26.0% 26 / 100 CC 13 SCAR 35.7
CC
13
Cov
22%
init
72.0
as_buffer
30.0
__ANON__
6.0
CRAP 35.5
« SFTP.pm ↑ Summary SFTP/Constants.pm »
1 # $Id: Attributes.pm,v 1.5 2001/05/16 01:38:01 btrott Exp $
2  
3 package Net::SFTP::Attributes;
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 ▶use Net::SFTP::Constants qw( :att );
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use Net::SFTP::Buffer;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 2 ▶use vars qw( @FIELDS );
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 @FIELDS = qw( flags size uid gid perm atime mtime );
11  
12 2 for my $f (@FIELDS) {
13 2 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
14 *$f = sub {
15 0 ▶ my $a = shift;
Subroutine __ANON__: not called CC=2 SCAR=17.9
16 0 ▶ $a->{$f} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
17 0 $a->{$f};
18 14 };
19 }
20  
21 sub new {
22 0 ▶ my $class = shift;
Subroutine new: not called CC=1 SCAR=6.9
Pod documented
23 0 my $a = bless { }, $class;
24 0 $a->init(@_);
25 }
26  
27 sub init {
28 0 ▶ my $a = shift;
Subroutine init: not called CC=8 SCAR=42.8
Pod undocumented
29 0 my %param = @_;
30 0 for my $f (@FIELDS) {
31 0 $a->{$f} = 0;
32 }
33 0 ▶ if (my $stat = $param{Stat}) {
Branch: 2 branches
BranchTrueFalseTotal
if (my $stat = $param{'Stat'}) { } 0 0 0
elsif (my $buf = $param{'Buffer'}) { } 0 0 0
34 0 $a->{flags} |= SSH2_FILEXFER_ATTR_SIZE;
35 0 $a->{size} = $stat->[7];
36 0 $a->{flags} |= SSH2_FILEXFER_ATTR_UIDGID;
37 0 $a->{uid} = $stat->[4];
38 0 $a->{gid} = $stat->[5];
39 0 $a->{flags} |= SSH2_FILEXFER_ATTR_PERMISSIONS;
40 0 $a->{perm} = $stat->[2];
41 0 $a->{flags} |= SSH2_FILEXFER_ATTR_ACMODTIME;
42 0 $a->{atime} = $stat->[8];
43 0 $a->{mtime} = $stat->[9];
44 }
45 elsif (my $buf = $param{Buffer}) {
46 0 $a->{flags} = $buf->get_int32;
47 0 ▶ if ($a->{flags} & SSH2_FILEXFER_ATTR_SIZE) {
Branch: 1 branch
BranchTrueFalseTotal
if ($a->{"flags"} & &SSH2_FILEXFER_ATTR_SIZE()) 0 0 0
48 0 $a->{size} = $buf->get_int64;
49 }
50 0 ▶ if ($a->{flags} & SSH2_FILEXFER_ATTR_UIDGID) {
Branch: 1 branch
BranchTrueFalseTotal
if ($a->{"flags"} & &SSH2_FILEXFER_ATTR_UIDGID()) 0 0 0
51 0 $a->{uid} = $buf->get_int32;
52 0 $a->{gid} = $buf->get_int32;
53 }
54 0 ▶ if ($a->{flags} & SSH2_FILEXFER_ATTR_PERMISSIONS) {
Branch: 1 branch
BranchTrueFalseTotal
if ($a->{"flags"} & &SSH2_FILEXFER_ATTR_PERMISSIONS()) 0 0 0
55 0 $a->{perm} = $buf->get_int32;
56 }
57 0 ▶ if ($a->{flags} & SSH2_FILEXFER_ATTR_ACMODTIME) {
Branch: 1 branch
BranchTrueFalseTotal
if ($a->{"flags"} & &SSH2_FILEXFER_ATTR_ACMODTIME()) 0 0 0
58 0 $a->{atime} = $buf->get_int32;
59 0 $a->{mtime} = $buf->get_int32;
60 }
61 }
62 0 $a;
63 }
64  
65 sub as_buffer {
66 0 ▶ my $a = shift;
Subroutine as_buffer: not called CC=5 SCAR=34.0
Pod documented
67 0 my $buf = Net::SFTP::Buffer->new;
68 0 $buf->put_int32($a->{flags});
69 0 ▶ if ($a->{flags} & SSH2_FILEXFER_ATTR_SIZE) {
Branch: 1 branch
BranchTrueFalseTotal
if ($a->{"flags"} & &SSH2_FILEXFER_ATTR_SIZE()) 0 0 0
70 0 $buf->put_int64(int $a->{size});
71 }
72 0 ▶ if ($a->{flags} & SSH2_FILEXFER_ATTR_UIDGID) {
Branch: 1 branch
BranchTrueFalseTotal
if ($a->{"flags"} & &SSH2_FILEXFER_ATTR_UIDGID()) 0 0 0
73 0 $buf->put_int32($a->{uid});
74 0 $buf->put_int32($a->{gid});
75 }
76 0 ▶ if ($a->{flags} & SSH2_FILEXFER_ATTR_PERMISSIONS) {
Branch: 1 branch
BranchTrueFalseTotal
if ($a->{"flags"} & &SSH2_FILEXFER_ATTR_PERMISSIONS()) 0 0 0
77 0 $buf->put_int32($a->{perm});
78 }
79 0 ▶ if ($a->{flags} & SSH2_FILEXFER_ATTR_ACMODTIME) {
Branch: 1 branch
BranchTrueFalseTotal
if ($a->{"flags"} & &SSH2_FILEXFER_ATTR_ACMODTIME()) 0 0 0
80 0 $buf->put_int32($a->{atime});
81 0 $buf->put_int32($a->{mtime});
82 }
83 0 $buf;
84 }
85  
86 2 1;
87 __END__
« SFTP.pm ↑ Summary SFTP/Constants.pm »