DiskBackedFileSystem.h 780 B

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