1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 02:47:35 +00:00

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
parent cafb5b2ad6
commit 8293a0ff36
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;