From: rkinyon Date: Thu, 2 Mar 2006 01:40:19 +0000 (+0000) Subject: Cleaned up open() a bit X-Git-Tag: 0-99_01~91 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=673464d93145b8e4d2ae9264cd1e5774486a6770;p=dbsrgits%2FDBM-Deep.git Cleaned up open() a bit --- diff --git a/lib/DBM/Deep/Engine.pm b/lib/DBM/Deep/Engine.pm index 7c8d139..ec21f82 100644 --- a/lib/DBM/Deep/Engine.pm +++ b/lib/DBM/Deep/Engine.pm @@ -90,7 +90,7 @@ sub setup_fh { $self->open( $obj ) if !defined $obj->_fh; - #XXX Is {end} busted? Can't we just seek( $fh, 0, SEEK_END ) ? + #XXX We have to make sure we don't mess up when autoflush isn't turned on unless ( $obj->_root->{inode} ) { my @stats = stat($obj->_fh); $obj->_root->{inode} = $stats[1]; @@ -110,22 +110,14 @@ sub open { if (defined($obj->_fh)) { $self->close_fh( $obj ); } - eval { - local $SIG{'__DIE__'}; - # 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 $fh; - sysopen( $fh, $obj->_root->{file}, $flags ) - or $fh = undef; - $obj->_root->{fh} = $fh; - }; if ($@ ) { $obj->_throw_error( "Received error: $@\n" ); } - if (! defined($obj->_fh)) { - return $obj->_throw_error("Cannot sysopen file: " . $obj->_root->{file} . ": $!"); - } + # 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 $fh = $obj->_fh; + my $fh; + sysopen( $fh, $obj->_root->{file}, $flags ) + or $obj->_throw_error("Cannot sysopen file: " . $obj->_root->{file} . ": $!"); + $obj->_root->{fh} = $fh; #XXX Can we remove this by using the right sysopen() flags? # Maybe ... q.v. above