LibreOffice Module package (master) 1
ZipOutputStream.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19#ifndef INCLUDED_PACKAGE_INC_ZIPOUTPUTSTREAM_HXX
20#define INCLUDED_PACKAGE_INC_ZIPOUTPUTSTREAM_HXX
21
22#include <com/sun/star/uno/Reference.hxx>
23#include <com/sun/star/io/XOutputStream.hpp>
24
25#include "ByteChucker.hxx"
27
28#include <cstddef>
29#include <exception>
30#include <vector>
31
32struct ZipEntry;
33class ZipOutputEntry;
36
38{
39 css::uno::Reference< css::io::XOutputStream > m_xStream;
40 ::std::vector < ZipEntry * > m_aZipList;
41 std::shared_ptr<comphelper::ThreadTaskTag> mpThreadTaskTag;
42
45 std::vector< ZipOutputEntryInThread* > m_aEntries;
46 std::exception_ptr m_aDeflateException;
47
48public:
50 const css::uno::Reference< css::io::XOutputStream > &xOStream );
52
53 void addDeflatingThreadTask( ZipOutputEntryInThread *pEntry, std::unique_ptr<comphelper::ThreadTask> pThreadTask );
54
57 void writeLOC( ZipEntry *pEntry, bool bEncrypt = false );
60 void rawWrite( const css::uno::Sequence< sal_Int8 >& rBuffer );
63 void rawCloseEntry( bool bEncrypt = false );
64
67 void finish();
68 const css::uno::Reference< css::io::XOutputStream >& getStream() const;
69
70 static sal_uInt32 getCurrentDosTime();
71 static void setEntry( ZipEntry *pEntry );
72
73private:
76 void writeEND(sal_uInt32 nOffset, sal_uInt32 nLength);
79 void writeCEN( const ZipEntry &rEntry );
82 void writeDataDescriptor( const ZipEntry &rEntry );
83 void writeExtraFields( const ZipEntry& rEntry );
84
85 // ScheduledThread handling helpers
86 void consumeScheduledThreadTaskEntry(std::unique_ptr<ZipOutputEntryInThread> pCandidate);
88
89public:
91 std::size_t nThreadTasks);
92
93 const std::shared_ptr<comphelper::ThreadTaskTag>& getThreadTaskTag() const { return mpThreadTaskTag; }
94};
95
96#endif
97
98/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
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
const std::shared_ptr< comphelper::ThreadTaskTag > & getThreadTaskTag() const
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)
ByteChucker m_aChucker
static sal_uInt32 getCurrentDosTime()
css::uno::Reference< css::io::XOutputStream > m_xStream
void reduceScheduledThreadTasksToGivenNumberOrLess(std::size_t nThreadTasks)
std::exception_ptr m_aDeflateException