line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id: Attributes.pm,v 1.5 2001/05/16 01:38:01 btrott Exp $ |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Net::SFTP::Attributes; |
4
|
2
|
|
|
2
|
|
11
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
50
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
8
|
use Net::SFTP::Constants qw( :att ); |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
9
|
|
7
|
2
|
|
|
2
|
|
602
|
use Net::SFTP::Buffer; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
50
|
|
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
617
|
use vars qw( @FIELDS ); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
103
|
|
10
|
|
|
|
|
|
|
@FIELDS = qw( flags size uid gid perm atime mtime ); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
for my $f (@FIELDS) { |
13
|
2
|
|
|
2
|
|
10
|
no strict 'refs'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
844
|
|
14
|
|
|
|
|
|
|
*$f = sub { |
15
|
0
|
|
|
0
|
|
|
my $a = shift; |
16
|
0
|
0
|
|
|
|
|
$a->{$f} = shift if @_; |
17
|
0
|
|
|
|
|
|
$a->{$f}; |
18
|
|
|
|
|
|
|
}; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub new { |
22
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
23
|
0
|
|
|
|
|
|
my $a = bless { }, $class; |
24
|
0
|
|
|
|
|
|
$a->init(@_); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub init { |
28
|
0
|
|
|
0
|
0
|
|
my $a = shift; |
29
|
0
|
|
|
|
|
|
my %param = @_; |
30
|
0
|
|
|
|
|
|
for my $f (@FIELDS) { |
31
|
0
|
|
|
|
|
|
$a->{$f} = 0; |
32
|
|
|
|
|
|
|
} |
33
|
0
|
0
|
|
|
|
|
if (my $stat = $param{Stat}) { |
|
|
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
|
0
|
|
|
|
|
if ($a->{flags} & SSH2_FILEXFER_ATTR_SIZE) { |
48
|
0
|
|
|
|
|
|
$a->{size} = $buf->get_int64; |
49
|
|
|
|
|
|
|
} |
50
|
0
|
0
|
|
|
|
|
if ($a->{flags} & SSH2_FILEXFER_ATTR_UIDGID) { |
51
|
0
|
|
|
|
|
|
$a->{uid} = $buf->get_int32; |
52
|
0
|
|
|
|
|
|
$a->{gid} = $buf->get_int32; |
53
|
|
|
|
|
|
|
} |
54
|
0
|
0
|
|
|
|
|
if ($a->{flags} & SSH2_FILEXFER_ATTR_PERMISSIONS) { |
55
|
0
|
|
|
|
|
|
$a->{perm} = $buf->get_int32; |
56
|
|
|
|
|
|
|
} |
57
|
0
|
0
|
|
|
|
|
if ($a->{flags} & SSH2_FILEXFER_ATTR_ACMODTIME) { |
58
|
0
|
|
|
|
|
|
$a->{atime} = $buf->get_int32; |
59
|
0
|
|
|
|
|
|
$a->{mtime} = $buf->get_int32; |
60
|
|
|
|
|
|
|
} |
61
|
0
|
0
|
|
|
|
|
if ($a->{flags} & SSH2_FILEXFER_ATTR_EXTENDED) { |
62
|
0
|
|
|
|
|
|
my $extended_count = $buf->get_int32; |
63
|
0
|
|
|
|
|
|
for (1..$extended_count) { |
64
|
0
|
|
|
|
|
|
my $name = $buf->get_str; |
65
|
0
|
|
|
|
|
|
my $value = $buf->get_str; |
66
|
0
|
|
|
|
|
|
$a->{$name} = $value; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
} |
70
|
0
|
|
|
|
|
|
$a; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub as_buffer { |
74
|
0
|
|
|
0
|
1
|
|
my $a = shift; |
75
|
0
|
|
|
|
|
|
my $buf = Net::SFTP::Buffer->new; |
76
|
0
|
|
|
|
|
|
$buf->put_int32($a->{flags}); |
77
|
0
|
0
|
|
|
|
|
if ($a->{flags} & SSH2_FILEXFER_ATTR_SIZE) { |
78
|
0
|
|
|
|
|
|
$buf->put_int64(int $a->{size}); |
79
|
|
|
|
|
|
|
} |
80
|
0
|
0
|
|
|
|
|
if ($a->{flags} & SSH2_FILEXFER_ATTR_UIDGID) { |
81
|
0
|
|
|
|
|
|
$buf->put_int32($a->{uid}); |
82
|
0
|
|
|
|
|
|
$buf->put_int32($a->{gid}); |
83
|
|
|
|
|
|
|
} |
84
|
0
|
0
|
|
|
|
|
if ($a->{flags} & SSH2_FILEXFER_ATTR_PERMISSIONS) { |
85
|
0
|
|
|
|
|
|
$buf->put_int32($a->{perm}); |
86
|
|
|
|
|
|
|
} |
87
|
0
|
0
|
|
|
|
|
if ($a->{flags} & SSH2_FILEXFER_ATTR_ACMODTIME) { |
88
|
0
|
|
|
|
|
|
$buf->put_int32($a->{atime}); |
89
|
0
|
|
|
|
|
|
$buf->put_int32($a->{mtime}); |
90
|
|
|
|
|
|
|
} |
91
|
0
|
|
|
|
|
|
$buf; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
1; |
95
|
|
|
|
|
|
|
__END__ |