#pragma once #include "tl/ptr.h" #include "fs/IMapSource.h" #include "fs/AbsPath.h" #include "fs/Api.h" namespace fs { class NativeFilesystem; class FS_API FileMapSource final : public IMapSource { friend class NativeFilesystem; public: explicit FileMapSource(AbsPathView filepath); FileMapSource(AbsPathView filepath, uint64_t start, size_t size); ~FileMapSource() override; bool isValid() const; tl::optional getLastError() const override; size_t read(tl::span data) override; void seekBeg(uint64_t offset) override; void seekRel(int64_t offset) override; uint64_t tell() const override; uint64_t getSize() const override; tl::span map(size_t size) override; bool isEOS() const override; size_t getPreferredBufferSize() const override; private: uint64_t m_offset = 0; mutable tl::optional m_optLastError; struct Impl; tl::unique_ptr m_impl; }; }