comparison OrthancFramework/Sources/Compression/ZipReader.h @ 4355:460a71988208

new class: ZipReader
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 08 Dec 2020 12:38:59 +0100
parents
children 18c94a82f3d4
comparison
equal deleted inserted replaced
4354:bcfb53d1bc56 4355:460a71988208
1 /**
2 * Orthanc - A Lightweight, RESTful DICOM Store
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
4 * Department, University Hospital of Liege, Belgium
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium
6 *
7 * This program is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public License
9 * as published by the Free Software Foundation, either version 3 of
10 * the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this program. If not, see
19 * <http://www.gnu.org/licenses/>.
20 **/
21
22
23 #pragma once
24
25 #include "../OrthancFramework.h"
26
27 #if !defined(ORTHANC_SANDBOXED)
28 # error The macro ORTHANC_SANDBOXED must be defined
29 #endif
30
31 #if !defined(ORTHANC_ENABLE_ZLIB)
32 # error The macro ORTHANC_ENABLE_ZLIB must be defined
33 #endif
34
35 #if ORTHANC_ENABLE_ZLIB != 1
36 # error ZLIB support must be enabled to include this file
37 #endif
38
39
40 #include <stdint.h>
41 #include <string>
42 #include <boost/noncopyable.hpp>
43 #include <boost/shared_ptr.hpp>
44
45
46 namespace Orthanc
47 {
48 class ORTHANC_PUBLIC ZipReader : public boost::noncopyable
49 {
50 private:
51 class MemoryBuffer;
52
53 struct PImpl;
54 boost::shared_ptr<PImpl> pimpl_;
55
56 ZipReader();
57
58 void SeekFirst();
59
60 public:
61 ~ZipReader();
62
63 uint64_t GetFilesCount() const;
64
65 bool ReadNextFile(std::string& content,
66 std::string& filename);
67
68 static ZipReader* CreateFromMemory(const void* buffer,
69 size_t size);
70
71 static ZipReader* CreateFromMemory(const std::string& buffer);
72
73 #if ORTHANC_SANDBOXED != 1
74 static ZipReader* CreateFromFile(const std::string& path);
75 #endif
76
77 static bool IsZipMemoryBuffer(const void* buffer,
78 size_t size);
79
80 static bool IsZipMemoryBuffer(const std::string& content);
81
82 #if ORTHANC_SANDBOXED != 1
83 static bool IsZipFile(const std::string& path);
84 #endif
85 };
86 }