diff options
author | Matúš Kukan <matus.kukan@collabora.com> | 2014-10-21 12:21:22 +0200 |
---|---|---|
committer | Matúš Kukan <matus.kukan@collabora.com> | 2014-11-17 10:49:22 +0100 |
commit | 30f80f12fb1db4c9c6f19fcfda4e796891b6e03c (patch) | |
tree | dba8555797a48171251a74a2a0911816263d9d3e /package | |
parent | ef8e7eabe1e53a99bbfeac0297faa9592cd18175 (diff) |
package: Do not use hacky bit 1<<4 in ZipEntry::nFlag
Change-Id: I504f5c0c9aa9b655ffb53d9820a33677dad6aa08
Diffstat (limited to 'package')
-rw-r--r-- | package/inc/ZipOutputStream.hxx | 1 | ||||
-rw-r--r-- | package/source/zipapi/ZipOutputStream.cxx | 37 | ||||
-rw-r--r-- | package/source/zippackage/ZipPackageStream.cxx | 7 |
3 files changed, 11 insertions, 34 deletions
diff --git a/package/inc/ZipOutputStream.hxx b/package/inc/ZipOutputStream.hxx index 0c8dafe6fee2..2d78eb78c567 100644 --- a/package/inc/ZipOutputStream.hxx +++ b/package/inc/ZipOutputStream.hxx @@ -37,6 +37,7 @@ class ZipOutputStream ByteChucker m_aChucker; bool m_bFinished; ZipEntry *m_pCurrentEntry; + bool m_bEncrypt; public: ZipOutputStream( diff --git a/package/source/zipapi/ZipOutputStream.cxx b/package/source/zipapi/ZipOutputStream.cxx index d4f045668a8f..25cdb18a6990 100644 --- a/package/source/zipapi/ZipOutputStream.cxx +++ b/package/source/zipapi/ZipOutputStream.cxx @@ -66,10 +66,7 @@ void ZipOutputStream::putNextEntry( ZipEntry& rEntry, bool bEncrypt ) rEntry.nSize = rEntry.nCompressedSize = 0; rEntry.nFlag |= 8; } - if (bEncrypt) - { - rEntry.nFlag |= 1 << 4; - } + m_bEncrypt = bEncrypt; sal_Int32 nLOCLength = writeLOC(rEntry); rEntry.nOffset = m_aChucker.GetPosition() - nLOCLength; @@ -88,6 +85,10 @@ void ZipOutputStream::rawCloseEntry() { if ( m_pCurrentEntry->nMethod == DEFLATED && ( m_pCurrentEntry->nFlag & 8 ) ) writeEXT(*m_pCurrentEntry); + + if (m_bEncrypt) + m_pCurrentEntry->nMethod = STORED; + m_pCurrentEntry = NULL; } @@ -144,19 +145,8 @@ void ZipOutputStream::writeCEN( const ZipEntry &rEntry ) m_aChucker << CENSIG; m_aChucker << rEntry.nVersion; m_aChucker << rEntry.nVersion; - if (rEntry.nFlag & (1 << 4) ) - { - // If it's an encrypted entry, we pretend its stored plain text - ZipEntry *pEntry = const_cast < ZipEntry * > ( &rEntry ); - pEntry->nFlag &= ~(1 <<4 ); - m_aChucker << rEntry.nFlag; - m_aChucker << static_cast < sal_Int16 > ( STORED ); - } - else - { - m_aChucker << rEntry.nFlag; - m_aChucker << rEntry.nMethod; - } + m_aChucker << rEntry.nFlag; + m_aChucker << rEntry.nMethod; bool bWrite64Header = false; m_aChucker << static_cast < sal_uInt32> ( rEntry.nTime ); @@ -214,19 +204,12 @@ sal_Int32 ZipOutputStream::writeLOC( const ZipEntry &rEntry ) m_aChucker << LOCSIG; m_aChucker << rEntry.nVersion; - if (rEntry.nFlag & (1 << 4) ) - { - // If it's an encrypted entry, we pretend its stored plain text - sal_Int16 nTmpFlag = rEntry.nFlag; - nTmpFlag &= ~(1 <<4 ); - m_aChucker << nTmpFlag; + m_aChucker << rEntry.nFlag; + // If it's an encrypted entry, we pretend its stored plain text + if (m_bEncrypt) m_aChucker << static_cast < sal_Int16 > ( STORED ); - } else - { - m_aChucker << rEntry.nFlag; m_aChucker << rEntry.nMethod; - } bool bWrite64Header = false; diff --git a/package/source/zippackage/ZipPackageStream.cxx b/package/source/zippackage/ZipPackageStream.cxx index 590ff0e404d7..c5f8a31c4f68 100644 --- a/package/source/zippackage/ZipPackageStream.cxx +++ b/package/source/zippackage/ZipPackageStream.cxx @@ -809,13 +809,6 @@ bool ZipPackageStream::saveChild( // Then copy it back afterwards... ZipPackageFolder::copyZipEntry ( aEntry, *pTempEntry ); - // Remove hacky bit from entry flags - if ( aEntry.nFlag & ( 1 << 4 ) ) - { - aEntry.nFlag &= ~( 1 << 4 ); - aEntry.nMethod = STORED; - } - // TODO/LATER: get rid of this hack ( the encrypted stream size property is changed during saving ) if ( IsEncrypted() ) setSize( nOwnStreamOrigSize ); |