comparison Core/Compression/ZipWriter.cpp @ 3945:0b3256c3ee14 transcoding

simplified IDicomTranscoder
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 19 May 2020 11:24:00 +0200
parents 94f4a18a79cc
children
comparison
equal deleted inserted replaced
3944:aae045f802f4 3945:0b3256c3ee14
225 Write(&data[0], data.size()); 225 Write(&data[0], data.size());
226 } 226 }
227 } 227 }
228 228
229 229
230 void ZipWriter::Write(const char* data, size_t length) 230 void ZipWriter::Write(const void* data, size_t length)
231 { 231 {
232 if (!hasFileInZip_) 232 if (!hasFileInZip_)
233 { 233 {
234 throw OrthancException(ErrorCode_BadSequenceOfCalls, "Call first OpenFile()"); 234 throw OrthancException(ErrorCode_BadSequenceOfCalls, "Call first OpenFile()");
235 } 235 }
236 236
237 const size_t maxBytesInAStep = std::numeric_limits<int32_t>::max(); 237 const size_t maxBytesInAStep = std::numeric_limits<int32_t>::max();
238 238
239 const char* p = reinterpret_cast<const char*>(data);
240
239 while (length > 0) 241 while (length > 0)
240 { 242 {
241 int bytes = static_cast<int32_t>(length <= maxBytesInAStep ? length : maxBytesInAStep); 243 int bytes = static_cast<int32_t>(length <= maxBytesInAStep ? length : maxBytesInAStep);
242 244
243 if (zipWriteInFileInZip(pimpl_->file_, data, bytes)) 245 if (zipWriteInFileInZip(pimpl_->file_, p, bytes))
244 { 246 {
245 throw OrthancException(ErrorCode_CannotWriteFile, 247 throw OrthancException(ErrorCode_CannotWriteFile,
246 "Cannot write data to ZIP archive: " + path_); 248 "Cannot write data to ZIP archive: " + path_);
247 } 249 }
248 250
249 data += bytes; 251 p += bytes;
250 length -= bytes; 252 length -= bytes;
251 } 253 }
252 } 254 }
253 255
254 256