Kaydet (Commit) 04ebf437 authored tarafından Matúš Kukan's avatar Matúš Kukan

package: ZipOutputStream: prefix members

Change-Id: I9cc21ba87484560ec0db5424800dd67f80e00540
üst 3d8f0598
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
#define INCLUDED_PACKAGE_INC_ZIPOUTPUTSTREAM_HXX #define INCLUDED_PACKAGE_INC_ZIPOUTPUTSTREAM_HXX
#include <com/sun/star/uno/Reference.hxx> #include <com/sun/star/uno/Reference.hxx>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/io/XOutputStream.hpp> #include <com/sun/star/io/XOutputStream.hpp>
#include <com/sun/star/xml/crypto/XCipherContext.hpp> #include <com/sun/star/xml/crypto/XCipherContext.hpp>
#include <com/sun/star/xml/crypto/XDigestContext.hpp> #include <com/sun/star/xml/crypto/XDigestContext.hpp>
...@@ -33,32 +32,28 @@ ...@@ -33,32 +32,28 @@
struct ZipEntry; struct ZipEntry;
class ZipPackageStream; class ZipPackageStream;
namespace rtl
{
template < class T > class Reference;
}
class ZipOutputStream class ZipOutputStream
{ {
protected: protected:
::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext> m_xContext; ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext> m_xContext;
::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > xStream; ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > m_xStream;
::std::vector < ZipEntry * > aZipList; ::std::vector < ZipEntry * > m_aZipList;
::com::sun::star::uno::Sequence< sal_Int8 > m_aDeflateBuffer; ::com::sun::star::uno::Sequence< sal_Int8 > m_aDeflateBuffer;
OUString sComment; OUString m_sComment;
ZipUtils::Deflater aDeflater; ZipUtils::Deflater m_aDeflater;
::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::XCipherContext > m_xCipherContext; ::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::XCipherContext > m_xCipherContext;
::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::XDigestContext > m_xDigestContext; ::com::sun::star::uno::Reference< ::com::sun::star::xml::crypto::XDigestContext > m_xDigestContext;
CRC32 aCRC; CRC32 m_aCRC;
ByteChucker aChucker; ByteChucker m_aChucker;
ZipEntry *pCurrentEntry; ZipEntry *m_pCurrentEntry;
sal_Int16 nMethod, nLevel, mnDigested; sal_Int16 m_nMethod, m_nLevel, m_nDigested;
bool bFinished, bEncryptCurrentEntry; bool m_bFinished, m_bEncryptCurrentEntry;
ZipPackageStream* m_pCurrentStream; ZipPackageStream* m_pCurrentStream;
public: public:
......
...@@ -33,8 +33,6 @@ ...@@ -33,8 +33,6 @@
using namespace com::sun::star; using namespace com::sun::star;
using namespace com::sun::star::io; using namespace com::sun::star::io;
using namespace com::sun::star::uno; using namespace com::sun::star::uno;
using namespace com::sun::star::packages;
using namespace com::sun::star::packages::zip;
using namespace com::sun::star::packages::zip::ZipConstants; using namespace com::sun::star::packages::zip::ZipConstants;
/** This class is used to write Zip files /** This class is used to write Zip files
...@@ -42,35 +40,35 @@ using namespace com::sun::star::packages::zip::ZipConstants; ...@@ -42,35 +40,35 @@ using namespace com::sun::star::packages::zip::ZipConstants;
ZipOutputStream::ZipOutputStream( const uno::Reference< uno::XComponentContext >& rxContext, ZipOutputStream::ZipOutputStream( const uno::Reference< uno::XComponentContext >& rxContext,
const uno::Reference < XOutputStream > &xOStream ) const uno::Reference < XOutputStream > &xOStream )
: m_xContext( rxContext ) : m_xContext( rxContext )
, xStream(xOStream) , m_xStream(xOStream)
, m_aDeflateBuffer(n_ConstBufferSize) , m_aDeflateBuffer(n_ConstBufferSize)
, aDeflater(DEFAULT_COMPRESSION, true) , m_aDeflater(DEFAULT_COMPRESSION, true)
, aChucker(xOStream) , m_aChucker(xOStream)
, pCurrentEntry(NULL) , m_pCurrentEntry(NULL)
, nMethod(DEFLATED) , m_nMethod(DEFLATED)
, nLevel(0) , m_nLevel(0)
, mnDigested(0) , m_nDigested(0)
, bFinished(false) , m_bFinished(false)
, bEncryptCurrentEntry(false) , m_bEncryptCurrentEntry(false)
, m_pCurrentStream(NULL) , m_pCurrentStream(NULL)
{ {
} }
ZipOutputStream::~ZipOutputStream( void ) ZipOutputStream::~ZipOutputStream( void )
{ {
for (sal_Int32 i = 0, nEnd = aZipList.size(); i < nEnd; i++) for (sal_Int32 i = 0, nEnd = m_aZipList.size(); i < nEnd; i++)
delete aZipList[i]; delete m_aZipList[i];
} }
void SAL_CALL ZipOutputStream::setMethod( sal_Int32 nNewMethod ) void SAL_CALL ZipOutputStream::setMethod( sal_Int32 nNewMethod )
throw(RuntimeException) throw(RuntimeException)
{ {
nMethod = static_cast < sal_Int16 > (nNewMethod); m_nMethod = static_cast < sal_Int16 > (nNewMethod);
} }
void SAL_CALL ZipOutputStream::setLevel( sal_Int32 nNewLevel ) void SAL_CALL ZipOutputStream::setLevel( sal_Int32 nNewLevel )
throw(RuntimeException) throw(RuntimeException)
{ {
aDeflater.setLevel( nNewLevel); m_aDeflater.setLevel( nNewLevel);
} }
void SAL_CALL ZipOutputStream::putNextEntry( ZipEntry& rEntry, void SAL_CALL ZipOutputStream::putNextEntry( ZipEntry& rEntry,
...@@ -78,12 +76,12 @@ void SAL_CALL ZipOutputStream::putNextEntry( ZipEntry& rEntry, ...@@ -78,12 +76,12 @@ void SAL_CALL ZipOutputStream::putNextEntry( ZipEntry& rEntry,
bool bEncrypt) bool bEncrypt)
throw(IOException, RuntimeException) throw(IOException, RuntimeException)
{ {
if (pCurrentEntry != NULL) if (m_pCurrentEntry != NULL)
closeEntry(); closeEntry();
if (rEntry.nTime == -1) if (rEntry.nTime == -1)
rEntry.nTime = getCurrentDosTime(); rEntry.nTime = getCurrentDosTime();
if (rEntry.nMethod == -1) if (rEntry.nMethod == -1)
rEntry.nMethod = nMethod; rEntry.nMethod = m_nMethod;
rEntry.nVersion = 20; rEntry.nVersion = 20;
rEntry.nFlag = 1 << 11; rEntry.nFlag = 1 << 11;
if (rEntry.nSize == -1 || rEntry.nCompressedSize == -1 || if (rEntry.nSize == -1 || rEntry.nCompressedSize == -1 ||
...@@ -95,61 +93,61 @@ void SAL_CALL ZipOutputStream::putNextEntry( ZipEntry& rEntry, ...@@ -95,61 +93,61 @@ void SAL_CALL ZipOutputStream::putNextEntry( ZipEntry& rEntry,
if (bEncrypt) if (bEncrypt)
{ {
bEncryptCurrentEntry = true; m_bEncryptCurrentEntry = true;
m_xCipherContext = ZipFile::StaticGetCipher( m_xContext, pStream->GetEncryptionData(), true ); m_xCipherContext = ZipFile::StaticGetCipher( m_xContext, pStream->GetEncryptionData(), true );
m_xDigestContext = ZipFile::StaticGetDigestContextForChecksum( m_xContext, pStream->GetEncryptionData() ); m_xDigestContext = ZipFile::StaticGetDigestContextForChecksum( m_xContext, pStream->GetEncryptionData() );
mnDigested = 0; m_nDigested = 0;
rEntry.nFlag |= 1 << 4; rEntry.nFlag |= 1 << 4;
m_pCurrentStream = pStream; m_pCurrentStream = pStream;
} }
sal_Int32 nLOCLength = writeLOC(rEntry); sal_Int32 nLOCLength = writeLOC(rEntry);
rEntry.nOffset = aChucker.GetPosition() - nLOCLength; rEntry.nOffset = m_aChucker.GetPosition() - nLOCLength;
aZipList.push_back( &rEntry ); m_aZipList.push_back( &rEntry );
pCurrentEntry = &rEntry; m_pCurrentEntry = &rEntry;
} }
void SAL_CALL ZipOutputStream::closeEntry( ) void SAL_CALL ZipOutputStream::closeEntry( )
throw(IOException, RuntimeException) throw(IOException, RuntimeException)
{ {
ZipEntry *pEntry = pCurrentEntry; ZipEntry *pEntry = m_pCurrentEntry;
if (pEntry) if (pEntry)
{ {
switch (pEntry->nMethod) switch (pEntry->nMethod)
{ {
case DEFLATED: case DEFLATED:
aDeflater.finish(); m_aDeflater.finish();
while (!aDeflater.finished()) while (!m_aDeflater.finished())
doDeflate(); doDeflate();
if ((pEntry->nFlag & 8) == 0) if ((pEntry->nFlag & 8) == 0)
{ {
if (pEntry->nSize != aDeflater.getTotalIn()) if (pEntry->nSize != m_aDeflater.getTotalIn())
{ {
OSL_FAIL("Invalid entry size"); OSL_FAIL("Invalid entry size");
} }
if (pEntry->nCompressedSize != aDeflater.getTotalOut()) if (pEntry->nCompressedSize != m_aDeflater.getTotalOut())
{ {
// Different compression strategies make the merit of this // Different compression strategies make the merit of this
// test somewhat dubious // test somewhat dubious
pEntry->nCompressedSize = aDeflater.getTotalOut(); pEntry->nCompressedSize = m_aDeflater.getTotalOut();
} }
if (pEntry->nCrc != aCRC.getValue()) if (pEntry->nCrc != m_aCRC.getValue())
{ {
OSL_FAIL("Invalid entry CRC-32"); OSL_FAIL("Invalid entry CRC-32");
} }
} }
else else
{ {
if ( !bEncryptCurrentEntry ) if ( !m_bEncryptCurrentEntry )
{ {
pEntry->nSize = aDeflater.getTotalIn(); pEntry->nSize = m_aDeflater.getTotalIn();
pEntry->nCompressedSize = aDeflater.getTotalOut(); pEntry->nCompressedSize = m_aDeflater.getTotalOut();
} }
pEntry->nCrc = aCRC.getValue(); pEntry->nCrc = m_aCRC.getValue();
writeEXT(*pEntry); writeEXT(*pEntry);
} }
aDeflater.reset(); m_aDeflater.reset();
aCRC.reset(); m_aCRC.reset();
break; break;
case STORED: case STORED:
if (!((pEntry->nFlag & 8) == 0)) if (!((pEntry->nFlag & 8) == 0))
...@@ -160,9 +158,9 @@ void SAL_CALL ZipOutputStream::closeEntry( ) ...@@ -160,9 +158,9 @@ void SAL_CALL ZipOutputStream::closeEntry( )
break; break;
} }
if (bEncryptCurrentEntry) if (m_bEncryptCurrentEntry)
{ {
bEncryptCurrentEntry = false; m_bEncryptCurrentEntry = false;
m_xCipherContext.clear(); m_xCipherContext.clear();
...@@ -176,7 +174,7 @@ void SAL_CALL ZipOutputStream::closeEntry( ) ...@@ -176,7 +174,7 @@ void SAL_CALL ZipOutputStream::closeEntry( )
if ( m_pCurrentStream ) if ( m_pCurrentStream )
m_pCurrentStream->setDigest( aDigestSeq ); m_pCurrentStream->setDigest( aDigestSeq );
} }
pCurrentEntry = NULL; m_pCurrentEntry = NULL;
m_pCurrentStream = NULL; m_pCurrentStream = NULL;
} }
} }
...@@ -184,22 +182,22 @@ void SAL_CALL ZipOutputStream::closeEntry( ) ...@@ -184,22 +182,22 @@ void SAL_CALL ZipOutputStream::closeEntry( )
void SAL_CALL ZipOutputStream::write( const Sequence< sal_Int8 >& rBuffer, sal_Int32 nNewOffset, sal_Int32 nNewLength ) void SAL_CALL ZipOutputStream::write( const Sequence< sal_Int8 >& rBuffer, sal_Int32 nNewOffset, sal_Int32 nNewLength )
throw(IOException, RuntimeException) throw(IOException, RuntimeException)
{ {
switch (pCurrentEntry->nMethod) switch (m_pCurrentEntry->nMethod)
{ {
case DEFLATED: case DEFLATED:
if (!aDeflater.finished()) if (!m_aDeflater.finished())
{ {
aDeflater.setInputSegment(rBuffer, nNewOffset, nNewLength); m_aDeflater.setInputSegment(rBuffer, nNewOffset, nNewLength);
while (!aDeflater.needsInput()) while (!m_aDeflater.needsInput())
doDeflate(); doDeflate();
if (!bEncryptCurrentEntry) if (!m_bEncryptCurrentEntry)
aCRC.updateSegment(rBuffer, nNewOffset, nNewLength); m_aCRC.updateSegment(rBuffer, nNewOffset, nNewLength);
} }
break; break;
case STORED: case STORED:
{ {
Sequence < sal_Int8 > aTmpBuffer ( rBuffer.getConstArray(), nNewLength ); Sequence < sal_Int8 > aTmpBuffer ( rBuffer.getConstArray(), nNewLength );
aChucker.WriteBytes( aTmpBuffer ); m_aChucker.WriteBytes( aTmpBuffer );
} }
break; break;
} }
...@@ -209,84 +207,84 @@ void SAL_CALL ZipOutputStream::rawWrite( Sequence< sal_Int8 >& rBuffer, sal_Int3 ...@@ -209,84 +207,84 @@ void SAL_CALL ZipOutputStream::rawWrite( Sequence< sal_Int8 >& rBuffer, sal_Int3
throw(IOException, RuntimeException) throw(IOException, RuntimeException)
{ {
Sequence < sal_Int8 > aTmpBuffer ( rBuffer.getConstArray(), nNewLength ); Sequence < sal_Int8 > aTmpBuffer ( rBuffer.getConstArray(), nNewLength );
aChucker.WriteBytes( aTmpBuffer ); m_aChucker.WriteBytes( aTmpBuffer );
} }
void SAL_CALL ZipOutputStream::rawCloseEntry( ) void SAL_CALL ZipOutputStream::rawCloseEntry( )
throw(IOException, RuntimeException) throw(IOException, RuntimeException)
{ {
if ( pCurrentEntry->nMethod == DEFLATED && ( pCurrentEntry->nFlag & 8 ) ) if ( m_pCurrentEntry->nMethod == DEFLATED && ( m_pCurrentEntry->nFlag & 8 ) )
writeEXT(*pCurrentEntry); writeEXT(*m_pCurrentEntry);
pCurrentEntry = NULL; m_pCurrentEntry = NULL;
} }
void SAL_CALL ZipOutputStream::finish( ) void SAL_CALL ZipOutputStream::finish( )
throw(IOException, RuntimeException) throw(IOException, RuntimeException)
{ {
if (bFinished) if (m_bFinished)
return; return;
if (pCurrentEntry != NULL) if (m_pCurrentEntry != NULL)
closeEntry(); closeEntry();
if (aZipList.size() < 1) if (m_aZipList.size() < 1)
OSL_FAIL("Zip file must have at least one entry!\n"); OSL_FAIL("Zip file must have at least one entry!\n");
sal_Int32 nOffset= static_cast < sal_Int32 > (aChucker.GetPosition()); sal_Int32 nOffset= static_cast < sal_Int32 > (m_aChucker.GetPosition());
for (sal_Int32 i =0, nEnd = aZipList.size(); i < nEnd; i++) for (sal_Int32 i =0, nEnd = m_aZipList.size(); i < nEnd; i++)
writeCEN( *aZipList[i] ); writeCEN( *m_aZipList[i] );
writeEND( nOffset, static_cast < sal_Int32 > (aChucker.GetPosition()) - nOffset); writeEND( nOffset, static_cast < sal_Int32 > (m_aChucker.GetPosition()) - nOffset);
bFinished = true; m_bFinished = true;
xStream->flush(); m_xStream->flush();
} }
void ZipOutputStream::doDeflate() void ZipOutputStream::doDeflate()
{ {
sal_Int32 nLength = aDeflater.doDeflateSegment(m_aDeflateBuffer, 0, m_aDeflateBuffer.getLength()); sal_Int32 nLength = m_aDeflater.doDeflateSegment(m_aDeflateBuffer, 0, m_aDeflateBuffer.getLength());
if ( nLength > 0 ) if ( nLength > 0 )
{ {
uno::Sequence< sal_Int8 > aTmpBuffer( m_aDeflateBuffer.getConstArray(), nLength ); uno::Sequence< sal_Int8 > aTmpBuffer( m_aDeflateBuffer.getConstArray(), nLength );
if ( bEncryptCurrentEntry && m_xDigestContext.is() && m_xCipherContext.is() ) if ( m_bEncryptCurrentEntry && m_xDigestContext.is() && m_xCipherContext.is() )
{ {
// Need to update our digest before encryption... // Need to update our digest before encryption...
sal_Int32 nDiff = n_ConstDigestLength - mnDigested; sal_Int32 nDiff = n_ConstDigestLength - m_nDigested;
if ( nDiff ) if ( nDiff )
{ {
sal_Int32 nEat = ::std::min( nLength, nDiff ); sal_Int32 nEat = ::std::min( nLength, nDiff );
uno::Sequence< sal_Int8 > aTmpSeq( aTmpBuffer.getConstArray(), nEat ); uno::Sequence< sal_Int8 > aTmpSeq( aTmpBuffer.getConstArray(), nEat );
m_xDigestContext->updateDigest( aTmpSeq ); m_xDigestContext->updateDigest( aTmpSeq );
mnDigested = mnDigested + static_cast< sal_Int16 >( nEat ); m_nDigested = m_nDigested + static_cast< sal_Int16 >( nEat );
} }
// FIXME64: uno::Sequence not 64bit safe. // FIXME64: uno::Sequence not 64bit safe.
uno::Sequence< sal_Int8 > aEncryptionBuffer = m_xCipherContext->convertWithCipherContext( aTmpBuffer ); uno::Sequence< sal_Int8 > aEncryptionBuffer = m_xCipherContext->convertWithCipherContext( aTmpBuffer );
aChucker.WriteBytes( aEncryptionBuffer ); m_aChucker.WriteBytes( aEncryptionBuffer );
// the sizes as well as checksum for encrypted streams is calculated here // the sizes as well as checksum for encrypted streams is calculated here
pCurrentEntry->nCompressedSize += aEncryptionBuffer.getLength(); m_pCurrentEntry->nCompressedSize += aEncryptionBuffer.getLength();
pCurrentEntry->nSize = pCurrentEntry->nCompressedSize; m_pCurrentEntry->nSize = m_pCurrentEntry->nCompressedSize;
aCRC.update( aEncryptionBuffer ); m_aCRC.update( aEncryptionBuffer );
} }
else else
{ {
aChucker.WriteBytes ( aTmpBuffer ); m_aChucker.WriteBytes ( aTmpBuffer );
} }
} }
if ( aDeflater.finished() && bEncryptCurrentEntry && m_xDigestContext.is() && m_xCipherContext.is() ) if ( m_aDeflater.finished() && m_bEncryptCurrentEntry && m_xDigestContext.is() && m_xCipherContext.is() )
{ {
// FIXME64: sequence not 64bit safe. // FIXME64: sequence not 64bit safe.
uno::Sequence< sal_Int8 > aEncryptionBuffer = m_xCipherContext->finalizeCipherContextAndDispose(); uno::Sequence< sal_Int8 > aEncryptionBuffer = m_xCipherContext->finalizeCipherContextAndDispose();
if ( aEncryptionBuffer.getLength() ) if ( aEncryptionBuffer.getLength() )
{ {
aChucker.WriteBytes( aEncryptionBuffer ); m_aChucker.WriteBytes( aEncryptionBuffer );
// the sizes as well as checksum for encrypted streams is calculated hier // the sizes as well as checksum for encrypted streams is calculated hier
pCurrentEntry->nCompressedSize += aEncryptionBuffer.getLength(); m_pCurrentEntry->nCompressedSize += aEncryptionBuffer.getLength();
pCurrentEntry->nSize = pCurrentEntry->nCompressedSize; m_pCurrentEntry->nSize = m_pCurrentEntry->nCompressedSize;
aCRC.update( aEncryptionBuffer ); m_aCRC.update( aEncryptionBuffer );
} }
} }
} }
...@@ -294,14 +292,14 @@ void ZipOutputStream::doDeflate() ...@@ -294,14 +292,14 @@ void ZipOutputStream::doDeflate()
void ZipOutputStream::writeEND(sal_uInt32 nOffset, sal_uInt32 nLength) void ZipOutputStream::writeEND(sal_uInt32 nOffset, sal_uInt32 nLength)
throw(IOException, RuntimeException) throw(IOException, RuntimeException)
{ {
aChucker << ENDSIG; m_aChucker << ENDSIG;
aChucker << static_cast < sal_Int16 > ( 0 ); m_aChucker << static_cast < sal_Int16 > ( 0 );
aChucker << static_cast < sal_Int16 > ( 0 ); m_aChucker << static_cast < sal_Int16 > ( 0 );
aChucker << static_cast < sal_Int16 > ( aZipList.size() ); m_aChucker << static_cast < sal_Int16 > ( m_aZipList.size() );
aChucker << static_cast < sal_Int16 > ( aZipList.size() ); m_aChucker << static_cast < sal_Int16 > ( m_aZipList.size() );
aChucker << nLength; m_aChucker << nLength;
aChucker << nOffset; m_aChucker << nOffset;
aChucker << static_cast < sal_Int16 > ( 0 ); m_aChucker << static_cast < sal_Int16 > ( 0 );
} }
static sal_uInt32 getTruncated( sal_Int64 nNum, bool *pIsTruncated ) static sal_uInt32 getTruncated( sal_Int64 nNum, bool *pIsTruncated )
...@@ -324,35 +322,35 @@ void ZipOutputStream::writeCEN( const ZipEntry &rEntry ) ...@@ -324,35 +322,35 @@ void ZipOutputStream::writeCEN( const ZipEntry &rEntry )
OString sUTF8Name = OUStringToOString( rEntry.sPath, RTL_TEXTENCODING_UTF8 ); OString sUTF8Name = OUStringToOString( rEntry.sPath, RTL_TEXTENCODING_UTF8 );
sal_Int16 nNameLength = static_cast < sal_Int16 > ( sUTF8Name.getLength() ); sal_Int16 nNameLength = static_cast < sal_Int16 > ( sUTF8Name.getLength() );
aChucker << CENSIG; m_aChucker << CENSIG;
aChucker << rEntry.nVersion; m_aChucker << rEntry.nVersion;
aChucker << rEntry.nVersion; m_aChucker << rEntry.nVersion;
if (rEntry.nFlag & (1 << 4) ) if (rEntry.nFlag & (1 << 4) )
{ {
// If it's an encrypted entry, we pretend its stored plain text // If it's an encrypted entry, we pretend its stored plain text
ZipEntry *pEntry = const_cast < ZipEntry * > ( &rEntry ); ZipEntry *pEntry = const_cast < ZipEntry * > ( &rEntry );
pEntry->nFlag &= ~(1 <<4 ); pEntry->nFlag &= ~(1 <<4 );
aChucker << rEntry.nFlag; m_aChucker << rEntry.nFlag;
aChucker << static_cast < sal_Int16 > ( STORED ); m_aChucker << static_cast < sal_Int16 > ( STORED );
} }
else else
{ {
aChucker << rEntry.nFlag; m_aChucker << rEntry.nFlag;
aChucker << rEntry.nMethod; m_aChucker << rEntry.nMethod;
} }
bool bWrite64Header = false; bool bWrite64Header = false;
aChucker << static_cast < sal_uInt32> ( rEntry.nTime ); m_aChucker << static_cast < sal_uInt32> ( rEntry.nTime );
aChucker << static_cast < sal_uInt32> ( rEntry.nCrc ); m_aChucker << static_cast < sal_uInt32> ( rEntry.nCrc );
aChucker << getTruncated( rEntry.nCompressedSize, &bWrite64Header ); m_aChucker << getTruncated( rEntry.nCompressedSize, &bWrite64Header );
aChucker << getTruncated( rEntry.nSize, &bWrite64Header ); m_aChucker << getTruncated( rEntry.nSize, &bWrite64Header );
aChucker << nNameLength; m_aChucker << nNameLength;
aChucker << static_cast < sal_Int16> (0); m_aChucker << static_cast < sal_Int16> (0);
aChucker << static_cast < sal_Int16> (0); m_aChucker << static_cast < sal_Int16> (0);
aChucker << static_cast < sal_Int16> (0); m_aChucker << static_cast < sal_Int16> (0);
aChucker << static_cast < sal_Int16> (0); m_aChucker << static_cast < sal_Int16> (0);
aChucker << static_cast < sal_Int32> (0); m_aChucker << static_cast < sal_Int32> (0);
aChucker << getTruncated( rEntry.nOffset, &bWrite64Header ); m_aChucker << getTruncated( rEntry.nOffset, &bWrite64Header );
if( bWrite64Header ) if( bWrite64Header )
{ {
...@@ -363,17 +361,17 @@ void ZipOutputStream::writeCEN( const ZipEntry &rEntry ) ...@@ -363,17 +361,17 @@ void ZipOutputStream::writeCEN( const ZipEntry &rEntry )
} }
Sequence < sal_Int8 > aSequence( (sal_Int8*)sUTF8Name.getStr(), sUTF8Name.getLength() ); Sequence < sal_Int8 > aSequence( (sal_Int8*)sUTF8Name.getStr(), sUTF8Name.getLength() );
aChucker.WriteBytes( aSequence ); m_aChucker.WriteBytes( aSequence );
} }
void ZipOutputStream::writeEXT( const ZipEntry &rEntry ) void ZipOutputStream::writeEXT( const ZipEntry &rEntry )
throw(IOException, RuntimeException) throw(IOException, RuntimeException)
{ {
bool bWrite64Header = false; bool bWrite64Header = false;
aChucker << EXTSIG; m_aChucker << EXTSIG;
aChucker << static_cast < sal_uInt32> ( rEntry.nCrc ); m_aChucker << static_cast < sal_uInt32> ( rEntry.nCrc );
aChucker << getTruncated( rEntry.nCompressedSize, &bWrite64Header ); m_aChucker << getTruncated( rEntry.nCompressedSize, &bWrite64Header );
aChucker << getTruncated( rEntry.nSize, &bWrite64Header ); m_aChucker << getTruncated( rEntry.nSize, &bWrite64Header );
if( bWrite64Header ) if( bWrite64Header )
{ {
...@@ -393,40 +391,40 @@ sal_Int32 ZipOutputStream::writeLOC( const ZipEntry &rEntry ) ...@@ -393,40 +391,40 @@ sal_Int32 ZipOutputStream::writeLOC( const ZipEntry &rEntry )
OString sUTF8Name = OUStringToOString( rEntry.sPath, RTL_TEXTENCODING_UTF8 ); OString sUTF8Name = OUStringToOString( rEntry.sPath, RTL_TEXTENCODING_UTF8 );
sal_Int16 nNameLength = static_cast < sal_Int16 > ( sUTF8Name.getLength() ); sal_Int16 nNameLength = static_cast < sal_Int16 > ( sUTF8Name.getLength() );
aChucker << LOCSIG; m_aChucker << LOCSIG;
aChucker << rEntry.nVersion; m_aChucker << rEntry.nVersion;
if (rEntry.nFlag & (1 << 4) ) if (rEntry.nFlag & (1 << 4) )
{ {
// If it's an encrypted entry, we pretend its stored plain text // If it's an encrypted entry, we pretend its stored plain text
sal_Int16 nTmpFlag = rEntry.nFlag; sal_Int16 nTmpFlag = rEntry.nFlag;
nTmpFlag &= ~(1 <<4 ); nTmpFlag &= ~(1 <<4 );
aChucker << nTmpFlag; m_aChucker << nTmpFlag;
aChucker << static_cast < sal_Int16 > ( STORED ); m_aChucker << static_cast < sal_Int16 > ( STORED );
} }
else else
{ {
aChucker << rEntry.nFlag; m_aChucker << rEntry.nFlag;
aChucker << rEntry.nMethod; m_aChucker << rEntry.nMethod;
} }
bool bWrite64Header = false; bool bWrite64Header = false;
aChucker << static_cast < sal_uInt32 > (rEntry.nTime); m_aChucker << static_cast < sal_uInt32 > (rEntry.nTime);
if ((rEntry.nFlag & 8) == 8 ) if ((rEntry.nFlag & 8) == 8 )
{ {
aChucker << static_cast < sal_Int32 > (0); m_aChucker << static_cast < sal_Int32 > (0);
aChucker << static_cast < sal_Int32 > (0); m_aChucker << static_cast < sal_Int32 > (0);
aChucker << static_cast < sal_Int32 > (0); m_aChucker << static_cast < sal_Int32 > (0);
} }
else else
{ {
aChucker << static_cast < sal_uInt32 > (rEntry.nCrc); m_aChucker << static_cast < sal_uInt32 > (rEntry.nCrc);
aChucker << getTruncated( rEntry.nCompressedSize, &bWrite64Header ); m_aChucker << getTruncated( rEntry.nCompressedSize, &bWrite64Header );
aChucker << getTruncated( rEntry.nSize, &bWrite64Header ); m_aChucker << getTruncated( rEntry.nSize, &bWrite64Header );
} }
aChucker << nNameLength; m_aChucker << nNameLength;
aChucker << static_cast < sal_Int16 > (0); m_aChucker << static_cast < sal_Int16 > (0);
if( bWrite64Header ) if( bWrite64Header )
{ {
...@@ -437,7 +435,7 @@ sal_Int32 ZipOutputStream::writeLOC( const ZipEntry &rEntry ) ...@@ -437,7 +435,7 @@ sal_Int32 ZipOutputStream::writeLOC( const ZipEntry &rEntry )
} }
Sequence < sal_Int8 > aSequence( (sal_Int8*)sUTF8Name.getStr(), sUTF8Name.getLength() ); Sequence < sal_Int8 > aSequence( (sal_Int8*)sUTF8Name.getStr(), sUTF8Name.getLength() );
aChucker.WriteBytes( aSequence ); m_aChucker.WriteBytes( aSequence );
return LOCHDR + nNameLength; return LOCHDR + nNameLength;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment