24 lines
482 B
C++
24 lines
482 B
C++
|
#include "fs/VFS.h"
|
||
|
|
||
|
static VFS::Node* vfs_root;
|
||
|
|
||
|
int32_t VFS::read(Node* node, uint32_t offset, uint32_t length, char* buffer)
|
||
|
{
|
||
|
if (!node) return -1;
|
||
|
if (!node->read_func) return -1;
|
||
|
|
||
|
return node->read_func(node, offset, length, buffer);
|
||
|
}
|
||
|
|
||
|
VFS::Node* VFS::open(const char* filename)
|
||
|
{
|
||
|
if (!vfs_root) return 0;
|
||
|
if (!vfs_root->find_func) return 0;
|
||
|
|
||
|
return vfs_root->find_func(vfs_root, filename);
|
||
|
}
|
||
|
|
||
|
void VFS::mount_root(Node* root)
|
||
|
{
|
||
|
vfs_root = root;
|
||
|
}
|