src/util/vfs.h (view raw)
1#ifndef VFS_H
2#define VFS_H
3
4#include "common.h"
5
6#include "memory.h"
7
8struct VFile {
9 bool (*close)(struct VFile* vf);
10 off_t (*seek)(struct VFile* vf, off_t offset, int whence);
11 ssize_t (*read)(struct VFile* vf, void* buffer, size_t size);
12 ssize_t (*readline)(struct VFile* vf, char* buffer, size_t size);
13 ssize_t (*write)(struct VFile* vf, void* buffer, size_t size);
14 void* (*map)(struct VFile* vf, size_t size, int flags);
15 void (*unmap)(struct VFile* vf, void* memory, size_t size);
16 void (*truncate)(struct VFile* vf, size_t size);
17};
18
19struct VDirEntry {
20 const char* (*name)(struct VDirEntry* vde);
21};
22
23struct VDir {
24 bool (*close)(struct VDir* vd);
25 struct VDirEntry* (*listNext)(struct VDir* vd);
26 struct VFile* (*openFile)(struct VDir* vd, const char* name, int mode);
27};
28
29struct VFile* VFileOpen(const char* path, int flags);
30struct VFile* VFileFromFD(int fd);
31
32struct VDir* VDirOpen(const char* path);
33
34#endif