summaryrefslogtreecommitdiff
path: root/package/source/zippackage
diff options
context:
space:
mode:
authorMatúš Kukan <matus.kukan@collabora.com>2014-10-20 21:13:50 +0200
committerMatúš Kukan <matus.kukan@collabora.com>2014-11-17 10:49:20 +0100
commit2d92a84a6aac37e34d1699fdebe0270468b4f746 (patch)
tree0ea2d2eb83775800e6bbf0106ef26cd09f39137e /package/source/zippackage
parent15678e7483369fae400c3b289c85e63001b3d131 (diff)
package: Move most ZipOutputEntry's methods back to ZipOutputStream
We want to use ZipOutputEntry only for deflating (and maybe rename it). ca13a9377e4a36436e4c82bb33648d0f3b6db6f5 was not a good idea because the data still needs to be written sequentially anyway. Otherwise it's hard to get offset positions of individual entries right. Since this commit rawCloseEntry needs to be called always; also when we use write&closeEntry because we don't call writeEXT in closeEntry anymore. Need to rename and add comments later. Change-Id: I03bd48ca6e108e6253a77a137746165909ca3c3d
Diffstat (limited to 'package/source/zippackage')
-rw-r--r--package/source/zippackage/ZipPackage.cxx21
-rw-r--r--package/source/zippackage/ZipPackageFolder.cxx6
-rw-r--r--package/source/zippackage/ZipPackageStream.cxx12
3 files changed, 20 insertions, 19 deletions
diff --git a/package/source/zippackage/ZipPackage.cxx b/package/source/zippackage/ZipPackage.cxx
index a631cabb14ba..a05320a48951 100644
--- a/package/source/zippackage/ZipPackage.cxx
+++ b/package/source/zippackage/ZipPackage.cxx
@@ -989,7 +989,7 @@ void ZipPackage::WriteMimetypeMagicFile( ZipOutputStream& aZipOut )
pEntry->sPath = sMime;
pEntry->nMethod = STORED;
pEntry->nSize = pEntry->nCompressedSize = nBufferLength;
- pEntry->nTime = ZipOutputEntry::getCurrentDosTime();
+ pEntry->nTime = ZipOutputStream::getCurrentDosTime();
CRC32 aCRC32;
aCRC32.update( aType );
@@ -997,10 +997,11 @@ void ZipPackage::WriteMimetypeMagicFile( ZipOutputStream& aZipOut )
try
{
- ZipOutputEntry aZipEntry(m_xContext, aZipOut.getChucker(), *pEntry, NULL);
+ aZipOut.putNextEntry(*pEntry);
+ ZipOutputEntry aZipEntry(m_xContext, &aZipOut, *pEntry, NULL);
aZipEntry.write(aType, 0, nBufferLength);
aZipEntry.closeEntry();
- aZipOut.addEntry(pEntry);
+ aZipOut.rawCloseEntry();
}
catch ( const ::com::sun::star::io::IOException & r )
{
@@ -1023,7 +1024,7 @@ void ZipPackage::WriteManifest( ZipOutputStream& aZipOut, const vector< uno::Seq
pEntry->nMethod = DEFLATED;
pEntry->nCrc = -1;
pEntry->nSize = pEntry->nCompressedSize = -1;
- pEntry->nTime = ZipOutputEntry::getCurrentDosTime();
+ pEntry->nTime = ZipOutputStream::getCurrentDosTime();
// Convert vector into a uno::Sequence
uno::Sequence < uno::Sequence < PropertyValue > > aManifestSequence ( aManList.size() );
@@ -1040,10 +1041,11 @@ void ZipPackage::WriteManifest( ZipOutputStream& aZipOut, const vector< uno::Seq
pBuffer->realloc( nBufferLength );
// the manifest.xml is never encrypted - so pass an empty reference
- ZipOutputEntry aZipEntry(m_xContext, aZipOut.getChucker(), *pEntry, NULL);
+ aZipOut.putNextEntry(*pEntry);
+ ZipOutputEntry aZipEntry(m_xContext, &aZipOut, *pEntry, NULL);
aZipEntry.write(pBuffer->getSequence(), 0, nBufferLength);
aZipEntry.closeEntry();
- aZipOut.addEntry(pEntry);
+ aZipOut.rawCloseEntry();
}
void ZipPackage::WriteContentTypes( ZipOutputStream& aZipOut, const vector< uno::Sequence < PropertyValue > >& aManList )
@@ -1056,7 +1058,7 @@ void ZipPackage::WriteContentTypes( ZipOutputStream& aZipOut, const vector< uno:
pEntry->nMethod = DEFLATED;
pEntry->nCrc = -1;
pEntry->nSize = pEntry->nCompressedSize = -1;
- pEntry->nTime = ZipOutputEntry::getCurrentDosTime();
+ pEntry->nTime = ZipOutputStream::getCurrentDosTime();
// Convert vector into a uno::Sequence
// TODO/LATER: use Defaulst entries in future
@@ -1091,10 +1093,11 @@ void ZipPackage::WriteContentTypes( ZipOutputStream& aZipOut, const vector< uno:
pBuffer->realloc( nBufferLength );
// there is no encryption in this format currently
- ZipOutputEntry aZipEntry(m_xContext, aZipOut.getChucker(), *pEntry, NULL);
+ aZipOut.putNextEntry(*pEntry);
+ ZipOutputEntry aZipEntry(m_xContext, &aZipOut, *pEntry, NULL);
aZipEntry.write(pBuffer->getSequence(), 0, nBufferLength);
aZipEntry.closeEntry();
- aZipOut.addEntry(pEntry);
+ aZipOut.rawCloseEntry();
}
void ZipPackage::ConnectTo( const uno::Reference< io::XInputStream >& xInStream )
diff --git a/package/source/zippackage/ZipPackageFolder.cxx b/package/source/zippackage/ZipPackageFolder.cxx
index c2e5a4fa2f9a..a6b2e5c139a7 100644
--- a/package/source/zippackage/ZipPackageFolder.cxx
+++ b/package/source/zippackage/ZipPackageFolder.cxx
@@ -21,7 +21,6 @@
#include <ZipPackageFolder.hxx>
#include <ZipFile.hxx>
-#include <ZipOutputEntry.hxx>
#include <ZipOutputStream.hxx>
#include <ZipPackageStream.hxx>
#include <PackageConstants.hxx>
@@ -338,9 +337,8 @@ void ZipPackageFolder::saveContents(
try
{
- ZipOutputEntry aZipEntry(m_xContext, rZipOut.getChucker(), *pTempEntry, NULL, false);
- aZipEntry.rawCloseEntry();
- rZipOut.addEntry(pTempEntry);
+ rZipOut.putNextEntry( *pTempEntry );
+ rZipOut.rawCloseEntry();
}
catch ( ZipException& )
{
diff --git a/package/source/zippackage/ZipPackageStream.cxx b/package/source/zippackage/ZipPackageStream.cxx
index a4651d78b298..7547e9cf0dc5 100644
--- a/package/source/zippackage/ZipPackageStream.cxx
+++ b/package/source/zippackage/ZipPackageStream.cxx
@@ -674,7 +674,7 @@ bool ZipPackageStream::saveChild(
if ( bRawStream )
xStream->skipBytes( m_nMagicalHackPos );
- ZipOutputEntry aZipEntry(m_xContext, rZipOut.getChucker(), *pTempEntry, this, false);
+ rZipOut.putNextEntry(*pTempEntry);
// the entry is provided to the ZipOutputStream that will delete it
pAutoTempEntry.release();
@@ -684,12 +684,11 @@ bool ZipPackageStream::saveChild(
do
{
nLength = xStream->readBytes( aSeq, n_ConstBufferSize );
- aZipEntry.rawWrite(aSeq, 0, nLength);
+ rZipOut.rawWrite(aSeq, 0, nLength);
}
while ( nLength == n_ConstBufferSize );
- aZipEntry.rawCloseEntry();
- rZipOut.addEntry(pTempEntry);
+ rZipOut.rawCloseEntry();
}
catch ( ZipException& )
{
@@ -732,7 +731,8 @@ bool ZipPackageStream::saveChild(
try
{
- ZipOutputEntry aZipEntry(m_xContext, rZipOut.getChucker(), *pTempEntry, this, bToBeEncrypted);
+ rZipOut.putNextEntry(*pTempEntry, bToBeEncrypted);
+ ZipOutputEntry aZipEntry(m_xContext, &rZipOut, *pTempEntry, this, bToBeEncrypted);
// the entry is provided to the ZipOutputStream that will delete it
pAutoTempEntry.release();
@@ -746,7 +746,7 @@ bool ZipPackageStream::saveChild(
while ( nLength == n_ConstBufferSize );
aZipEntry.closeEntry();
- rZipOut.addEntry(pTempEntry);
+ rZipOut.rawCloseEntry();
}
catch ( ZipException& )
{