Mercurial > hg > orthanc
annotate OrthancFramework/Sources/Compression/ZipWriter.cpp @ 4744:c125632f9468
cppcheck
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 06 Jul 2021 13:29:57 +0200 |
parents | 13efc0967cea |
children | b3957ddd88f1 |
rev | line source |
---|---|
136 | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
1900 | 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
1288
6e7e5ed91c2d
upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1278
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
4437
d9473bd5ed43
upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4297
diff
changeset
|
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium |
136 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
8 * modify it under the terms of the GNU Lesser General Public License |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
9 * as published by the Free Software Foundation, either version 3 of |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
10 * the License, or (at your option) any later version. |
136 | 11 * |
12 * This program is distributed in the hope that it will be useful, but | |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
15 * Lesser General Public License for more details. |
136 | 16 * |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
17 * You should have received a copy of the GNU Lesser General Public |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
18 * License along with this program. If not, see |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
19 * <http://www.gnu.org/licenses/>. |
136 | 20 **/ |
21 | |
824
a811bdf8b8eb
precompiled headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
689
diff
changeset
|
22 |
a811bdf8b8eb
precompiled headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
689
diff
changeset
|
23 #include "../PrecompiledHeaders.h" |
a811bdf8b8eb
precompiled headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
689
diff
changeset
|
24 |
658
e8e59e80868c
note about glog-0.3.3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
644
diff
changeset
|
25 #ifndef NOMINMAX |
568 | 26 #define NOMINMAX |
27 #endif | |
136 | 28 |
81 | 29 #include "ZipWriter.h" |
30 | |
1278 | 31 #include <limits> |
32 #include <boost/filesystem.hpp> | |
81 | 33 #include <boost/date_time/posix_time/posix_time.hpp> |
34 | |
1278 | 35 #include "../../Resources/ThirdParty/minizip/zip.h" |
4672
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
36 #include "../Logging.h" |
81 | 37 #include "../OrthancException.h" |
4672
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
38 #include "../SystemToolbox.h" |
81 | 39 |
40 | |
41 static void PrepareFileInfo(zip_fileinfo& zfi) | |
42 { | |
43 memset(&zfi, 0, sizeof(zfi)); | |
44 | |
45 using namespace boost::posix_time; | |
46 ptime now = second_clock::local_time(); | |
47 | |
48 boost::gregorian::date today = now.date(); | |
49 ptime midnight(today); | |
50 | |
51 time_duration sinceMidnight = now - midnight; | |
3128
972cc98959a3
fix build of civetweb for Visual Studio 2008 and LSB
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
52 zfi.tmz_date.tm_sec = static_cast<unsigned int>(sinceMidnight.seconds()); // seconds after the minute - [0,59] |
972cc98959a3
fix build of civetweb for Visual Studio 2008 and LSB
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
53 zfi.tmz_date.tm_min = static_cast<unsigned int>(sinceMidnight.minutes()); // minutes after the hour - [0,59] |
972cc98959a3
fix build of civetweb for Visual Studio 2008 and LSB
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
54 zfi.tmz_date.tm_hour = static_cast<unsigned int>(sinceMidnight.hours()); // hours since midnight - [0,23] |
81 | 55 |
56 // http://www.boost.org/doc/libs/1_35_0/doc/html/boost/gregorian/greg_day.html | |
57 zfi.tmz_date.tm_mday = today.day(); // day of the month - [1,31] | |
58 | |
59 // http://www.boost.org/doc/libs/1_35_0/doc/html/boost/gregorian/greg_month.html | |
60 zfi.tmz_date.tm_mon = today.month() - 1; // months since January - [0,11] | |
61 | |
62 // http://www.boost.org/doc/libs/1_35_0/doc/html/boost/gregorian/greg_year.html | |
63 zfi.tmz_date.tm_year = today.year(); // years - [1980..2044] | |
64 } | |
65 | |
66 | |
67 | |
68 namespace Orthanc | |
69 { | |
4670
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
70 ZipWriter::MemoryStream::MemoryStream(std::string& target) : |
4672
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
71 target_(target), |
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
72 archiveSize_(0) |
4670
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
73 { |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
74 } |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
75 |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
76 |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
77 void ZipWriter::MemoryStream::Write(const std::string& chunk) |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
78 { |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
79 chunked_.AddChunk(chunk); |
4672
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
80 archiveSize_ += chunk.size(); |
4670
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
81 } |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
82 |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
83 |
4672
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
84 uint64_t ZipWriter::MemoryStream::GetArchiveSize() const |
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
85 { |
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
86 return archiveSize_; |
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
87 } |
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
88 |
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
89 |
4670
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
90 void ZipWriter::MemoryStream::Close() |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
91 { |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
92 chunked_.Flatten(target_); |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
93 } |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
94 |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
95 |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
96 void ZipWriter::BufferWithSeek::CheckInvariants() const |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
97 { |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
98 #if !defined(NDEBUG) |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
99 assert(chunks_.GetNumBytes() == 0 || |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
100 flattened_.empty()); |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
101 |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
102 assert(currentPosition_ <= GetSize()); |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
103 |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
104 if (currentPosition_ < GetSize()) |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
105 { |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
106 assert(chunks_.GetNumBytes() == 0); |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
107 assert(!flattened_.empty()); |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
108 } |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
109 #endif |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
110 } |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
111 |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
112 |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
113 ZipWriter::BufferWithSeek::BufferWithSeek() : |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
114 currentPosition_(0) |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
115 { |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
116 CheckInvariants(); |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
117 } |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
118 |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
119 |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
120 ZipWriter::BufferWithSeek::~BufferWithSeek() |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
121 { |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
122 CheckInvariants(); |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
123 } |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
124 |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
125 |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
126 size_t ZipWriter::BufferWithSeek::GetPosition() const |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
127 { |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
128 return currentPosition_; |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
129 } |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
130 |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
131 |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
132 size_t ZipWriter::BufferWithSeek::GetSize() const |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
133 { |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
134 if (flattened_.empty()) |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
135 { |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
136 return chunks_.GetNumBytes(); |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
137 } |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
138 else |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
139 { |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
140 return flattened_.size(); |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
141 } |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
142 } |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
143 |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
144 |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
145 void ZipWriter::BufferWithSeek::Write(const void* data, |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
146 size_t size) |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
147 { |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
148 CheckInvariants(); |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
149 |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
150 if (size != 0) |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
151 { |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
152 if (currentPosition_ < GetSize()) |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
153 { |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
154 if (currentPosition_ + size > flattened_.size()) |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
155 { |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
156 throw OrthancException(ErrorCode_ParameterOutOfRange); |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
157 } |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
158 else |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
159 { |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
160 memcpy(&flattened_[currentPosition_], data, size); |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
161 } |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
162 } |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
163 else |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
164 { |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
165 if (!flattened_.empty()) |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
166 { |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
167 assert(chunks_.GetNumBytes() == 0); |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
168 chunks_.AddChunk(flattened_); |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
169 flattened_.clear(); |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
170 } |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
171 |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
172 chunks_.AddChunk(data, size); |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
173 } |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
174 |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
175 currentPosition_ += size; |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
176 } |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
177 |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
178 CheckInvariants(); |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
179 } |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
180 |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
181 |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
182 void ZipWriter::BufferWithSeek::Write(const std::string& data) |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
183 { |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
184 if (!data.empty()) |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
185 { |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
186 Write(data.c_str(), data.size()); |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
187 } |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
188 } |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
189 |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
190 |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
191 void ZipWriter::BufferWithSeek::Seek(size_t position) |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
192 { |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
193 CheckInvariants(); |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
194 |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
195 if (currentPosition_ != position) |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
196 { |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
197 if (position < GetSize()) |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
198 { |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
199 if (chunks_.GetNumBytes() != 0) |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
200 { |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
201 assert(flattened_.empty()); |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
202 chunks_.Flatten(flattened_); |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
203 } |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
204 |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
205 assert(chunks_.GetNumBytes() == 0); |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
206 } |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
207 else if (position > GetSize()) |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
208 { |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
209 throw OrthancException(ErrorCode_ParameterOutOfRange); |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
210 } |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
211 |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
212 currentPosition_ = position; |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
213 } |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
214 |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
215 CheckInvariants(); |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
216 } |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
217 |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
218 |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
219 void ZipWriter::BufferWithSeek::Flush(std::string& target) |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
220 { |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
221 CheckInvariants(); |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
222 |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
223 if (flattened_.empty()) |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
224 { |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
225 chunks_.Flatten(target); |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
226 } |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
227 else |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
228 { |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
229 flattened_.swap(target); |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
230 flattened_.clear(); |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
231 } |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
232 |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
233 currentPosition_ = 0; |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
234 |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
235 CheckInvariants(); |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
236 } |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
237 |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
238 |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
239 /** |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
240 * Inside a ZIP archive, compressed files are concatenated, each |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
241 * file being prefixed by its "Local file header". The ZIP archive |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
242 * ends with the "central directory" structure. |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
243 * https://en.wikipedia.org/wiki/ZIP_(file_format) |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
244 * |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
245 * When writing one file, the minizip implementation first TELLS to |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
246 * know the current size of the archive, then WRITES the header and |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
247 * data bytes, then SEEKS backward to update the "local file header" |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
248 * with info about the compressed data (at the 14 offset, containing |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
249 * CRC-32, compressed size and uncompressed size), and finally SEEKS |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
250 * to get back at the end of the stream in order to continue adding |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
251 * files. |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
252 * |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
253 * The minizip implementation will *never* SEEK *before* the "local |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
254 * file header" of the current file. However, the current file must |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
255 * *not* be immediately sent to the stream as new bytes are written, |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
256 * because the "local file header" will be updated. |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
257 * |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
258 * Consequently, this buffer class only sends the pending bytes to |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
259 * the output stream once it receives a SEEK command that moves the |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
260 * cursor at the end of the archive. In the minizip implementation, |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
261 * such a SEEK indicates that the current file has been properly |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
262 * added to the archive. |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
263 **/ |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
264 class ZipWriter::StreamBuffer : public boost::noncopyable |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
265 { |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
266 private: |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
267 IOutputStream& stream_; |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
268 bool success_; |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
269 ZPOS64_T startCurrentFile_; |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
270 BufferWithSeek buffer_; |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
271 |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
272 public: |
4690 | 273 explicit StreamBuffer(IOutputStream& stream) : |
4670
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
274 stream_(stream), |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
275 success_(true), |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
276 startCurrentFile_(0) |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
277 { |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
278 } |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
279 |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
280 int Close() |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
281 { |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
282 try |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
283 { |
4672
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
284 if (success_) |
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
285 { |
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
286 std::string s; |
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
287 buffer_.Flush(s); |
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
288 stream_.Write(s); |
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
289 } |
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
290 |
4670
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
291 return 0; |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
292 } |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
293 catch (...) |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
294 { |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
295 success_ = false; |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
296 return 1; |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
297 } |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
298 } |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
299 |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
300 ZPOS64_T Tell() const |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
301 { |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
302 return startCurrentFile_ + static_cast<ZPOS64_T>(buffer_.GetPosition()); |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
303 } |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
304 |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
305 uLong Write(const void* buf, |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
306 uLong size) |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
307 { |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
308 if (size == 0) |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
309 { |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
310 return 0; |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
311 } |
4672
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
312 else if (!success_) |
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
313 { |
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
314 return 0; // Error |
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
315 } |
4670
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
316 else |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
317 { |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
318 try |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
319 { |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
320 buffer_.Write(buf, size); |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
321 return size; |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
322 } |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
323 catch (...) |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
324 { |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
325 return 0; |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
326 } |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
327 } |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
328 } |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
329 |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
330 |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
331 long Seek(ZPOS64_T offset, |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
332 int origin) |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
333 { |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
334 try |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
335 { |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
336 if (origin == ZLIB_FILEFUNC_SEEK_SET && |
4672
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
337 offset >= startCurrentFile_ && |
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
338 success_) |
4670
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
339 { |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
340 ZPOS64_T fullSize = startCurrentFile_ + static_cast<ZPOS64_T>(buffer_.GetSize()); |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
341 assert(offset <= fullSize); |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
342 |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
343 if (offset == fullSize) |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
344 { |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
345 // We can flush to the output stream |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
346 std::string s; |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
347 buffer_.Flush(s); |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
348 stream_.Write(s); |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
349 startCurrentFile_ = fullSize; |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
350 } |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
351 else |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
352 { |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
353 buffer_.Seek(offset - startCurrentFile_); |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
354 } |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
355 |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
356 return 0; // OK |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
357 } |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
358 else |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
359 { |
4672
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
360 return 1; |
4670
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
361 } |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
362 } |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
363 catch (...) |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
364 { |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
365 return 1; |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
366 } |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
367 } |
4672
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
368 |
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
369 |
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
370 void Cancel() |
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
371 { |
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
372 success_ = false; |
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
373 } |
4670
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
374 |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
375 |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
376 static int CloseWrapper(voidpf opaque, |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
377 voidpf stream) |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
378 { |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
379 assert(opaque != NULL); |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
380 return reinterpret_cast<StreamBuffer*>(opaque)->Close(); |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
381 } |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
382 |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
383 static voidpf OpenWrapper(voidpf opaque, |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
384 const void* filename, |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
385 int mode) |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
386 { |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
387 assert(opaque != NULL); |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
388 return opaque; |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
389 } |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
390 |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
391 static long SeekWrapper(voidpf opaque, |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
392 voidpf stream, |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
393 ZPOS64_T offset, |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
394 int origin) |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
395 { |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
396 assert(opaque != NULL); |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
397 return reinterpret_cast<StreamBuffer*>(opaque)->Seek(offset, origin); |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
398 } |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
399 |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
400 static ZPOS64_T TellWrapper(voidpf opaque, |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
401 voidpf stream) |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
402 { |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
403 assert(opaque != NULL); |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
404 return reinterpret_cast<StreamBuffer*>(opaque)->Tell(); |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
405 } |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
406 |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
407 static int TestErrorWrapper(voidpf opaque, |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
408 voidpf stream) |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
409 { |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
410 assert(opaque != NULL); |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
411 return reinterpret_cast<StreamBuffer*>(opaque)->success_ ? 0 : 1; |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
412 } |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
413 |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
414 static uLong WriteWrapper(voidpf opaque, |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
415 voidpf stream, |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
416 const void* buf, |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
417 uLong size) |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
418 { |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
419 assert(opaque != NULL); |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
420 return reinterpret_cast<StreamBuffer*>(opaque)->Write(buf, size); |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
421 } |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
422 }; |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
423 |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
424 |
4672
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
425 struct ZipWriter::PImpl : public boost::noncopyable |
81 | 426 { |
427 zipFile file_; | |
4670
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
428 std::unique_ptr<StreamBuffer> streamBuffer_; |
4672
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
429 uint64_t archiveSize_; |
1277
46bca019587e
primitives to add new content to existing ZIP files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
950
diff
changeset
|
430 |
4672
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
431 PImpl() : |
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
432 file_(NULL), |
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
433 archiveSize_(0) |
1277
46bca019587e
primitives to add new content to existing ZIP files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
950
diff
changeset
|
434 { |
46bca019587e
primitives to add new content to existing ZIP files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
950
diff
changeset
|
435 } |
81 | 436 }; |
437 | |
1277
46bca019587e
primitives to add new content to existing ZIP files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
950
diff
changeset
|
438 ZipWriter::ZipWriter() : |
46bca019587e
primitives to add new content to existing ZIP files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
950
diff
changeset
|
439 pimpl_(new PImpl), |
46bca019587e
primitives to add new content to existing ZIP files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
950
diff
changeset
|
440 isZip64_(false), |
46bca019587e
primitives to add new content to existing ZIP files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
950
diff
changeset
|
441 hasFileInZip_(false), |
46bca019587e
primitives to add new content to existing ZIP files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
950
diff
changeset
|
442 append_(false), |
46bca019587e
primitives to add new content to existing ZIP files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
950
diff
changeset
|
443 compressionLevel_(6) |
81 | 444 { |
445 } | |
446 | |
447 ZipWriter::~ZipWriter() | |
448 { | |
4670
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
449 try |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
450 { |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
451 Close(); |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
452 } |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
453 catch (OrthancException& e) // Don't throw exceptions in destructors |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
454 { |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
455 LOG(ERROR) << "Catched exception in destructor: " << e.What(); |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
456 } |
81 | 457 } |
458 | |
459 void ZipWriter::Close() | |
460 { | |
461 if (IsOpen()) | |
462 { | |
463 zipClose(pimpl_->file_, "Created by Orthanc"); | |
464 pimpl_->file_ = NULL; | |
465 hasFileInZip_ = false; | |
4670
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
466 |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
467 pimpl_->streamBuffer_.reset(NULL); |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
468 |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
469 if (outputStream_.get() != NULL) |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
470 { |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
471 outputStream_->Close(); |
4672
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
472 pimpl_->archiveSize_ = outputStream_->GetArchiveSize(); |
4670
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
473 outputStream_.reset(NULL); |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
474 } |
81 | 475 } |
476 } | |
477 | |
478 bool ZipWriter::IsOpen() const | |
479 { | |
480 return pimpl_->file_ != NULL; | |
481 } | |
482 | |
483 void ZipWriter::Open() | |
484 { | |
485 if (IsOpen()) | |
486 { | |
487 return; | |
488 } | |
4670
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
489 else if (outputStream_.get() != NULL) |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
490 { |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
491 // New in Orthanc 1.9.4 |
4671
42e1f5bde40b
added sanity check
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4670
diff
changeset
|
492 if (IsAppendToExisting()) |
42e1f5bde40b
added sanity check
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4670
diff
changeset
|
493 { |
42e1f5bde40b
added sanity check
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4670
diff
changeset
|
494 throw OrthancException(ErrorCode_BadSequenceOfCalls, "Cannot append to output streams"); |
42e1f5bde40b
added sanity check
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4670
diff
changeset
|
495 } |
42e1f5bde40b
added sanity check
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4670
diff
changeset
|
496 |
4670
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
497 hasFileInZip_ = false; |
81 | 498 |
4670
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
499 zlib_filefunc64_def funcs; |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
500 memset(&funcs, 0, sizeof(funcs)); |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
501 |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
502 pimpl_->streamBuffer_.reset(new StreamBuffer(*outputStream_)); |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
503 funcs.opaque = pimpl_->streamBuffer_.get(); |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
504 funcs.zclose_file = StreamBuffer::CloseWrapper; |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
505 funcs.zerror_file = StreamBuffer::TestErrorWrapper; |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
506 funcs.zopen64_file = StreamBuffer::OpenWrapper; |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
507 funcs.ztell64_file = StreamBuffer::TellWrapper; |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
508 funcs.zwrite_file = StreamBuffer::WriteWrapper; |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
509 funcs.zseek64_file = StreamBuffer::SeekWrapper; |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
510 |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
511 /** |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
512 * "funcs.zread_file" (ZREAD64) also appears in "minizip/zip.c", |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
513 * but is only needed by function "LoadCentralDirectoryRecord()" |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
514 * that is only used if appending new files to an already |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
515 * existing ZIP, which makes no sense for an output stream. |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
516 **/ |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
517 |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
518 pimpl_->file_ = zipOpen2_64(NULL /* no output path */, APPEND_STATUS_CREATE, |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
519 NULL /* global comment */, &funcs); |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
520 |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
521 if (!pimpl_->file_) |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
522 { |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
523 throw OrthancException(ErrorCode_CannotWriteFile, |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
524 "Cannot create new ZIP archive into an output stream"); |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
525 } |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
526 } |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
527 else if (path_.empty()) |
81 | 528 { |
2954
d924f9bb61cc
taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
529 throw OrthancException(ErrorCode_BadSequenceOfCalls, |
d924f9bb61cc
taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
530 "Please call SetOutputPath() before creating the file"); |
81 | 531 } |
644
eb5a0b21d05e
do not use ZIP64 as the default format anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
568
diff
changeset
|
532 else |
eb5a0b21d05e
do not use ZIP64 as the default format anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
568
diff
changeset
|
533 { |
4670
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
534 hasFileInZip_ = false; |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
535 |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
536 int mode = APPEND_STATUS_CREATE; |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
537 if (append_ && |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
538 boost::filesystem::exists(path_)) |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
539 { |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
540 mode = APPEND_STATUS_ADDINZIP; |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
541 } |
644
eb5a0b21d05e
do not use ZIP64 as the default format anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
568
diff
changeset
|
542 |
4670
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
543 if (isZip64_) |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
544 { |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
545 pimpl_->file_ = zipOpen64(path_.c_str(), mode); |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
546 } |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
547 else |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
548 { |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
549 pimpl_->file_ = zipOpen(path_.c_str(), mode); |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
550 } |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
551 |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
552 if (!pimpl_->file_) |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
553 { |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
554 throw OrthancException(ErrorCode_CannotWriteFile, |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
555 "Cannot create new ZIP archive: " + path_); |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
556 } |
81 | 557 } |
558 } | |
559 | |
560 void ZipWriter::SetOutputPath(const char* path) | |
561 { | |
562 Close(); | |
563 path_ = path; | |
564 } | |
565 | |
4296
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
566 const std::string &ZipWriter::GetOutputPath() const |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
567 { |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
568 return path_; |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
569 } |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
570 |
644
eb5a0b21d05e
do not use ZIP64 as the default format anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
568
diff
changeset
|
571 void ZipWriter::SetZip64(bool isZip64) |
eb5a0b21d05e
do not use ZIP64 as the default format anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
568
diff
changeset
|
572 { |
4672
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
573 if (outputStream_.get() == NULL) |
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
574 { |
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
575 Close(); |
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
576 isZip64_ = isZip64; |
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
577 } |
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
578 else |
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
579 { |
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
580 throw OrthancException(ErrorCode_BadSequenceOfCalls, |
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
581 "SetZip64() must be given to AcquireOutputStream()"); |
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
582 } |
644
eb5a0b21d05e
do not use ZIP64 as the default format anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
568
diff
changeset
|
583 } |
eb5a0b21d05e
do not use ZIP64 as the default format anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
568
diff
changeset
|
584 |
81 | 585 void ZipWriter::SetCompressionLevel(uint8_t level) |
586 { | |
587 if (level >= 10) | |
588 { | |
2954
d924f9bb61cc
taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
589 throw OrthancException(ErrorCode_ParameterOutOfRange, |
3181
6fd38327e777
Fix issue #130 (Orthanc failed to start when /tmp partition was full)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3128
diff
changeset
|
590 "ZIP compression level must be between 0 (no compression) " |
6fd38327e777
Fix issue #130 (Orthanc failed to start when /tmp partition was full)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3128
diff
changeset
|
591 "and 9 (highest compression)"); |
81 | 592 } |
4672
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
593 else |
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
594 { |
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
595 compressionLevel_ = level; |
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
596 } |
81 | 597 } |
598 | |
4296
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
599 uint8_t ZipWriter::GetCompressionLevel() const |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
600 { |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
601 return compressionLevel_; |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
602 } |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
603 |
249 | 604 void ZipWriter::OpenFile(const char* path) |
81 | 605 { |
606 Open(); | |
607 | |
608 zip_fileinfo zfi; | |
609 PrepareFileInfo(zfi); | |
610 | |
644
eb5a0b21d05e
do not use ZIP64 as the default format anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
568
diff
changeset
|
611 int result; |
eb5a0b21d05e
do not use ZIP64 as the default format anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
568
diff
changeset
|
612 |
eb5a0b21d05e
do not use ZIP64 as the default format anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
568
diff
changeset
|
613 if (isZip64_) |
eb5a0b21d05e
do not use ZIP64 as the default format anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
568
diff
changeset
|
614 { |
eb5a0b21d05e
do not use ZIP64 as the default format anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
568
diff
changeset
|
615 result = zipOpenNewFileInZip64(pimpl_->file_, path, |
eb5a0b21d05e
do not use ZIP64 as the default format anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
568
diff
changeset
|
616 &zfi, |
eb5a0b21d05e
do not use ZIP64 as the default format anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
568
diff
changeset
|
617 NULL, 0, |
eb5a0b21d05e
do not use ZIP64 as the default format anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
568
diff
changeset
|
618 NULL, 0, |
eb5a0b21d05e
do not use ZIP64 as the default format anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
568
diff
changeset
|
619 "", // Comment |
eb5a0b21d05e
do not use ZIP64 as the default format anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
568
diff
changeset
|
620 Z_DEFLATED, |
eb5a0b21d05e
do not use ZIP64 as the default format anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
568
diff
changeset
|
621 compressionLevel_, 1); |
eb5a0b21d05e
do not use ZIP64 as the default format anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
568
diff
changeset
|
622 } |
eb5a0b21d05e
do not use ZIP64 as the default format anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
568
diff
changeset
|
623 else |
eb5a0b21d05e
do not use ZIP64 as the default format anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
568
diff
changeset
|
624 { |
eb5a0b21d05e
do not use ZIP64 as the default format anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
568
diff
changeset
|
625 result = zipOpenNewFileInZip(pimpl_->file_, path, |
eb5a0b21d05e
do not use ZIP64 as the default format anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
568
diff
changeset
|
626 &zfi, |
eb5a0b21d05e
do not use ZIP64 as the default format anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
568
diff
changeset
|
627 NULL, 0, |
eb5a0b21d05e
do not use ZIP64 as the default format anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
568
diff
changeset
|
628 NULL, 0, |
eb5a0b21d05e
do not use ZIP64 as the default format anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
568
diff
changeset
|
629 "", // Comment |
eb5a0b21d05e
do not use ZIP64 as the default format anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
568
diff
changeset
|
630 Z_DEFLATED, |
eb5a0b21d05e
do not use ZIP64 as the default format anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
568
diff
changeset
|
631 compressionLevel_); |
eb5a0b21d05e
do not use ZIP64 as the default format anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
568
diff
changeset
|
632 } |
eb5a0b21d05e
do not use ZIP64 as the default format anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
568
diff
changeset
|
633 |
eb5a0b21d05e
do not use ZIP64 as the default format anymore
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
568
diff
changeset
|
634 if (result != 0) |
81 | 635 { |
3184 | 636 throw OrthancException(ErrorCode_CannotWriteFile, |
637 "Cannot add new file inside ZIP archive: " + std::string(path)); | |
81 | 638 } |
639 | |
640 hasFileInZip_ = true; | |
641 } | |
642 | |
643 | |
644 void ZipWriter::Write(const std::string& data) | |
645 { | |
646 if (data.size()) | |
647 { | |
648 Write(&data[0], data.size()); | |
649 } | |
650 } | |
651 | |
652 | |
3945
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
653 void ZipWriter::Write(const void* data, size_t length) |
81 | 654 { |
655 if (!hasFileInZip_) | |
656 { | |
2954
d924f9bb61cc
taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
657 throw OrthancException(ErrorCode_BadSequenceOfCalls, "Call first OpenFile()"); |
81 | 658 } |
659 | |
660 const size_t maxBytesInAStep = std::numeric_limits<int32_t>::max(); | |
661 | |
3945
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
662 const char* p = reinterpret_cast<const char*>(data); |
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
663 |
81 | 664 while (length > 0) |
665 { | |
666 int bytes = static_cast<int32_t>(length <= maxBytesInAStep ? length : maxBytesInAStep); | |
667 | |
3945
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
668 if (zipWriteInFileInZip(pimpl_->file_, p, bytes)) |
81 | 669 { |
3184 | 670 throw OrthancException(ErrorCode_CannotWriteFile, |
671 "Cannot write data to ZIP archive: " + path_); | |
81 | 672 } |
673 | |
3945
0b3256c3ee14
simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
674 p += bytes; |
81 | 675 length -= bytes; |
676 } | |
677 } | |
1277
46bca019587e
primitives to add new content to existing ZIP files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
950
diff
changeset
|
678 |
46bca019587e
primitives to add new content to existing ZIP files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
950
diff
changeset
|
679 |
46bca019587e
primitives to add new content to existing ZIP files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
950
diff
changeset
|
680 void ZipWriter::SetAppendToExisting(bool append) |
46bca019587e
primitives to add new content to existing ZIP files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
950
diff
changeset
|
681 { |
46bca019587e
primitives to add new content to existing ZIP files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
950
diff
changeset
|
682 Close(); |
46bca019587e
primitives to add new content to existing ZIP files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
950
diff
changeset
|
683 append_ = append; |
46bca019587e
primitives to add new content to existing ZIP files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
950
diff
changeset
|
684 } |
4296
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
685 |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
686 bool ZipWriter::IsAppendToExisting() const |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
687 { |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
688 return append_; |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
689 } |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
690 |
4297 | 691 bool ZipWriter::IsZip64() const |
4296
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
692 { |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
693 return isZip64_; |
3b70a2e6a06c
moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4119
diff
changeset
|
694 } |
4670
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
695 |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
696 |
4672
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
697 void ZipWriter::AcquireOutputStream(IOutputStream* stream, |
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
698 bool isZip64) |
4670
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
699 { |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
700 std::unique_ptr<IOutputStream> protection(stream); |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
701 |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
702 if (stream == NULL) |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
703 { |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
704 throw OrthancException(ErrorCode_NullPointer); |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
705 } |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
706 else |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
707 { |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
708 Close(); |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
709 path_.clear(); |
4672
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
710 isZip64_ = isZip64; |
4670
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
711 outputStream_.reset(protection.release()); |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
712 } |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
713 } |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
714 |
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
715 |
4672
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
716 void ZipWriter::SetMemoryOutput(std::string& target, |
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
717 bool isZip64) |
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
718 { |
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
719 AcquireOutputStream(new MemoryStream(target), isZip64); |
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
720 } |
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
721 |
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
722 |
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
723 void ZipWriter::CancelStream() |
4670
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
724 { |
4672
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
725 if (outputStream_.get() == NULL || |
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
726 pimpl_->streamBuffer_.get() == NULL) |
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
727 { |
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
728 throw OrthancException(ErrorCode_BadSequenceOfCalls, "Only applicable after AcquireOutputStream() and Open()"); |
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
729 } |
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
730 else |
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
731 { |
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
732 pimpl_->streamBuffer_->Cancel(); |
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
733 } |
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
734 } |
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
735 |
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
736 |
4673 | 737 uint64_t ZipWriter::GetArchiveSize() const |
4672
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
738 { |
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
739 if (outputStream_.get() != NULL) |
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
740 { |
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
741 return outputStream_->GetArchiveSize(); |
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
742 } |
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
743 else if (path_.empty()) |
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
744 { |
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
745 // This is the case after a call to "Close()" |
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
746 return pimpl_->archiveSize_; |
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
747 } |
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
748 else |
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
749 { |
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
750 return SystemToolbox::GetFileSize(path_); |
d9942d48fea7
ZipWriter::CancelStream(), ZipWriter::GetArchiveSize() and HttpOutput::AnswerWithoutBuffering()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4671
diff
changeset
|
751 } |
4670
b12faca76a52
support of output streams in ZipWriter
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
752 } |
81 | 753 } |