mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 15:57:34 +00:00
Import all this stuff into a single repo called Serenity.
This commit is contained in:
commit
5a30055157
67 changed files with 8836 additions and 0 deletions
32
VirtualFileSystem/FileBackedBlockDevice.h
Normal file
32
VirtualFileSystem/FileBackedBlockDevice.h
Normal file
|
@ -0,0 +1,32 @@
|
|||
#pragma once
|
||||
|
||||
#include "BlockDevice.h"
|
||||
#include <AK/RetainPtr.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/Types.h>
|
||||
#include <stdio.h>
|
||||
|
||||
class FileBackedBlockDevice final : public BlockDevice {
|
||||
public:
|
||||
static RetainPtr<FileBackedBlockDevice> create(String&& imagePath, unsigned blockSize);
|
||||
virtual ~FileBackedBlockDevice() override;
|
||||
|
||||
bool isValid() const { return m_file; }
|
||||
|
||||
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;
|
||||
|
||||
FileBackedBlockDevice(String&& imagePath, unsigned blockSize);
|
||||
|
||||
String m_imagePath;
|
||||
FILE* m_file { nullptr };
|
||||
qword m_fileLength { 0 };
|
||||
unsigned m_blockSize { 0 };
|
||||
};
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue