return;
}
+sub read_file_signature {
+ my $self = shift;
+ my ($obj) = @_;
+
+ my $fh = $obj->_fh;
+
+ seek($fh, 0 + $obj->_root->{file_offset}, SEEK_SET);
+ my $signature;
+ my $bytes_read = read( $fh, $signature, length(SIG_FILE));
+
+ if ( $bytes_read ) {
+ unless ($signature eq SIG_FILE) {
+ $self->close_fh( $obj );
+ $obj->_throw_error("Signature not found -- file is not a Deep DB");
+ }
+ }
+
+ return $bytes_read;
+}
+
sub setup_fh {
my $self = shift;
my ($obj) = @_;
flock $fh, LOCK_EX;
unless ( $obj->{base_offset} ) {
- seek($fh, 0 + $obj->_root->{file_offset}, SEEK_SET);
- my $signature;
- my $bytes_read = read( $fh, $signature, length(SIG_FILE));
+ my $bytes_read = $self->read_file_signature( $obj );
##
# File is empty -- write signature and master index
$obj->{base_offset} = $bytes_read;
##
- # Check signature was valid
- ##
- unless ($signature eq SIG_FILE) {
- $self->close_fh( $obj );
- $obj->_throw_error("Signature not found -- file is not a Deep DB");
- }
-
- ##
# Get our type from master index signature
##
my $tag = $self->load_tag($obj, $obj->_base_offset)