Mercurial > hg > orthanc
comparison OrthancFramework/UnitTestsSources/ZipTests.cpp @ 4354:bcfb53d1bc56
trying to uncompress one zip archive
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 07 Dec 2020 20:38:31 +0100 |
parents | bf7b9edf6b81 |
children | 460a71988208 |
comparison
equal
deleted
inserted
replaced
4353:df15262373b0 | 4354:bcfb53d1bc56 |
---|---|
178 => There must be 6 files. The first 3 files must have a negative | 178 => There must be 6 files. The first 3 files must have a negative |
179 compression ratio. | 179 compression ratio. |
180 | 180 |
181 **/ | 181 **/ |
182 } | 182 } |
183 | |
184 | |
185 | |
186 | |
187 | |
188 #include "../Resources/ThirdParty/minizip/unzip.h" | |
189 | |
190 TEST(ZipReader, DISABLED_Basic) | |
191 { | |
192 unzFile zip = unzOpen("/home/jodogne/DICOM/Demo/BRAINIX.zip"); | |
193 printf(">> %d\n", zip); | |
194 | |
195 unz_global_info info; | |
196 printf(">> %d\n", unzGetGlobalInfo(zip, &info)); | |
197 printf("%d %d\n", info.number_entry, info.size_comment); | |
198 | |
199 unsigned int count = 0; | |
200 printf(">> %d\n", unzGoToFirstFile(zip)); | |
201 for (;;) | |
202 { | |
203 char f[1024]; | |
204 unz_file_info64_s j; | |
205 unzGetCurrentFileInfo64(zip, &j, f, sizeof(f) - 1, NULL, 0, NULL, 0); | |
206 printf("[%s] %d %d\n", f, j.uncompressed_size, j.size_filename); | |
207 | |
208 | |
209 printf("%d\n", unzOpenCurrentFile(zip)); | |
210 | |
211 std::string content; | |
212 content.resize(j.uncompressed_size); | |
213 if (!content.empty()) | |
214 { | |
215 printf("%d\n", unzReadCurrentFile(zip, &content[0], content.size())); | |
216 | |
217 char g[1024]; | |
218 sprintf(g, "/tmp/i/zip-%06d.dcm", count); | |
219 FILE* h = fopen(g, "wb"); | |
220 fwrite(content.c_str(), content.size(), 1, h); | |
221 fclose(h); | |
222 } | |
223 | |
224 printf("%d\n", unzCloseCurrentFile(zip)); | |
225 | |
226 | |
227 count += 1; | |
228 int i = unzGoToNextFile(zip); | |
229 if (i != 0) | |
230 { | |
231 printf("done\n"); | |
232 break; | |
233 } | |
234 } | |
235 | |
236 printf("count: %d\n", count); | |
237 | |
238 unzClose(zip); | |
239 } | |
240 |