mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-25 10:48:41 +00:00
Instead of having DiskBackedFS allocate a ByteBuffer, leave it to each client to provide buffer space. This is significantly faster in many cases where we can use a stack buffer and avoid heap allocation entirely.
34 lines
831 B
C++
34 lines
831 B
C++
#pragma once
|
|
|
|
#include "FileSystem.h"
|
|
#include <AK/ByteBuffer.h>
|
|
|
|
class DiskCache;
|
|
|
|
class DiskBackedFS : public FS {
|
|
public:
|
|
virtual ~DiskBackedFS() override;
|
|
|
|
virtual bool is_disk_backed() const override { return true; }
|
|
|
|
DiskDevice& device() { return *m_device; }
|
|
const DiskDevice& device() const { return *m_device; }
|
|
|
|
virtual void flush_writes() override;
|
|
|
|
protected:
|
|
explicit DiskBackedFS(NonnullRefPtr<DiskDevice>&&);
|
|
|
|
bool read_block(unsigned index, u8* buffer) const;
|
|
bool read_blocks(unsigned index, unsigned count, u8* buffer) const;
|
|
|
|
bool write_block(unsigned index, const ByteBuffer&);
|
|
bool write_blocks(unsigned index, unsigned count, const ByteBuffer&);
|
|
|
|
private:
|
|
DiskCache& cache() const;
|
|
|
|
NonnullRefPtr<DiskDevice> m_device;
|
|
mutable OwnPtr<DiskCache> m_cache;
|
|
};
|