Mercurial > hg > orthanc
diff Core/FileStorage/FileStorage.cpp @ 1122:1d60316c3618
simplifications in FileStorage
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 05 Sep 2014 15:48:43 +0200 |
parents | a811bdf8b8eb |
children |
line wrap: on
line diff
--- a/Core/FileStorage/FileStorage.cpp Fri Sep 05 14:28:43 2014 +0200 +++ b/Core/FileStorage/FileStorage.cpp Fri Sep 05 15:48:43 2014 +0200 @@ -85,7 +85,7 @@ Toolbox::CreateDirectory(root); } - std::string FileStorage::CreateFileWithoutCompression(const void* content, size_t size) + std::string FileStorage::Create(const void* content, size_t size) { std::string uuid; boost::filesystem::path path; @@ -140,22 +140,6 @@ f.close(); return uuid; - } - - - std::string FileStorage::Create(const void* content, size_t size) - { - if (!HasBufferCompressor() || size == 0) - { - return CreateFileWithoutCompression(content, size); - } - else - { - std::string compressed; - compressor_->Compress(compressed, content, size); - assert(compressed.size() > 0); - return CreateFileWithoutCompression(&compressed[0], compressed.size()); - } } @@ -175,29 +159,15 @@ return Create(&content[0], content.size()); } - void FileStorage::ReadFile(std::string& content, - const std::string& uuid) const + void FileStorage::Read(std::string& content, + const std::string& uuid) const { content.clear(); - - if (HasBufferCompressor()) - { - std::string compressed; - Toolbox::ReadFile(compressed, ToString(GetPath(uuid))); - - if (compressed.size() != 0) - { - compressor_->Uncompress(content, compressed); - } - } - else - { - Toolbox::ReadFile(content, GetPath(uuid).string()); - } + Toolbox::ReadFile(content, GetPath(uuid).string()); } - uintmax_t FileStorage::GetCompressedSize(const std::string& uuid) const + uintmax_t FileStorage::GetSize(const std::string& uuid) const { boost::filesystem::path path = GetPath(uuid); return boost::filesystem::file_size(path);