2018-10-10 11:53:07 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "VirtualFileSystem.h"
|
|
|
|
#include <AK/ByteBuffer.h>
|
|
|
|
|
2018-10-14 21:19:27 +02:00
|
|
|
enum class SeekType {
|
|
|
|
Absolute, // SEEK_SET
|
|
|
|
RelativeToCurrent, // SEEK_CUR
|
|
|
|
RelativeToEnd, // SEEK_END
|
|
|
|
};
|
|
|
|
|
2018-10-10 11:53:07 +02:00
|
|
|
class FileHandle {
|
|
|
|
public:
|
|
|
|
explicit FileHandle(RetainPtr<VirtualFileSystem::Node>&&);
|
|
|
|
~FileHandle();
|
|
|
|
|
2018-10-14 21:19:27 +02:00
|
|
|
FileOffset lseek(FileOffset, SeekType);
|
|
|
|
ssize_t read(byte* buffer, size_t count);
|
|
|
|
|
|
|
|
ByteBuffer readEntireFile();
|
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
|
|
|
|
|
|
|
FileOffset m_currentOffset { 0 };
|
2018-10-10 11:53:07 +02:00
|
|
|
};
|
|
|
|
|