src/util/vfile.h (view raw)
1#ifndef VFILE_H
2#define VFILE_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 VFile* VFileOpen(const char* path, int flags);
20struct VFile* VFileFromFD(int fd);
21
22#endif