mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-29 14:14:45 +03:00
38 lines
1.4 KiB
C++
38 lines
1.4 KiB
C++
#pragma once
|
|
|
|
#include "FileSystem.h"
|
|
#include "UnixTypes.h"
|
|
#include <AK/HashMap.h>
|
|
|
|
class SyntheticFileSystem final : public FileSystem {
|
|
public:
|
|
virtual ~SyntheticFileSystem() override;
|
|
static RetainPtr<SyntheticFileSystem> create();
|
|
|
|
virtual bool initialize() override;
|
|
virtual const char* className() const override;
|
|
virtual InodeIdentifier rootInode() const override;
|
|
virtual bool writeInode(InodeIdentifier, const ByteBuffer&) override;
|
|
virtual bool enumerateDirectoryInode(InodeIdentifier, std::function<bool(const DirectoryEntry&)>) const override;
|
|
virtual InodeMetadata inodeMetadata(InodeIdentifier) const override;
|
|
virtual bool setModificationTime(InodeIdentifier, dword timestamp) override;
|
|
virtual InodeIdentifier createInode(InodeIdentifier parentInode, const String& name, Unix::mode_t, unsigned size) override;
|
|
virtual Unix::ssize_t readInodeBytes(InodeIdentifier, Unix::off_t offset, Unix::size_t count, byte* buffer) const override;
|
|
virtual InodeIdentifier makeDirectory(InodeIdentifier parentInode, const String& name, Unix::mode_t) override;
|
|
|
|
private:
|
|
SyntheticFileSystem();
|
|
|
|
struct File {
|
|
String name;
|
|
InodeMetadata metadata;
|
|
ByteBuffer data;
|
|
};
|
|
|
|
OwnPtr<File> createTextFile(String&& name, String&& text);
|
|
void addFile(OwnPtr<File>&&);
|
|
|
|
Vector<OwnPtr<File>> m_files;
|
|
};
|
|
|