Kaydet (Commit) 30f80f12 authored tarafından Matúš Kukan's avatar Matúš Kukan

package: Do not use hacky bit 1<<4 in ZipEntry::nFlag

Change-Id: I504f5c0c9aa9b655ffb53d9820a33677dad6aa08
üst ef8e7eab
...@@ -37,6 +37,7 @@ class ZipOutputStream ...@@ -37,6 +37,7 @@ class ZipOutputStream
ByteChucker m_aChucker; ByteChucker m_aChucker;
bool m_bFinished; bool m_bFinished;
ZipEntry *m_pCurrentEntry; ZipEntry *m_pCurrentEntry;
bool m_bEncrypt;
public: public:
ZipOutputStream( ZipOutputStream(
......
...@@ -66,10 +66,7 @@ void ZipOutputStream::putNextEntry( ZipEntry& rEntry, bool bEncrypt ) ...@@ -66,10 +66,7 @@ void ZipOutputStream::putNextEntry( ZipEntry& rEntry, bool bEncrypt )
rEntry.nSize = rEntry.nCompressedSize = 0; rEntry.nSize = rEntry.nCompressedSize = 0;
rEntry.nFlag |= 8; rEntry.nFlag |= 8;
} }
if (bEncrypt) m_bEncrypt = bEncrypt;
{
rEntry.nFlag |= 1 << 4;
}
sal_Int32 nLOCLength = writeLOC(rEntry); sal_Int32 nLOCLength = writeLOC(rEntry);
rEntry.nOffset = m_aChucker.GetPosition() - nLOCLength; rEntry.nOffset = m_aChucker.GetPosition() - nLOCLength;
...@@ -88,6 +85,10 @@ void ZipOutputStream::rawCloseEntry() ...@@ -88,6 +85,10 @@ void ZipOutputStream::rawCloseEntry()
{ {
if ( m_pCurrentEntry->nMethod == DEFLATED && ( m_pCurrentEntry->nFlag & 8 ) ) if ( m_pCurrentEntry->nMethod == DEFLATED && ( m_pCurrentEntry->nFlag & 8 ) )
writeEXT(*m_pCurrentEntry); writeEXT(*m_pCurrentEntry);
if (m_bEncrypt)
m_pCurrentEntry->nMethod = STORED;
m_pCurrentEntry = NULL; m_pCurrentEntry = NULL;
} }
...@@ -144,19 +145,8 @@ void ZipOutputStream::writeCEN( const ZipEntry &rEntry ) ...@@ -144,19 +145,8 @@ void ZipOutputStream::writeCEN( const ZipEntry &rEntry )
m_aChucker << CENSIG; m_aChucker << CENSIG;
m_aChucker << rEntry.nVersion; m_aChucker << rEntry.nVersion;
m_aChucker << rEntry.nVersion; m_aChucker << rEntry.nVersion;
if (rEntry.nFlag & (1 << 4) ) m_aChucker << rEntry.nFlag;
{ m_aChucker << rEntry.nMethod;
// 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;
}
bool bWrite64Header = false; bool bWrite64Header = false;
m_aChucker << static_cast < sal_uInt32> ( rEntry.nTime ); m_aChucker << static_cast < sal_uInt32> ( rEntry.nTime );
...@@ -214,19 +204,12 @@ sal_Int32 ZipOutputStream::writeLOC( const ZipEntry &rEntry ) ...@@ -214,19 +204,12 @@ sal_Int32 ZipOutputStream::writeLOC( const ZipEntry &rEntry )
m_aChucker << LOCSIG; m_aChucker << LOCSIG;
m_aChucker << rEntry.nVersion; m_aChucker << rEntry.nVersion;
if (rEntry.nFlag & (1 << 4) ) m_aChucker << rEntry.nFlag;
{ // If it's an encrypted entry, we pretend its stored plain text
// If it's an encrypted entry, we pretend its stored plain text if (m_bEncrypt)
sal_Int16 nTmpFlag = rEntry.nFlag;
nTmpFlag &= ~(1 <<4 );
m_aChucker << nTmpFlag;
m_aChucker << static_cast < sal_Int16 > ( STORED ); m_aChucker << static_cast < sal_Int16 > ( STORED );
}
else else
{
m_aChucker << rEntry.nFlag;
m_aChucker << rEntry.nMethod; m_aChucker << rEntry.nMethod;
}
bool bWrite64Header = false; bool bWrite64Header = false;
......
...@@ -809,13 +809,6 @@ bool ZipPackageStream::saveChild( ...@@ -809,13 +809,6 @@ bool ZipPackageStream::saveChild(
// Then copy it back afterwards... // Then copy it back afterwards...
ZipPackageFolder::copyZipEntry ( aEntry, *pTempEntry ); 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 ) // TODO/LATER: get rid of this hack ( the encrypted stream size property is changed during saving )
if ( IsEncrypted() ) if ( IsEncrypted() )
setSize( nOwnStreamOrigSize ); setSize( nOwnStreamOrigSize );
......
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