mirror of
https://github.com/RGBCube/serenity
synced 2025-07-10 04:17:34 +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:
parent
cafb5b2ad6
commit
8293a0ff36
5 changed files with 47 additions and 10 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue