Rework DiskDevice's read() and write() to be non-virtual wrappers.

This way subclasses only have to implement readBlock() and writeBlock().
read() and write() require that the offset and length are both divisible
by the blockSize().
This commit is contained in:
Andreas Kling 2018-10-16 14:11:58 +02:00
commit 8293a0ff36
Notes: sideshowbarker 2024-07-19 18:47:22 +09:00
5 changed files with 47 additions and 10 deletions

View file

@ -16,12 +16,13 @@ public:
virtual unsigned blockSize() const override;
virtual bool readBlock(unsigned index, byte* out) const override;
virtual bool writeBlock(unsigned index, const byte*) override;
virtual bool read(qword offset, unsigned length, byte* out) const override;
virtual bool write(qword offset, unsigned length, const byte* data) override;
private:
virtual const char* className() const override;
bool readInternal(qword offset, unsigned length, byte* out) const;
bool writeInternal(qword offset, unsigned length, const byte* data);
FileBackedDiskDevice(String&& imagePath, unsigned blockSize);
String m_imagePath;