22#include <com/sun/star/packages/zip/ZipConstants.hpp>
23#include <com/sun/star/io/IOException.hpp>
24#include <com/sun/star/io/XInputStream.hpp>
28#include <osl/thread.hxx>
40using namespace com::sun::star::packages::zip::ZipConstants;
46, mpThreadTaskTag(
comphelper::ThreadPool::createThreadTaskTag() )
48, m_pCurrentEntry(nullptr)
58 if (pEntry->
nTime == -1)
63 pEntry->
nFlag = 1 << 11;
98 const std::exception_ptr& rCaughtException(pCandidate->getParallelDeflateException());
106 writeLOC(pCandidate->getZipEntry(), pCandidate->isEncrypt());
110 uno::Reference< io::XInputStream > xInput = pCandidate->getData();
115 aSequence.realloc(nRead);
124 pCandidate->getZipPackageStream()->successfullyWritten(pCandidate->getZipEntry());
125 pCandidate->deleteBufferFile();
130 std::vector< ZipOutputEntryInThread* > aNonFinishedEntries;
134 if(pEntry->isFinished())
140 aNonFinishedEntries.push_back(pEntry);
156 std::this_thread::sleep_for(std::chrono::microseconds(100));
163 assert(!
m_aZipList.empty() &&
"Zip file must have at least one entry!");
210 if( nNum >= 0xffffffff )
212 *pIsTruncated =
true;
216 return static_cast< sal_uInt32
>( nNum );
222 throw IOException(
"Unexpected character is used in file name." );
225 sal_Int16 nNameLength =
static_cast < sal_Int16
> ( sUTF8Name.getLength() );
232 bool bWrite64Header =
false;
258 bool bWrite64Header =
false;
290 assert(!
m_pCurrentEntry &&
"Forgot to close an entry with rawCloseEntry()?");
296 throw IOException(
"Unexpected character is used in file name." );
299 sal_Int16 nNameLength =
static_cast < sal_Int16
> ( sUTF8Name.getLength() );
311 bool bWrite64Header =
false;
314 if ((rEntry.
nFlag & 8) == 8 )
342 oslDateTime aDateTime;
343 TimeValue aTimeValue;
344 osl_getSystemTime ( &aTimeValue );
345 osl_getDateTimeFromTimeValue( &aTimeValue, &aDateTime);
356 assert(aDateTime.Year > 1980 && aDateTime.Year < 2108);
358 sal_uInt32 nYear =
static_cast <sal_uInt32
> (aDateTime.Year);
366 sal_uInt32 nResult =
static_cast < sal_uInt32
>( ( ( ( aDateTime.Day) +
367 ( 32 * (aDateTime.Month)) +
368 ( 512 * nYear ) ) << 16) |
369 ( ( aDateTime.Seconds/2) +
370 ( 32 * aDateTime.Minutes) +
371 ( 2048 *
static_cast <sal_uInt32
> (aDateTime.Hours) ) ) );
const sal_Int32 n_ConstBufferSize
static sal_uInt32 getTruncated(sal_Int64 nNum, bool *pIsTruncated)
void WriteUInt64(sal_uInt64 nuInt64)
void WriteInt32(sal_Int32 nInt32)
void WriteUInt32(sal_uInt32 nuInt32)
void WriteInt16(sal_Int16 nInt16)
void WriteBytes(const css::uno::Sequence< sal_Int8 > &aData)
void writeLOC(ZipEntry *pEntry, bool bEncrypt=false)
void consumeFinishedScheduledThreadTaskEntries()
void rawCloseEntry(bool bEncrypt=false)
const css::uno::Reference< css::io::XOutputStream > & getStream() const
ZipEntry * m_pCurrentEntry
void writeDataDescriptor(const ZipEntry &rEntry)
void writeCEN(const ZipEntry &rEntry)
void writeEND(sal_uInt32 nOffset, sal_uInt32 nLength)
::std::vector< ZipEntry * > m_aZipList
void rawWrite(const css::uno::Sequence< sal_Int8 > &rBuffer)
std::vector< ZipOutputEntryInThread * > m_aEntries
static void setEntry(ZipEntry *pEntry)
std::shared_ptr< comphelper::ThreadTaskTag > mpThreadTaskTag
void writeExtraFields(const ZipEntry &rEntry)
void addDeflatingThreadTask(ZipOutputEntryInThread *pEntry, std::unique_ptr< comphelper::ThreadTask > pThreadTask)
ZipOutputStream(const css::uno::Reference< css::io::XOutputStream > &xOStream)
This class is used to write Zip files.
void consumeScheduledThreadTaskEntry(std::unique_ptr< ZipOutputEntryInThread > pCandidate)
static sal_uInt32 getCurrentDosTime()
css::uno::Reference< css::io::XOutputStream > m_xStream
void reduceScheduledThreadTasksToGivenNumberOrLess(std::size_t nThreadTasks)
std::exception_ptr m_aDeflateException
static bool IsValidZipEntryFileName(std::u16string_view aName, bool bSlashAllowed)
static ThreadPool & getSharedOptimalPool()
void waitUntilDone(const std::shared_ptr< ThreadTaskTag > &, bool bJoin=true)
void pushTask(std::unique_ptr< ThreadTask > pTask)
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
sal_Int64 nCompressedSize
Reference< XStream > m_xStream