annotate OrthancFramework/Sources/Compression/ZipReader.h @ 4792:434843934307 storage-cache

Added a StorageCache in the StorageAccessor
author Alain Mazy <am@osimis.io>
date Thu, 30 Sep 2021 12:14:19 +0200
parents d9473bd5ed43
children 7053502fbf97
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
4437
d9473bd5ed43 upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4356
diff changeset
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium
4355
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * 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
9 * as published by the Free Software Foundation, either version 3 of
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * the License, or (at your option) any later version.
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * 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
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * Lesser General Public License for more details.
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 *
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * 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
18 * License along with this program. If not, see
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * <http://www.gnu.org/licenses/>.
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 **/
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
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 #pragma once
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 #include "../OrthancFramework.h"
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 #if !defined(ORTHANC_SANDBOXED)
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 # error The macro ORTHANC_SANDBOXED must be defined
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 #endif
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 #if !defined(ORTHANC_ENABLE_ZLIB)
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 # error The macro ORTHANC_ENABLE_ZLIB must be defined
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 #endif
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 #if ORTHANC_ENABLE_ZLIB != 1
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 # error ZLIB support must be enabled to include this file
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 #endif
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 #include <stdint.h>
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 #include <string>
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 #include <boost/noncopyable.hpp>
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 #include <boost/shared_ptr.hpp>
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 namespace Orthanc
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 class ORTHANC_PUBLIC ZipReader : public boost::noncopyable
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 private:
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 class MemoryBuffer;
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 struct PImpl;
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 boost::shared_ptr<PImpl> pimpl_;
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 ZipReader();
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 void SeekFirst();
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 public:
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 ~ZipReader();
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 uint64_t GetFilesCount() const;
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64
4356
18c94a82f3d4 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4355
diff changeset
65 bool ReadNextFile(std::string& filename,
18c94a82f3d4 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4355
diff changeset
66 std::string& content);
4355
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 static ZipReader* CreateFromMemory(const void* buffer,
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 size_t size);
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 static ZipReader* CreateFromMemory(const std::string& buffer);
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 #if ORTHANC_SANDBOXED != 1
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 static ZipReader* CreateFromFile(const std::string& path);
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 #endif
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 static bool IsZipMemoryBuffer(const void* buffer,
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 size_t size);
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 static bool IsZipMemoryBuffer(const std::string& content);
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 #if ORTHANC_SANDBOXED != 1
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 static bool IsZipFile(const std::string& path);
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 #endif
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 };
460a71988208 new class: ZipReader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 }