1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-23 01:35:07 +00:00
serenity/VirtualFileSystem/FileHandle.h
Andreas Kling bca4b71bfa Lots of hacking to make a very simple "ls" utility.
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().
2018-10-24 12:50:07 +02:00

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
};