mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 14:37:45 +00:00
Kernel: Move devices into Kernel/Devices/.
This commit is contained in:
parent
072ea7eece
commit
ab43658c55
42 changed files with 53 additions and 54 deletions
33
Kernel/Devices/FileBackedDiskDevice.h
Normal file
33
Kernel/Devices/FileBackedDiskDevice.h
Normal file
|
@ -0,0 +1,33 @@
|
|||
#pragma once
|
||||
|
||||
#include <Kernel/Devices/DiskDevice.h>
|
||||
#include <AK/RetainPtr.h>
|
||||
#include <AK/AKString.h>
|
||||
#include <AK/Types.h>
|
||||
#include <stdio.h>
|
||||
|
||||
class FileBackedDiskDevice final : public DiskDevice {
|
||||
public:
|
||||
static RetainPtr<FileBackedDiskDevice> create(String&& image_path, unsigned block_size);
|
||||
virtual ~FileBackedDiskDevice() override;
|
||||
|
||||
bool is_valid() const { return m_file; }
|
||||
|
||||
virtual unsigned block_size() const override;
|
||||
virtual bool read_block(unsigned index, byte* out) const override;
|
||||
virtual bool write_block(unsigned index, const byte*) override;
|
||||
|
||||
private:
|
||||
virtual const char* class_name() const override;
|
||||
|
||||
bool read_internal(DiskOffset, unsigned length, byte* out) const;
|
||||
bool write_internal(DiskOffset, unsigned length, const byte* data);
|
||||
|
||||
FileBackedDiskDevice(String&& imagePath, unsigned block_size);
|
||||
|
||||
String m_image_path;
|
||||
FILE* m_file { nullptr };
|
||||
DiskOffset m_file_length { 0 };
|
||||
unsigned m_block_size { 0 };
|
||||
};
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue