Mercurial > hg > orthanc-object-storage
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 |
rev | line source |
---|---|
77 | 1 /** |
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 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
8 * modify it under the terms of the GNU Affero 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 * Affero General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU Affero General Public License | |
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 **/ | |
20 | |
21 | |
22 #pragma once | |
23 | |
78 | 24 #include "IStorage.h" |
77 | 25 #include <boost/filesystem.hpp> |
26 | |
27 namespace fs = boost::filesystem; | |
28 | |
29 | |
78 | 30 class FileSystemStoragePlugin: public IStorage |
77 | 31 { |
32 public: | |
78 | 33 class FileSystemWriter: public IStorage::IWriter |
77 | 34 { |
35 const fs::path path_; | |
36 bool fsync_; | |
37 public: | |
38 FileSystemWriter(const fs::path& path, bool fsync) | |
39 : path_(path), | |
40 fsync_(fsync) | |
41 {} | |
42 | |
43 virtual ~FileSystemWriter() {} | |
153 | 44 virtual void Write(const char* data, size_t size) ORTHANC_OVERRIDE; |
77 | 45 }; |
46 | |
78 | 47 class FileSystemReader: public IStorage::IReader |
77 | 48 { |
49 const fs::path path_; | |
50 public: | |
153 | 51 explicit FileSystemReader(const fs::path& path) |
77 | 52 : path_(path) |
53 {} | |
54 | |
55 virtual ~FileSystemReader() {} | |
153 | 56 virtual size_t GetSize() ORTHANC_OVERRIDE; |
57 virtual void ReadWhole(char* data, size_t size) ORTHANC_OVERRIDE; | |
58 virtual void ReadRange(char* data, size_t size, size_t fromOffset) ORTHANC_OVERRIDE; | |
77 | 59 }; |
60 | |
61 std::string fileSystemRootPath_; | |
62 bool fsync_; | |
63 public: | |
64 FileSystemStoragePlugin(const std::string& nameForLogs, const std::string& fileSystemRootPath, bool fsync) | |
78 | 65 : IStorage(nameForLogs), |
77 | 66 fileSystemRootPath_(fileSystemRootPath), |
67 fsync_(fsync) | |
68 {} | |
69 | |
153 | 70 virtual void SetRootPath(const std::string& rootPath) ORTHANC_OVERRIDE {} |
77 | 71 |
153 | 72 virtual IStorage::IWriter* GetWriterForObject(const char* uuid, OrthancPluginContentType type, bool encryptionEnabled) ORTHANC_OVERRIDE; |
73 virtual IStorage::IReader* GetReaderForObject(const char* uuid, OrthancPluginContentType type, bool encryptionEnabled) ORTHANC_OVERRIDE; | |
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 | 76 virtual bool HasFileExists() ORTHANC_OVERRIDE {return true;}; |
77 virtual bool FileExists(const std::string& uuid, OrthancPluginContentType type, bool encryptionEnabled) ORTHANC_OVERRIDE; | |
78 }; |