line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# Copyright (c) 2004 Paul Winkeler. All Rights Reserved. |
3
|
|
|
|
|
|
|
# This program is free software; you may redistribute it and/or modify it under |
4
|
|
|
|
|
|
|
# the same terms as Perl itself. |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
package NBU::File; |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
35
|
|
9
|
1
|
|
|
1
|
|
6
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
79
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
6
|
use Date::Parse; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
127
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
BEGIN { |
14
|
1
|
|
|
1
|
|
6
|
use Exporter (); |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
16
|
|
15
|
1
|
|
|
1
|
|
5
|
use AutoLoader qw(AUTOLOAD); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
9
|
|
16
|
1
|
|
|
1
|
|
31
|
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $AUTOLOAD); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
141
|
|
17
|
1
|
|
|
1
|
|
2
|
$VERSION = do { my @r=(q$Revision: 1.3 $=~/\d+/g); sprintf "%d."."%02d"x$#r,@r }; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
11
|
|
18
|
1
|
|
|
|
|
14
|
@ISA = qw(); |
19
|
1
|
|
|
|
|
4
|
@EXPORT = qw(%densities); |
20
|
1
|
|
|
|
|
2
|
@EXPORT_OK = qw(); |
21
|
1
|
|
|
|
|
808
|
%EXPORT_TAGS = qw(); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my %fileList; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub new { |
27
|
0
|
|
|
0
|
0
|
|
my $proto = shift; |
28
|
0
|
|
|
|
|
|
my $file = {}; |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
bless $file, $proto; |
31
|
|
|
|
|
|
|
|
32
|
0
|
0
|
|
|
|
|
if (@_) { |
33
|
0
|
|
|
|
|
|
my $baseName = shift; |
34
|
|
|
|
|
|
|
|
35
|
0
|
0
|
|
|
|
|
if (exists($fileList{$baseName})) { |
36
|
0
|
|
|
|
|
|
return $fileList{$baseName}; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
$file->{BASENAME} = $baseName; |
40
|
0
|
|
|
|
|
|
$fileList{$file->{BASENAME}} = $file; |
41
|
|
|
|
|
|
|
} |
42
|
0
|
|
|
|
|
|
return $file; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub listIDs { |
46
|
0
|
|
|
0
|
0
|
|
my $proto = shift; |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
return (keys %fileList); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub listFiles { |
52
|
0
|
|
|
0
|
0
|
|
my $proto = shift; |
53
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
return (values %fileList); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub list { |
58
|
0
|
|
|
0
|
0
|
|
my $proto = shift; |
59
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
return ($proto->listFiles); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub id { |
64
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
65
|
|
|
|
|
|
|
|
66
|
0
|
0
|
|
|
|
|
if (@_) { |
67
|
0
|
|
|
|
|
|
$self->{BASENAME} = shift; |
68
|
0
|
|
|
|
|
|
$fileList{$self->{BASENAME}} = $self; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
|
return $self->{BASENAME}; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub baseName { |
75
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
76
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
return $self->id(@_); |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
# |
81
|
|
|
|
|
|
|
# Unlike the process of choosing a particular tape volume for a backup, |
82
|
|
|
|
|
|
|
# selecting a file has no meaning |
83
|
|
|
|
|
|
|
sub selected { |
84
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
85
|
|
|
|
|
|
|
|
86
|
0
|
|
|
|
|
|
return undef; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub retention { |
90
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
91
|
|
|
|
|
|
|
|
92
|
0
|
0
|
|
|
|
|
if (@_) { |
93
|
0
|
|
|
|
|
|
my $retention = shift; |
94
|
0
|
|
|
|
|
|
$self->{RETENTION} = $retention; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
0
|
|
|
|
|
|
return $self->{RETENTION}; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub mount { |
101
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
102
|
|
|
|
|
|
|
|
103
|
0
|
0
|
|
|
|
|
if (@_) { |
104
|
0
|
|
|
|
|
|
my ($mount, $path) = @_; |
105
|
0
|
|
|
|
|
|
$self->{MOUNT} = $mount; |
106
|
0
|
|
|
|
|
|
$self->{PATH} = $path; |
107
|
|
|
|
|
|
|
} |
108
|
0
|
|
|
|
|
|
return $self->{MOUNT}; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub path { |
112
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
113
|
|
|
|
|
|
|
|
114
|
0
|
|
|
|
|
|
return $self->{PATH}; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub unmount { |
118
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
119
|
0
|
|
|
|
|
|
my ($tm) = @_; |
120
|
|
|
|
|
|
|
|
121
|
0
|
0
|
|
|
|
|
if (my $mount = $self->mount) { |
122
|
0
|
|
|
|
|
|
$mount->unmount($tm); |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
0
|
|
|
|
|
|
$self->mount(undef, undef); |
126
|
0
|
|
|
|
|
|
return $self; |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
sub read { |
130
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
131
|
|
|
|
|
|
|
|
132
|
0
|
|
|
|
|
|
my ($size, $speed) = @_; |
133
|
|
|
|
|
|
|
|
134
|
0
|
|
|
|
|
|
$self->{SIZE} += $size; |
135
|
0
|
|
|
|
|
|
$self->{READTIME} += ($size / $speed); |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
sub write { |
139
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
140
|
|
|
|
|
|
|
|
141
|
0
|
|
|
|
|
|
my ($size, $speed) = @_; |
142
|
|
|
|
|
|
|
|
143
|
0
|
|
|
|
|
|
$self->{SIZE} += $size; |
144
|
0
|
|
|
|
|
|
$self->{WRITETIME} += ($size / $speed); |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
sub writeTime { |
148
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
149
|
|
|
|
|
|
|
|
150
|
0
|
|
|
|
|
|
return $self->{WRITETIME}; |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
sub dataWritten { |
154
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
155
|
|
|
|
|
|
|
|
156
|
0
|
0
|
|
|
|
|
if (@_) { |
157
|
0
|
|
|
|
|
|
$self->{SIZE} = shift; |
158
|
|
|
|
|
|
|
} |
159
|
0
|
|
|
|
|
|
return $self->{SIZE}; |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
# |
163
|
|
|
|
|
|
|
# Insert a single fragment into this volume's table of contents |
164
|
|
|
|
|
|
|
sub insertFragment { |
165
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
166
|
0
|
|
|
|
|
|
my $index = shift; |
167
|
0
|
|
|
|
|
|
my $fragment = shift; |
168
|
|
|
|
|
|
|
|
169
|
0
|
0
|
|
|
|
|
$self->{TOC} = [] if (!defined($self->{TOC})); |
170
|
|
|
|
|
|
|
|
171
|
0
|
|
|
|
|
|
my $toc = $self->{TOC}; |
172
|
|
|
|
|
|
|
|
173
|
0
|
0
|
|
|
|
|
$$toc[$index] = [] if (!defined($$toc[$index])); |
174
|
0
|
|
|
|
|
|
my $mpxList = $$toc[$index]; |
175
|
0
|
|
|
|
|
|
push @$mpxList, $fragment; |
176
|
|
|
|
|
|
|
} |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
# |
179
|
|
|
|
|
|
|
# Load the list of fragments for this volume into its table of |
180
|
|
|
|
|
|
|
# contents. |
181
|
|
|
|
|
|
|
sub loadImages { |
182
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
183
|
|
|
|
|
|
|
|
184
|
0
|
0
|
|
|
|
|
$self->{TOC} = [] if (!defined($self->{TOC})); |
185
|
|
|
|
|
|
|
|
186
|
0
|
0
|
0
|
|
|
|
if (!$self->{MMLOADED} || ($self->allocated && ($self->expires > time))) { |
|
|
|
0
|
|
|
|
|
187
|
|
|
|
|
|
|
# NBU::Image->loadImages(NBU->cmd("bpimmedia -l -mediaid ".$self->id." |")); |
188
|
0
|
|
|
|
|
|
print STDERR "Cannot load images of a file!\n"; |
189
|
|
|
|
|
|
|
} |
190
|
0
|
|
|
|
|
|
return $self->{TOC}; |
191
|
|
|
|
|
|
|
} |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
sub tableOfContents { |
194
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
195
|
|
|
|
|
|
|
|
196
|
0
|
0
|
|
|
|
|
if (!defined($self->{TOC})) { |
197
|
0
|
|
|
|
|
|
$self->loadImages; |
198
|
|
|
|
|
|
|
} |
199
|
|
|
|
|
|
|
|
200
|
0
|
|
|
|
|
|
my $toc = $self->{TOC}; |
201
|
0
|
|
|
|
|
|
return (@$toc); |
202
|
|
|
|
|
|
|
} |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
1; |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
__END__ |