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   931 use 5.008_004;
  50         185  
4              
5 50     50   275 use strict;
  50         150  
  50         1359  
6 50     50   266 use warnings FATAL => 'all';
  50         108  
  50         2056  
7              
8 50     50   330 use base qw( DBM::Deep::Sector::File::Data );
  50         104  
  50         24692  
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 314 sub type { $_[0]{engine}->SIG_NULL }
21 67     67 0 397 sub data_length { 0 }
22 12     12 0 41 sub data { return }
23              
24             sub _init {
25 94     94   179 my $self = shift;
26              
27 94         226 my $engine = $self->engine;
28              
29 94 100       268 unless ( $self->offset ) {
30 67         181 my $leftover = $self->size - $self->base_size - 1 * $engine->byte_size - 1;
31              
32 67         174 $self->{offset} = $engine->_request_data_sector( $self->size );
33 67         240 $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         255 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__