Skip Menu |

This queue is for tickets about the OLE-Storage_Lite CPAN distribution.

Report information
The Basics
Id: 3699
Status: resolved
Priority: 0/
Queue: OLE-Storage_Lite

People
Owner: jmcnamara [...] cpan.org
Requestors: kyle.burton [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.11
Fixed in: (no value)



Subject: Inconsistiency in processing IO::Scalars
For use cases where an on-disk file is not acceptible, an IO::Scalar should be useable in place of standard Perl file handles (or IO::File objects). Storage_Lite currently tests for IO::Handle derived objects, but assumes that they are files, i.e. that you can call a close method on them, which is not true for IO::Scalars. The attached patch adds a check for the IO::Scalar case and only closes file handles that are determinable as being able to support the operation. Thank you, Kyle R. Burton krburton@cpan.org
--- OLE-Storage_Lite-0.11/Storage_Lite.pm 2002-11-11 17:44:14.000000000 -0500 +++ OLE-Storage_Lite-0.11-krb/Storage_Lite.pm 2003-07-29 21:48:32.000000000 -0400 @@ -213,16 +213,23 @@ $rhInfo->{_SMALL_SIZE} = 0x1000; $rhInfo->{_PPS_SIZE} = 0x80; + my $closeFile = undef; + #1.Open File #1.1 $sFile is Ref of scalar if(ref($sFile) eq 'SCALAR') { my $oIo = new IO::Scalar $sFile, O_WRONLY; $rhInfo->{_FILEH_} = $oIo; + $closeFile = 1; } #1.2 $sFile is a IO::Handle object + elsif(UNIVERSAL::isa($sFile, 'IO::Scalar')) { + $rhInfo->{_FILEH_} = $sFile; + } elsif(UNIVERSAL::isa($sFile, 'IO::Handle')) { binmode($sFile); $rhInfo->{_FILEH_} = $sFile; + $closeFile = 1; } #1.3 $sFile is a simple filename string elsif(!ref($sFile)) { @@ -237,6 +244,7 @@ $oIo->fdopen(fileno(STDOUT),"w") || return undef; binmode($oIo); $rhInfo->{_FILEH_} = $oIo; + $closeFile = 1; } } #1.4 Others @@ -269,7 +277,7 @@ #6. Write BD and BDList and Adding Header informations $oThis->_saveBbd($iSBDcnt, $iBBcnt, $iPPScnt, $rhInfo); #7.Close File - $rhInfo->{_FILEH_}->close unless($sFile ne '-'); + $rhInfo->{_FILEH_}->close if $closeFile; } #------------------------------------------------------------------------------ # _calcSize (OLE::Storage_Lite::PPS)
Subject: OLE::Storage_Lite: Inconsistiency in processing IO::Scalars
[KRBURTON - Tue Sep 2 12:58:25 2003]: Show quoted text
> The attached patch adds a check for the IO::Scalar case and only > closes file handles that are determinable as being able to support > the operation.
Patched applied in OLE::Storage_Lite version 0.12. Thanks, John. --