2022-10-10 17:00:24 +00:00
|
|
|
#include "fs/FileDescriptor.h"
|
|
|
|
|
|
|
|
Descriptor::Descriptor() : m_is_open(false)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
Descriptor::Descriptor(const Descriptor& other)
|
2022-10-10 18:21:39 +00:00
|
|
|
: m_is_open(other.m_is_open), m_can_read(other.m_can_read), m_node(other.m_node), m_offset(other.m_offset)
|
2022-10-10 17:00:24 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void Descriptor::open(VFS::Node* node, bool can_read)
|
|
|
|
{
|
|
|
|
m_can_read = can_read;
|
|
|
|
m_node = node;
|
|
|
|
m_offset = 0;
|
2022-10-10 18:21:39 +00:00
|
|
|
m_is_open = true;
|
2022-10-10 17:00:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ssize_t Descriptor::read(size_t size, char* buffer)
|
|
|
|
{
|
|
|
|
ssize_t result = VFS::read(m_node, m_offset, size, buffer);
|
|
|
|
m_offset += result;
|
|
|
|
return result;
|
|
|
|
}
|