annotate OrthancFramework/Sources/Compression/ZlibCompressor.cpp @ 5666:aa231c18b9d2 find-refactoring

adding computed tags
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 04 Jul 2024 18:31:54 +0200
parents f7adfb22e20e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
59
c996319e90bc renaming in Core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 50
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
1900
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1582
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
1288
6e7e5ed91c2d upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 824
diff changeset
4 * Department, University Hospital of Liege, Belgium
5640
f7adfb22e20e updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5485
diff changeset
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium
f7adfb22e20e updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5485
diff changeset
6 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium
5485
48b8dae6dc77 upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
7 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 *
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * 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
10 * 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
11 * 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
12 * the License, or (at your option) any later version.
136
fe180eae201d openssl exception
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 81
diff changeset
13 *
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful, but
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * 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
17 * Lesser General Public License for more details.
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 *
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
19 * 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
20 * 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
21 * <http://www.gnu.org/licenses/>.
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 **/
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24
824
a811bdf8b8eb precompiled headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 689
diff changeset
25 #include "../PrecompiledHeaders.h"
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 #include "ZlibCompressor.h"
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27
4455
a8f554ca5ac6 Explicitly use little-endian to encode uncompressed file size with zlib compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
28 #include "../Endianness.h"
1513
fe07f82d83d3 gzip compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
29 #include "../OrthancException.h"
fe07f82d83d3 gzip compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
30 #include "../Logging.h"
fe07f82d83d3 gzip compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
31
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 #include <stdio.h>
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 #include <string.h>
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 #include <zlib.h>
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35
59
c996319e90bc renaming in Core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 50
diff changeset
36 namespace Orthanc
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 {
4297
785a2713323e abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4296
diff changeset
38 ZlibCompressor::ZlibCompressor()
4296
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
39 {
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
40 SetPrefixWithUncompressedSize(true);
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
41 }
3b70a2e6a06c moving inline methods to source files for ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
42
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 void ZlibCompressor::Compress(std::string& compressed,
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 const void* uncompressed,
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 size_t uncompressedSize)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 if (uncompressedSize == 0)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 compressed.clear();
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 return;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52
3378
596cfabd72c5 Fixed a couple of truncation warnings
Benjamin Golinvaux <bgo@osimis.io>
parents: 3060
diff changeset
53 uLongf compressedSize = compressBound(static_cast<uLong>(uncompressedSize))
596cfabd72c5 Fixed a couple of truncation warnings
Benjamin Golinvaux <bgo@osimis.io>
parents: 3060
diff changeset
54 + 1024 /* security margin */;
1511
7962563129c9 starting support of deflate/gzip content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
55 if (compressedSize == 0)
7962563129c9 starting support of deflate/gzip content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
56 {
7962563129c9 starting support of deflate/gzip content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
57 compressedSize = 1;
7962563129c9 starting support of deflate/gzip content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
58 }
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59
1511
7962563129c9 starting support of deflate/gzip content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
60 uint8_t* target;
1512
52dc56bcec7d refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1511
diff changeset
61 if (HasPrefixWithUncompressedSize())
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 {
1511
7962563129c9 starting support of deflate/gzip content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
63 compressed.resize(compressedSize + sizeof(uint64_t));
7962563129c9 starting support of deflate/gzip content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
64 target = reinterpret_cast<uint8_t*>(&compressed[0]) + sizeof(uint64_t);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 else
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 {
1511
7962563129c9 starting support of deflate/gzip content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
68 compressed.resize(compressedSize);
7962563129c9 starting support of deflate/gzip content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
69 target = reinterpret_cast<uint8_t*>(&compressed[0]);
7962563129c9 starting support of deflate/gzip content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
70 }
7962563129c9 starting support of deflate/gzip content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
71
7962563129c9 starting support of deflate/gzip content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
72 int error = compress2(target,
7962563129c9 starting support of deflate/gzip content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
73 &compressedSize,
7962563129c9 starting support of deflate/gzip content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
74 const_cast<Bytef *>(static_cast<const Bytef *>(uncompressed)),
3378
596cfabd72c5 Fixed a couple of truncation warnings
Benjamin Golinvaux <bgo@osimis.io>
parents: 3060
diff changeset
75 static_cast<uLong>(uncompressedSize),
1512
52dc56bcec7d refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1511
diff changeset
76 GetCompressionLevel());
1511
7962563129c9 starting support of deflate/gzip content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
77
7962563129c9 starting support of deflate/gzip content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
78 if (error != Z_OK)
7962563129c9 starting support of deflate/gzip content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
79 {
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 compressed.clear();
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 switch (error)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 case Z_MEM_ERROR:
59
c996319e90bc renaming in Core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 50
diff changeset
85 throw OrthancException(ErrorCode_NotEnoughMemory);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 default:
59
c996319e90bc renaming in Core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 50
diff changeset
88 throw OrthancException(ErrorCode_InternalError);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 }
1511
7962563129c9 starting support of deflate/gzip content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
91
7962563129c9 starting support of deflate/gzip content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
92 // The compression was successful
1512
52dc56bcec7d refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1511
diff changeset
93 if (HasPrefixWithUncompressedSize())
1511
7962563129c9 starting support of deflate/gzip content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
94 {
7962563129c9 starting support of deflate/gzip content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
95 uint64_t s = static_cast<uint64_t>(uncompressedSize);
4455
a8f554ca5ac6 Explicitly use little-endian to encode uncompressed file size with zlib compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
96
a8f554ca5ac6 Explicitly use little-endian to encode uncompressed file size with zlib compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
97 // New in Orthanc 1.9.0: Explicitly use litte-endian encoding in size prefix
a8f554ca5ac6 Explicitly use little-endian to encode uncompressed file size with zlib compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
98 s = htole64(s);
a8f554ca5ac6 Explicitly use little-endian to encode uncompressed file size with zlib compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
99
1511
7962563129c9 starting support of deflate/gzip content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
100 memcpy(&compressed[0], &s, sizeof(uint64_t));
7962563129c9 starting support of deflate/gzip content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
101 compressed.resize(compressedSize + sizeof(uint64_t));
7962563129c9 starting support of deflate/gzip content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
102 }
7962563129c9 starting support of deflate/gzip content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
103 else
7962563129c9 starting support of deflate/gzip content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
104 {
7962563129c9 starting support of deflate/gzip content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
105 compressed.resize(compressedSize);
7962563129c9 starting support of deflate/gzip content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
106 }
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 void ZlibCompressor::Uncompress(std::string& uncompressed,
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 const void* compressed,
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112 size_t compressedSize)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114 if (compressedSize == 0)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116 uncompressed.clear();
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117 return;
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119
1513
fe07f82d83d3 gzip compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
120 if (!HasPrefixWithUncompressedSize())
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121 {
2954
d924f9bb61cc taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
122 throw OrthancException(ErrorCode_InternalError,
d924f9bb61cc taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
123 "Cannot guess the uncompressed size of a zlib-encoded buffer");
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125
1513
fe07f82d83d3 gzip compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
126 uint64_t uncompressedSize = ReadUncompressedSizePrefix(compressed, compressedSize);
221
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
127
4492
0b2484663233 Fix build on big-endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4455
diff changeset
128 // New in Orthanc 1.9.0: Explicitly use litte-endian encoding in size prefix
0b2484663233 Fix build on big-endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4455
diff changeset
129 uncompressedSize = le64toh(uncompressedSize);
0b2484663233 Fix build on big-endian architectures
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4455
diff changeset
130
221
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
131 try
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
132 {
1545
33d34bc4ac15 fix msvc warnings
jodogne
parents: 1513
diff changeset
133 uncompressed.resize(static_cast<size_t>(uncompressedSize));
221
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
134 }
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
135 catch (...)
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
136 {
1513
fe07f82d83d3 gzip compression
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1512
diff changeset
137 throw OrthancException(ErrorCode_NotEnoughMemory);
221
e7432706b354 accessors to storage
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 136
diff changeset
138 }
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
139
1545
33d34bc4ac15 fix msvc warnings
jodogne
parents: 1513
diff changeset
140 uLongf tmp = static_cast<uLongf>(uncompressedSize);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141 int error = uncompress
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
142 (reinterpret_cast<uint8_t*>(&uncompressed[0]),
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143 &tmp,
1511
7962563129c9 starting support of deflate/gzip content types
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1288
diff changeset
144 reinterpret_cast<const uint8_t*>(compressed) + sizeof(uint64_t),
3378
596cfabd72c5 Fixed a couple of truncation warnings
Benjamin Golinvaux <bgo@osimis.io>
parents: 3060
diff changeset
145 static_cast<uLong>(compressedSize - sizeof(uint64_t)));
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
146
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
147 if (error != Z_OK)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
148 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
149 uncompressed.clear();
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
150
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151 switch (error)
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
153 case Z_DATA_ERROR:
1582
bd1889029cbb encoding of exceptions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1545
diff changeset
154 throw OrthancException(ErrorCode_CorruptedFile);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
156 case Z_MEM_ERROR:
59
c996319e90bc renaming in Core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 50
diff changeset
157 throw OrthancException(ErrorCode_NotEnoughMemory);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
158
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
159 default:
59
c996319e90bc renaming in Core
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 50
diff changeset
160 throw OrthancException(ErrorCode_InternalError);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
161 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
163 }
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
164 }