#87256# Keep a copy of the ZipEntry struct, not a reference

This commit is contained in:
Martin Gallwey 2001-05-29 10:57:06 +00:00
parent 84d10d8d3d
commit ce28f432b5
2 changed files with 21 additions and 15 deletions

View file

@ -2,9 +2,9 @@
*
* $RCSfile: EntryInputStream.cxx,v $
*
* $Revision: 1.15 $
* $Revision: 1.16 $
*
* last change: $Author: mtg $ $Date: 2001-05-08 13:57:41 $
* last change: $Author: mtg $ $Date: 2001-05-29 11:57:06 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -94,7 +94,7 @@ EntryInputStream::EntryInputStream( Reference < io::XInputStream > xNewInput,
sal_Bool bGetRawStream)
: xStream( xNewInput )
, xSeek( xNewInput, UNO_QUERY )
, rEntry (rNewEntry )
, aEntry (rNewEntry )
, nCurrent( 0 )
, bHaveInMemory ( sal_False )
, aInflater( sal_True )
@ -104,22 +104,27 @@ EntryInputStream::EntryInputStream( Reference < io::XInputStream > xNewInput,
{
if (bGetRawStream)
{
nUncompressedSize = rEntry.nMethod == DEFLATED ? rEntry.nCompressedSize : rEntry.nSize;
nEnd = rEntry.nOffset + nUncompressedSize;
nUncompressedSize = aEntry.nMethod == DEFLATED ? aEntry.nCompressedSize : aEntry.nSize;
nEnd = aEntry.nOffset + nUncompressedSize;
}
else
{
nEnd = rEntry.nMethod == DEFLATED ? rEntry.nOffset + rEntry.nCompressedSize : rEntry.nOffset + rEntry.nSize;
nUncompressedSize = rEntry.nSize;
nEnd = aEntry.nMethod == DEFLATED ? aEntry.nOffset + aEntry.nCompressedSize : aEntry.nOffset + aEntry.nSize;
nUncompressedSize = aEntry.nSize;
}
}
void EntryInputStream::readIntoMemory()
throw(io::NotConnectedException, io::BufferSizeExceededException, io::IOException, RuntimeException)
{
if (!bHaveInMemory)
{
Sequence < sal_Int8 > aReadBuffer;
xSeek->seek(rEntry.nOffset);
sal_Int32 nSize = rEntry.nMethod == DEFLATED ? rEntry.nCompressedSize : rEntry.nSize;
xSeek->seek(aEntry.nOffset);
sal_Int32 nSize = aEntry.nMethod == DEFLATED ? aEntry.nCompressedSize : aEntry.nSize;
if (nSize <0)
throw io::BufferSizeExceededException(::rtl::OUString(), *this);
xStream->readBytes( aReadBuffer, nSize ); // Now it holds the raw stuff from disk
if (xEncryptionData->aSalt.getLength())
@ -153,12 +158,12 @@ void EntryInputStream::readIntoMemory()
OSL_ASSERT (aResult == rtl_Cipher_E_None);
aReadBuffer = aDecryptBuffer; // Now it holds the decrypted data
}
if (bRawStream || rEntry.nMethod == STORED)
if (bRawStream || aEntry.nMethod == STORED)
aBuffer = aReadBuffer; // bRawStream means the caller doesn't want it decompressed
else
{
aInflater.setInputSegment(aReadBuffer, 0, nSize );
aBuffer.realloc( rEntry.nSize );
aBuffer.realloc( aEntry.nSize );
aInflater.doInflate(aBuffer);
aInflater.end();
}

View file

@ -2,9 +2,9 @@
*
* $RCSfile: EntryInputStream.hxx,v $
*
* $Revision: 1.4 $
* $Revision: 1.5 $
*
* last change: $Author: mtg $ $Date: 2001-05-08 13:58:22 $
* last change: $Author: mtg $ $Date: 2001-05-29 11:57:06 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@ -92,9 +92,10 @@ protected:
sal_Bool bRawStream, bHaveInMemory, bEncrypted;
com::sun::star::uno::Sequence < sal_Int8 > aBuffer;
const vos::ORef < EncryptionData > xEncryptionData;
const com::sun::star::packages::ZipEntry & rEntry;
const com::sun::star::packages::ZipEntry aEntry;
Inflater aInflater;
void readIntoMemory();
void readIntoMemory()
throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
public:
EntryInputStream( com::sun::star::uno::Reference < com::sun::star::io::XInputStream > xInput,
const com::sun::star::packages::ZipEntry &rNewEntry,