File Coverage

blib/lib/DBM/Deep/Sector/File/Null.pm
Criterion Covered Total %
statement 22 22 100.0
branch 2 2 100.0
condition n/a
subroutine 8 8 100.0
pod 0 3 0.0
total 32 35 91.4


line stmt bran cond sub pod time code
1             package DBM::Deep::Sector::File::Null;
2              
3 50     50   927 use 5.008_004;
  50         175  
4              
5 50     50   281 use strict;
  50         96  
  50         1321  
6 50     50   260 use warnings FATAL => 'all';
  50         107  
  50         2150  
7              
8 50     50   300 use base qw( DBM::Deep::Sector::File::Data );
  50         136  
  50         25075  
9              
10             my $STALE_SIZE = 2;
11              
12             # Please refer to the pack() documentation for further information
13             my %StP = (
14             1 => 'C', # Unsigned char value (no order needed as it's just one byte)
15             2 => 'n', # Unsigned short in "network" (big-endian) order
16             4 => 'N', # Unsigned long in "network" (big-endian) order
17             8 => 'Q', # Usigned quad (no order specified, presumably machine-dependent)
18             );
19              
20 67     67 0 330 sub type { $_[0]{engine}->SIG_NULL }
21 67     67 0 336 sub data_length { 0 }
22 12     12 0 39 sub data { return }
23              
24             sub _init {
25 94     94   159 my $self = shift;
26              
27 94         223 my $engine = $self->engine;
28              
29 94 100       257 unless ( $self->offset ) {
30 67         201 my $leftover = $self->size - $self->base_size - 1 * $engine->byte_size - 1;
31              
32 67         183 $self->{offset} = $engine->_request_data_sector( $self->size );
33 67         239 $engine->storage->print_at( $self->offset, $self->type ); # Sector type
34             # Skip staleness counter
35             $engine->storage->print_at( $self->offset + $self->base_size,
36             pack( $StP{$engine->byte_size}, 0 ), # Chain loc
37 67         235 pack( $StP{1}, $self->data_length ), # Data length
38             chr(0) x $leftover, # Zero-fill the rest
39             );
40              
41 67         201 return;
42             }
43             }
44              
45             1;
46             __END__