Mercurial > hg > orthanc
comparison Core/Compression/ZipWriter.cpp @ 2981:eff50153a7b3 db-changes
integration mainline->db-changes
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 06 Dec 2018 15:58:08 +0100 |
parents | d924f9bb61cc |
children | 4e43e67f8ecf |
comparison
equal
deleted
inserted
replaced
2896:3fabf9a673f6 | 2981:eff50153a7b3 |
---|---|
122 return; | 122 return; |
123 } | 123 } |
124 | 124 |
125 if (path_.size() == 0) | 125 if (path_.size() == 0) |
126 { | 126 { |
127 LOG(ERROR) << "Please call SetOutputPath() before creating the file"; | 127 throw OrthancException(ErrorCode_BadSequenceOfCalls, |
128 throw OrthancException(ErrorCode_BadSequenceOfCalls); | 128 "Please call SetOutputPath() before creating the file"); |
129 } | 129 } |
130 | 130 |
131 hasFileInZip_ = false; | 131 hasFileInZip_ = false; |
132 | 132 |
133 int mode = APPEND_STATUS_CREATE; | 133 int mode = APPEND_STATUS_CREATE; |
166 | 166 |
167 void ZipWriter::SetCompressionLevel(uint8_t level) | 167 void ZipWriter::SetCompressionLevel(uint8_t level) |
168 { | 168 { |
169 if (level >= 10) | 169 if (level >= 10) |
170 { | 170 { |
171 LOG(ERROR) << "ZIP compression level must be between 0 (no compression) and 9 (highest compression)"; | 171 throw OrthancException(ErrorCode_ParameterOutOfRange, |
172 throw OrthancException(ErrorCode_ParameterOutOfRange); | 172 "ZIP compression level must be between 0 (no compression) and 9 (highest compression)"); |
173 } | 173 } |
174 | 174 |
175 Close(); | 175 Close(); |
176 compressionLevel_ = level; | 176 compressionLevel_ = level; |
177 } | 177 } |
226 | 226 |
227 void ZipWriter::Write(const char* data, size_t length) | 227 void ZipWriter::Write(const char* data, size_t length) |
228 { | 228 { |
229 if (!hasFileInZip_) | 229 if (!hasFileInZip_) |
230 { | 230 { |
231 LOG(ERROR) << "Call first OpenFile()"; | 231 throw OrthancException(ErrorCode_BadSequenceOfCalls, "Call first OpenFile()"); |
232 throw OrthancException(ErrorCode_BadSequenceOfCalls); | |
233 } | 232 } |
234 | 233 |
235 const size_t maxBytesInAStep = std::numeric_limits<int32_t>::max(); | 234 const size_t maxBytesInAStep = std::numeric_limits<int32_t>::max(); |
236 | 235 |
237 while (length > 0) | 236 while (length > 0) |