52 lines
841 B
C++
52 lines
841 B
C++
#pragma once
|
|
#include "fs/VFS.h"
|
|
#include <stdint.h>
|
|
|
|
struct Descriptor
|
|
{
|
|
bool is_open()
|
|
{
|
|
return m_is_open;
|
|
}
|
|
|
|
bool can_read()
|
|
{
|
|
return m_can_read && m_is_open;
|
|
}
|
|
|
|
bool can_write()
|
|
{
|
|
return m_can_write && m_is_open;
|
|
}
|
|
|
|
void close()
|
|
{
|
|
m_is_open = false;
|
|
}
|
|
|
|
ssize_t read(size_t size, char* buffer);
|
|
ssize_t write(size_t size, const char* buffer);
|
|
|
|
void open(VFS::Node* node, bool can_read, bool can_write);
|
|
|
|
int seek(long offset);
|
|
long offset()
|
|
{
|
|
return (long)m_offset;
|
|
}
|
|
|
|
unsigned long length()
|
|
{
|
|
return m_node->length;
|
|
}
|
|
|
|
Descriptor(const Descriptor& other);
|
|
Descriptor();
|
|
|
|
private:
|
|
bool m_is_open;
|
|
bool m_can_read;
|
|
bool m_can_write;
|
|
VFS::Node* m_node;
|
|
uint64_t m_offset;
|
|
}; |