DiskBackedFileSystem.h 815 B

123456789101112131415161718192021222324252627282930313233
  1. #pragma once
  2. #include "FileSystem.h"
  3. #include <AK/ByteBuffer.h>
  4. class DiskCache;
  5. class DiskBackedFS : public FS {
  6. public:
  7. virtual ~DiskBackedFS() override;
  8. virtual bool is_disk_backed() const override { return true; }
  9. DiskDevice& device() { return *m_device; }
  10. const DiskDevice& device() const { return *m_device; }
  11. virtual void flush_writes() override;
  12. protected:
  13. explicit DiskBackedFS(NonnullRefPtr<DiskDevice>&&);
  14. bool read_block(unsigned index, u8* buffer) const;
  15. bool read_blocks(unsigned index, unsigned count, u8* buffer) const;
  16. bool write_block(unsigned index, const u8*);
  17. bool write_blocks(unsigned index, unsigned count, const u8*);
  18. private:
  19. DiskCache& cache() const;
  20. NonnullRefPtr<DiskDevice> m_device;
  21. mutable OwnPtr<DiskCache> m_cache;
  22. };