comparison Core/Compression/ZipWriter.cpp @ 3186:92bbc5274220

merge
author Alain Mazy <alain@mazy.be>
date Fri, 01 Feb 2019 17:54:06 +0100
parents 5d1f5984dc41
children 94f4a18a79cc
comparison
equal deleted inserted replaced
3185:c6dab987f43a 3186:92bbc5274220
146 pimpl_->file_ = zipOpen(path_.c_str(), mode); 146 pimpl_->file_ = zipOpen(path_.c_str(), mode);
147 } 147 }
148 148
149 if (!pimpl_->file_) 149 if (!pimpl_->file_)
150 { 150 {
151 throw OrthancException(ErrorCode_CannotWriteFile); 151 throw OrthancException(ErrorCode_CannotWriteFile,
152 "Cannot create new ZIP archive: " + path_);
152 } 153 }
153 } 154 }
154 155
155 void ZipWriter::SetOutputPath(const char* path) 156 void ZipWriter::SetOutputPath(const char* path)
156 { 157 {
167 void ZipWriter::SetCompressionLevel(uint8_t level) 168 void ZipWriter::SetCompressionLevel(uint8_t level)
168 { 169 {
169 if (level >= 10) 170 if (level >= 10)
170 { 171 {
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 "ZIP compression level must be between 0 (no compression) "
174 "and 9 (highest compression)");
173 } 175 }
174 176
175 Close(); 177 Close();
176 compressionLevel_ = level; 178 compressionLevel_ = level;
177 } 179 }
206 compressionLevel_); 208 compressionLevel_);
207 } 209 }
208 210
209 if (result != 0) 211 if (result != 0)
210 { 212 {
211 throw OrthancException(ErrorCode_CannotWriteFile); 213 throw OrthancException(ErrorCode_CannotWriteFile,
214 "Cannot add new file inside ZIP archive: " + std::string(path));
212 } 215 }
213 216
214 hasFileInZip_ = true; 217 hasFileInZip_ = true;
215 } 218 }
216 219
237 { 240 {
238 int bytes = static_cast<int32_t>(length <= maxBytesInAStep ? length : maxBytesInAStep); 241 int bytes = static_cast<int32_t>(length <= maxBytesInAStep ? length : maxBytesInAStep);
239 242
240 if (zipWriteInFileInZip(pimpl_->file_, data, bytes)) 243 if (zipWriteInFileInZip(pimpl_->file_, data, bytes))
241 { 244 {
242 throw OrthancException(ErrorCode_CannotWriteFile); 245 throw OrthancException(ErrorCode_CannotWriteFile,
246 "Cannot write data to ZIP archive: " + path_);
243 } 247 }
244 248
245 data += bytes; 249 data += bytes;
246 length -= bytes; 250 length -= bytes;
247 } 251 }
251 void ZipWriter::SetAppendToExisting(bool append) 255 void ZipWriter::SetAppendToExisting(bool append)
252 { 256 {
253 Close(); 257 Close();
254 append_ = append; 258 append_ = append;
255 } 259 }
256
257
258 } 260 }