Mercurial > hg > orthanc
comparison Core/FileStorage/FileStorage.h @ 1122:1d60316c3618
simplifications in FileStorage
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 05 Sep 2014 15:48:43 +0200 |
parents | 2d0a347e8cfc |
children |
comparison
equal
deleted
inserted
replaced
1121:82567bac5e25 | 1122:1d60316c3618 |
---|---|
33 #pragma once | 33 #pragma once |
34 | 34 |
35 #include <boost/filesystem.hpp> | 35 #include <boost/filesystem.hpp> |
36 #include <set> | 36 #include <set> |
37 | 37 |
38 #include "../Compression/BufferCompressor.h" | |
39 | |
40 namespace Orthanc | 38 namespace Orthanc |
41 { | 39 { |
42 class FileStorage : public boost::noncopyable | 40 class FileStorage : public boost::noncopyable |
43 { | 41 { |
44 // TODO REMOVE THIS | 42 // TODO REMOVE THIS |
45 friend class FilesystemHttpSender; | 43 friend class FilesystemHttpSender; |
46 friend class FileStorageAccessor; | 44 friend class FileStorageAccessor; |
47 | 45 |
48 private: | 46 private: |
49 std::auto_ptr<BufferCompressor> compressor_; | |
50 | |
51 boost::filesystem::path root_; | 47 boost::filesystem::path root_; |
52 | 48 |
53 boost::filesystem::path GetPath(const std::string& uuid) const; | 49 boost::filesystem::path GetPath(const std::string& uuid) const; |
54 | 50 |
55 std::string CreateFileWithoutCompression(const void* content, size_t size); | |
56 | |
57 public: | 51 public: |
58 FileStorage(std::string root); | 52 FileStorage(std::string root); |
59 | |
60 void SetBufferCompressor(BufferCompressor* compressor) // Takes the ownership | |
61 { | |
62 compressor_.reset(compressor); | |
63 } | |
64 | |
65 bool HasBufferCompressor() const | |
66 { | |
67 return compressor_.get() != NULL; | |
68 } | |
69 | 53 |
70 std::string Create(const void* content, size_t size); | 54 std::string Create(const void* content, size_t size); |
71 | 55 |
72 std::string Create(const std::vector<uint8_t>& content); | 56 std::string Create(const std::vector<uint8_t>& content); |
73 | 57 |
74 std::string Create(const std::string& content); | 58 std::string Create(const std::string& content); |
75 | 59 |
76 void ReadFile(std::string& content, | 60 void Read(std::string& content, |
77 const std::string& uuid) const; | 61 const std::string& uuid) const; |
78 | 62 |
79 void ListAllFiles(std::set<std::string>& result) const; | 63 void ListAllFiles(std::set<std::string>& result) const; |
80 | 64 |
81 uintmax_t GetCompressedSize(const std::string& uuid) const; | 65 uintmax_t GetSize(const std::string& uuid) const; |
82 | 66 |
83 void Clear(); | 67 void Clear(); |
84 | 68 |
85 void Remove(const std::string& uuid); | 69 void Remove(const std::string& uuid); |
86 | 70 |
87 uintmax_t GetCapacity() const; | 71 uintmax_t GetCapacity() const; |
88 | 72 |
89 uintmax_t GetAvailableSpace() const; | 73 uintmax_t GetAvailableSpace() const; |
90 | |
91 std::string GetPath() const | |
92 { | |
93 return root_.string(); | |
94 } | |
95 }; | 74 }; |
96 } | 75 } |