mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 08:36:15 +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:
@@ -35,16 +35,16 @@ unsigned FileBackedDiskDevice::blockSize() const
|
||||
bool FileBackedDiskDevice::readBlock(unsigned index, byte* out) const
|
||||
{
|
||||
qword offset = index * m_blockSize;
|
||||
return read(offset, blockSize(), out);
|
||||
return readInternal(offset, blockSize(), out);
|
||||
}
|
||||
|
||||
bool FileBackedDiskDevice::writeBlock(unsigned index, const byte* data)
|
||||
{
|
||||
qword offset = index * m_blockSize;
|
||||
return write(offset, blockSize(), data);
|
||||
return writeInternal(offset, blockSize(), data);
|
||||
}
|
||||
|
||||
bool FileBackedDiskDevice::read(qword offset, unsigned length, byte* out) const
|
||||
bool FileBackedDiskDevice::readInternal(qword offset, unsigned length, byte* out) const
|
||||
{
|
||||
#ifndef IGNORE_FILE_LENGTH
|
||||
if (offset + length >= m_fileLength)
|
||||
@@ -59,7 +59,7 @@ bool FileBackedDiskDevice::read(qword offset, unsigned length, byte* out) const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FileBackedDiskDevice::write(qword offset, unsigned length, const byte* data)
|
||||
bool FileBackedDiskDevice::writeInternal(qword offset, unsigned length, const byte* data)
|
||||
{
|
||||
#ifndef IGNORE_FILE_LENGTH
|
||||
if (offset + length >= m_fileLength)
|
||||
|
||||
Reference in New Issue
Block a user