11 template<
typename Ptr> [[nodiscard]]
const std::string&
operator()(
const Ptr& p)
const {
16 GetURLFromDecompressed,
XXHasher> decompressCache;
20 : file(
std::move(file_))
27 auto it = decompressCache.find(
getURL());
28 assert(it !=
end(decompressCache));
29 assert(it->get() == decompressed);
31 if ((*it)->useCount == 0) {
33 decompressCache.erase(it);
38void CompressedFileAdapter::decompress()
40 if (decompressed)
return;
42 const std::string& url =
getURL();
43 auto it = decompressCache.find(url);
44 if (it ==
end(decompressCache)) {
45 auto d = std::make_unique<Decompressed>();
46 decompress(*file, *d);
49 it = decompressCache.insert_noDuplicateCheck(std::move(d));
52 decompressed = it->get();
61 if (decompressed->
buf.
size() < (pos + buffer.size())) {
70 throw FileException(
"Writing to compressed files not yet supported");
76 return std::span{decompressed->
buf};
87 return decompressed->
buf.
size();
102 throw FileException(
"Truncating compressed files not yet supported.");
112 return file ? file->getURL() : decompressed->
cachedURL;
128 return file ? file->getModificationDate()
void read(std::span< uint8_t > buffer) final
std::string_view getOriginalName() final
virtual void decompress(FileBase &file, Decompressed &decompressed)=0
std::span< const uint8_t > mmap() final
void truncate(size_t size) final
bool isReadOnly() const final
void write(std::span< const uint8_t > buffer) final
~CompressedFileAdapter() override
const std::string & getURL() const final
CompressedFileAdapter(std::unique_ptr< FileBase > file)
void seek(size_t pos) final
time_t getModificationDate() final
std::span< const T > subspan(size_t offset, size_t n=std::dynamic_extent) const
This file implemented 3 utility functions:
constexpr auto copy(InputRange &&range, OutputIter out)
time_t cachedModificationDate
const std::string & operator()(const Ptr &p) const
constexpr auto end(const zstring_view &x)