2018-10-10 11:53:07 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "VirtualFileSystem.h"
|
|
|
|
#include <AK/ByteBuffer.h>
|
|
|
|
|
|
|
|
class FileHandle {
|
|
|
|
public:
|
|
|
|
explicit FileHandle(RetainPtr<VirtualFileSystem::Node>&&);
|
|
|
|
~FileHandle();
|
|
|
|
|
2018-10-14 22:57:41 +02:00
|
|
|
Unix::off_t seek(Unix::off_t, int whence);
|
|
|
|
Unix::ssize_t read(byte* buffer, Unix::size_t count);
|
|
|
|
int stat(Unix::stat*);
|
2018-10-14 21:19:27 +02:00
|
|
|
|
2018-10-24 12:43:52 +02:00
|
|
|
ssize_t get_dir_entries(byte* buffer, Unix::size_t);
|
|
|
|
|
2018-10-14 21:19:27 +02:00
|
|
|
ByteBuffer readEntireFile();
|
2018-10-10 11:53:07 +02:00
|
|
|
|
2018-10-24 14:28:22 +02:00
|
|
|
String absolutePath() const;
|
|
|
|
|
2018-10-22 14:06:22 +02:00
|
|
|
#ifdef SERENITY
|
2018-10-18 10:27:07 +02:00
|
|
|
int fd() const { return m_fd; }
|
|
|
|
void setFD(int fd) { m_fd = fd; }
|
|
|
|
#endif
|
|
|
|
|
2018-10-10 11:53:07 +02:00
|
|
|
private:
|
|
|
|
friend class VirtualFileSystem;
|
|
|
|
|
|
|
|
RetainPtr<VirtualFileSystem::Node> m_vnode;
|
2018-10-14 21:19:27 +02:00
|
|
|
|
2018-10-14 22:57:41 +02:00
|
|
|
Unix::off_t m_currentOffset { 0 };
|
2018-10-18 10:27:07 +02:00
|
|
|
|
2018-10-22 14:06:22 +02:00
|
|
|
#ifdef SERENITY
|
2018-10-18 10:27:07 +02:00
|
|
|
int m_fd { -1 };
|
|
|
|
#endif
|
2018-10-10 11:53:07 +02:00
|
|
|
};
|
|
|
|
|