/usr/share/perl5/DBM/Deep/Sector/File.pm is in libdbm-deep-perl 2.0002-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | package DBM::Deep::Sector::File;
use 5.008_004;
use strict;
use warnings FATAL => 'all';
use base qw( DBM::Deep::Sector );
use DBM::Deep::Sector::File::BucketList ();
use DBM::Deep::Sector::File::Index ();
use DBM::Deep::Sector::File::Null ();
use DBM::Deep::Sector::File::Reference ();
use DBM::Deep::Sector::File::Scalar ();
my $STALE_SIZE = 2;
sub base_size {
my $self = shift;
return $self->engine->SIG_SIZE + $STALE_SIZE;
}
sub free_meth { die "free_meth must be implemented in a child class" }
sub free {
my $self = shift;
my $e = $self->engine;
$e->storage->print_at( $self->offset, $e->SIG_FREE );
# Skip staleness counter
$e->storage->print_at( $self->offset + $self->base_size,
chr(0) x ($self->size - $self->base_size),
);
my $free_meth = $self->free_meth;
$e->$free_meth( $self->offset, $self->size );
return;
}
#=head2 load( $offset )
#
#This will instantiate and return the sector object that represents the data
#found at $offset.
#
#=cut
sub load {
my $self = shift;
my ($engine, $offset) = @_;
# Add a catch for offset of 0 or 1
return if !$offset || $offset <= 1;
my $type = $engine->storage->read_at( $offset, 1 );
return if $type eq chr(0);
if ( $type eq $engine->SIG_ARRAY || $type eq $engine->SIG_HASH ) {
return DBM::Deep::Sector::File::Reference->new({
engine => $engine,
type => $type,
offset => $offset,
});
}
# XXX Don't we need key_md5 here?
elsif ( $type eq $engine->SIG_BLIST ) {
return DBM::Deep::Sector::File::BucketList->new({
engine => $engine,
type => $type,
offset => $offset,
});
}
elsif ( $type eq $engine->SIG_INDEX ) {
return DBM::Deep::Sector::File::Index->new({
engine => $engine,
type => $type,
offset => $offset,
});
}
elsif ( $type eq $engine->SIG_NULL ) {
return DBM::Deep::Sector::File::Null->new({
engine => $engine,
type => $type,
offset => $offset,
});
}
elsif ( $type eq $engine->SIG_DATA || $type eq $engine->SIG_UNIDATA ) {
return DBM::Deep::Sector::File::Scalar->new({
engine => $engine,
type => $type,
offset => $offset,
});
}
# This was deleted from under us, so just return and let the caller figure it out.
elsif ( $type eq $engine->SIG_FREE ) {
return;
}
DBM::Deep->_throw_error( "'$offset': Don't know what to do with type '$type'" );
}
1;
__END__
|