mirror of
https://github.com/RGBCube/serenity
synced 2025-05-23 01:35:07 +00:00

I added a dead-simple malloc that only allows allocations < 4096 bytes. It just forwards the request to mmap() every time. I also added simplified versions of opendir() and readdir().
35 lines
689 B
C++
35 lines
689 B
C++
#pragma once
|
|
|
|
#include "VirtualFileSystem.h"
|
|
#include <AK/ByteBuffer.h>
|
|
|
|
class FileHandle {
|
|
public:
|
|
explicit FileHandle(RetainPtr<VirtualFileSystem::Node>&&);
|
|
~FileHandle();
|
|
|
|
Unix::off_t seek(Unix::off_t, int whence);
|
|
Unix::ssize_t read(byte* buffer, Unix::size_t count);
|
|
int stat(Unix::stat*);
|
|
|
|
ssize_t get_dir_entries(byte* buffer, Unix::size_t);
|
|
|
|
ByteBuffer readEntireFile();
|
|
|
|
#ifdef SERENITY
|
|
int fd() const { return m_fd; }
|
|
void setFD(int fd) { m_fd = fd; }
|
|
#endif
|
|
|
|
private:
|
|
friend class VirtualFileSystem;
|
|
|
|
RetainPtr<VirtualFileSystem::Node> m_vnode;
|
|
|
|
Unix::off_t m_currentOffset { 0 };
|
|
|
|
#ifdef SERENITY
|
|
int m_fd { -1 };
|
|
#endif
|
|
};
|
|
|