diff options
author | Matúš Kukan <matus.kukan@collabora.com> | 2014-12-14 00:11:53 +0100 |
---|---|---|
committer | Matúš Kukan <matus.kukan@collabora.com> | 2014-12-14 00:21:20 +0100 |
commit | f92183833fa569006602ac7e93c906d2094e0d4d (patch) | |
tree | 9eade04a981394c2d3129b4667f5c20d8e46dee5 /package/source/zipapi/ZipOutputStream.cxx | |
parent | 43eca2d9f8d87363b5f4bf8c5df92bf06be08c08 (diff) |
package: Better to use temporary files for huge memory zip streams
ZipPackageBuffer was holding the whole compressed data stream in one
uno::Sequence which seems to be a lot for big documents in some cases.
Change-Id: Ib10d00ac54df9674231f4bbf047fab7e9b0a7d45
Diffstat (limited to 'package/source/zipapi/ZipOutputStream.cxx')
-rw-r--r-- | package/source/zipapi/ZipOutputStream.cxx | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/package/source/zipapi/ZipOutputStream.cxx b/package/source/zipapi/ZipOutputStream.cxx index 058cb3d2224d..5c49b1bfc6b7 100644 --- a/package/source/zipapi/ZipOutputStream.cxx +++ b/package/source/zipapi/ZipOutputStream.cxx @@ -20,6 +20,7 @@ #include <ZipOutputStream.hxx> #include <com/sun/star/packages/zip/ZipConstants.hpp> +#include <com/sun/star/io/XInputStream.hpp> #include <com/sun/star/io/XOutputStream.hpp> #include <comphelper/storagehelper.hxx> #include <osl/diagnose.h> @@ -101,7 +102,20 @@ void ZipOutputStream::finish() for (size_t i = 0; i < m_aEntries.size(); i++) { writeLOC(m_aEntries[i]->getZipEntry(), m_aEntries[i]->isEncrypt()); - rawWrite(m_aEntries[i]->getData()); + + sal_Int32 nRead; + uno::Sequence< sal_Int8 > aSequence(n_ConstBufferSize); + uno::Reference< io::XInputStream > xInput = m_aEntries[i]->getData(); + do + { + nRead = xInput->readBytes(aSequence, n_ConstBufferSize); + if (nRead < n_ConstBufferSize) + aSequence.realloc(nRead); + + rawWrite(aSequence); + } + while (nRead == n_ConstBufferSize); + rawCloseEntry(m_aEntries[i]->isEncrypt()); m_aEntries[i]->getZipPackageStream()->successfullyWritten(m_aEntries[i]->getZipEntry()); |