annotate Common/FileSystemStorage.h @ 191:61ab81a0f27d

integration 1.3.1: back to mainline
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 25 Jun 2024 12:20:19 +0200
parents 6dd8bb916573
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
77
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
1 /**
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
2 * Cloud storage plugins for Orthanc
145
3c7e0374f28e updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 111
diff changeset
3 * Copyright (C) 2020-2023 Osimis S.A., Belgium
3c7e0374f28e updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 111
diff changeset
4 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium
3c7e0374f28e updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 111
diff changeset
5 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
77
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
6 *
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
8 * modify it under the terms of the GNU Affero General Public License
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
10 * the License, or (at your option) any later version.
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
11 *
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
15 * Affero General Public License for more details.
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
16 *
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
17 * You should have received a copy of the GNU Affero General Public License
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
19 **/
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
20
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
21
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
22 #pragma once
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
23
78
d7295e8678d7 renames
Alain Mazy <am@osimis.io>
parents: 77
diff changeset
24 #include "IStorage.h"
77
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
25 #include <boost/filesystem.hpp>
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
26
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
27 namespace fs = boost::filesystem;
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
28
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
29
78
d7295e8678d7 renames
Alain Mazy <am@osimis.io>
parents: 77
diff changeset
30 class FileSystemStoragePlugin: public IStorage
77
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
31 {
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
32 public:
78
d7295e8678d7 renames
Alain Mazy <am@osimis.io>
parents: 77
diff changeset
33 class FileSystemWriter: public IStorage::IWriter
77
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
34 {
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
35 const fs::path path_;
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
36 bool fsync_;
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
37 public:
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
38 FileSystemWriter(const fs::path& path, bool fsync)
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
39 : path_(path),
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
40 fsync_(fsync)
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
41 {}
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
42
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
43 virtual ~FileSystemWriter() {}
153
6dd8bb916573 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 145
diff changeset
44 virtual void Write(const char* data, size_t size) ORTHANC_OVERRIDE;
77
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
45 };
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
46
78
d7295e8678d7 renames
Alain Mazy <am@osimis.io>
parents: 77
diff changeset
47 class FileSystemReader: public IStorage::IReader
77
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
48 {
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
49 const fs::path path_;
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
50 public:
153
6dd8bb916573 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 145
diff changeset
51 explicit FileSystemReader(const fs::path& path)
77
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
52 : path_(path)
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
53 {}
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
54
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
55 virtual ~FileSystemReader() {}
153
6dd8bb916573 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 145
diff changeset
56 virtual size_t GetSize() ORTHANC_OVERRIDE;
6dd8bb916573 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 145
diff changeset
57 virtual void ReadWhole(char* data, size_t size) ORTHANC_OVERRIDE;
6dd8bb916573 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 145
diff changeset
58 virtual void ReadRange(char* data, size_t size, size_t fromOffset) ORTHANC_OVERRIDE;
77
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
59 };
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
60
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
61 std::string fileSystemRootPath_;
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
62 bool fsync_;
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
63 public:
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
64 FileSystemStoragePlugin(const std::string& nameForLogs, const std::string& fileSystemRootPath, bool fsync)
78
d7295e8678d7 renames
Alain Mazy <am@osimis.io>
parents: 77
diff changeset
65 : IStorage(nameForLogs),
77
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
66 fileSystemRootPath_(fileSystemRootPath),
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
67 fsync_(fsync)
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
68 {}
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
69
153
6dd8bb916573 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 145
diff changeset
70 virtual void SetRootPath(const std::string& rootPath) ORTHANC_OVERRIDE {}
77
80792bb9600e new HybridMode
Alain Mazy <am@osimis.io>
parents:
diff changeset
71
153
6dd8bb916573 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 145
diff changeset
72 virtual IStorage::IWriter* GetWriterForObject(const char* uuid, OrthancPluginContentType type, bool encryptionEnabled) ORTHANC_OVERRIDE;
6dd8bb916573 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 145
diff changeset
73 virtual IStorage::IReader* GetReaderForObject(const char* uuid, OrthancPluginContentType type, bool encryptionEnabled) ORTHANC_OVERRIDE;
6dd8bb916573 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 145
diff changeset
74 virtual void DeleteObject(const char* uuid, OrthancPluginContentType type, bool encryptionEnabled) ORTHANC_OVERRIDE;
111
407bd022b0cf in /move-storage: now detecting if file should be moved or not
Alain Mazy <am@osimis.io>
parents: 78
diff changeset
75
153
6dd8bb916573 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 145
diff changeset
76 virtual bool HasFileExists() ORTHANC_OVERRIDE {return true;};
6dd8bb916573 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 145
diff changeset
77 virtual bool FileExists(const std::string& uuid, OrthancPluginContentType type, bool encryptionEnabled) ORTHANC_OVERRIDE;
6dd8bb916573 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 145
diff changeset
78 };