my $self = bless {
autobless => undef,
autoflush => undef,
- #XXX It should be this in order to work with the initial create_tag(),
- #XXX but it's not ... it works out because of the stat() in setup_fh(),
- #XXX but that's not good.
- end => 0, #length(DBM::Deep->SIG_FILE),
+ end => 0,
fh => undef,
file => undef,
file_offset => 0,
# File is empty -- write signature and master index
##
if (!$bytes_read) {
- seek($fh, 0 + $obj->_root->{file_offset}, SEEK_SET);
+ my $loc = $self->_request_space( $obj, length( SIG_FILE ) );
+ seek($fh, $loc + $obj->_root->{file_offset}, SEEK_SET);
print( $fh SIG_FILE);
- $obj->_root->{end} = length( SIG_FILE );
-
- $obj->{base_offset} = $self->_request_space($obj, $self->{index_size});
+ $obj->{base_offset} = $self->_request_space(
+ $obj, $self->{index_size},
+ );
$self->create_tag(
- $obj, $obj->_base_offset, $obj->_type, chr(0) x $self->{index_size},
+ $obj, $obj->_base_offset, $obj->_type,
+ chr(0) x $self->{index_size},
);
# Flush the filehandle
my $self = shift;
my ($obj) = @_;
- if (defined($obj->_fh)) { $self->close_fh( $obj ); }
-
# Theoretically, adding O_BINARY should remove the need for the binmode
# Of course, testing it is going to be ... interesting.
my $flags = O_RDWR | O_CREAT | O_BINARY;
my ($obj, $size) = @_;
my $loc = $obj->_root->{end};
+ $obj->_root->{end} += $size;
return $loc;
}