77
|
1 /**
|
|
2 * Cloud storage plugins for Orthanc
|
|
3 * Copyright (C) 2020-2021 Osimis S.A., Belgium
|
|
4 *
|
|
5 * This program is free software: you can redistribute it and/or
|
|
6 * modify it under the terms of the GNU Affero General Public License
|
|
7 * as published by the Free Software Foundation, either version 3 of
|
|
8 * the License, or (at your option) any later version.
|
|
9 *
|
|
10 * This program is distributed in the hope that it will be useful, but
|
|
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
13 * Affero General Public License for more details.
|
|
14 *
|
|
15 * You should have received a copy of the GNU Affero General Public License
|
|
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17 **/
|
|
18
|
|
19
|
|
20 #pragma once
|
|
21
|
78
|
22 #include "IStorage.h"
|
77
|
23 #include <boost/filesystem.hpp>
|
|
24
|
|
25 namespace fs = boost::filesystem;
|
|
26
|
|
27
|
78
|
28 class FileSystemStoragePlugin: public IStorage
|
77
|
29 {
|
|
30 public:
|
78
|
31 class FileSystemWriter: public IStorage::IWriter
|
77
|
32 {
|
|
33 const fs::path path_;
|
|
34 bool fsync_;
|
|
35 public:
|
|
36 FileSystemWriter(const fs::path& path, bool fsync)
|
|
37 : path_(path),
|
|
38 fsync_(fsync)
|
|
39 {}
|
|
40
|
|
41 virtual ~FileSystemWriter() {}
|
|
42 virtual void Write(const char* data, size_t size);
|
|
43 };
|
|
44
|
78
|
45 class FileSystemReader: public IStorage::IReader
|
77
|
46 {
|
|
47 const fs::path path_;
|
|
48 public:
|
|
49 FileSystemReader(const fs::path& path)
|
|
50 : path_(path)
|
|
51 {}
|
|
52
|
|
53 virtual ~FileSystemReader() {}
|
|
54 virtual size_t GetSize();
|
|
55 virtual void ReadWhole(char* data, size_t size);
|
|
56 virtual void ReadRange(char* data, size_t size, size_t fromOffset);
|
|
57 };
|
|
58
|
|
59 std::string fileSystemRootPath_;
|
|
60 bool fsync_;
|
|
61 public:
|
|
62 FileSystemStoragePlugin(const std::string& nameForLogs, const std::string& fileSystemRootPath, bool fsync)
|
78
|
63 : IStorage(nameForLogs),
|
77
|
64 fileSystemRootPath_(fileSystemRootPath),
|
|
65 fsync_(fsync)
|
|
66 {}
|
|
67
|
|
68 virtual void SetRootPath(const std::string& rootPath) {}
|
|
69
|
78
|
70 virtual IStorage::IWriter* GetWriterForObject(const char* uuid, OrthancPluginContentType type, bool encryptionEnabled);
|
|
71 virtual IStorage::IReader* GetReaderForObject(const char* uuid, OrthancPluginContentType type, bool encryptionEnabled);
|
77
|
72 virtual void DeleteObject(const char* uuid, OrthancPluginContentType type, bool encryptionEnabled);
|
|
73 }; |