annotate OrthancFramework/Sources/Compression/ZipReader.h @ 5853:4d932683049d get-scu tip

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