all repos — mgba @ b24b02d46cfd6fb4cc89d34fa38c442d31367017

mGBA Game Boy Advance Emulator

src/util/vfs.h (view raw)

 1#ifndef VFS_H
 2#define VFS_H
 3
 4#include "util/common.h"
 5
 6enum {
 7	MAP_READ = 1,
 8	MAP_WRITE = 2
 9};
10
11struct VFile {
12	bool (*close)(struct VFile* vf);
13	off_t (*seek)(struct VFile* vf, off_t offset, int whence);
14	ssize_t (*read)(struct VFile* vf, void* buffer, size_t size);
15	ssize_t (*readline)(struct VFile* vf, char* buffer, size_t size);
16	ssize_t (*write)(struct VFile* vf, const void* buffer, size_t size);
17	void* (*map)(struct VFile* vf, size_t size, int flags);
18	void (*unmap)(struct VFile* vf, void* memory, size_t size);
19	void (*truncate)(struct VFile* vf, size_t size);
20};
21
22struct VDirEntry {
23	const char* (*name)(struct VDirEntry* vde);
24};
25
26struct VDir {
27	bool (*close)(struct VDir* vd);
28	void (*rewind)(struct VDir* vd);
29	struct VDirEntry* (*listNext)(struct VDir* vd);
30	struct VFile* (*openFile)(struct VDir* vd, const char* name, int mode);
31};
32
33struct VFile* VFileOpen(const char* path, int flags);
34struct VFile* VFileFromFD(int fd);
35
36struct VDir* VDirOpen(const char* path);
37
38#ifdef ENABLE_LIBZIP
39struct VDir* VDirOpenZip(const char* path, int flags);
40#endif
41
42struct VFile* VDirOptionalOpenFile(struct VDir* dir, const char* realPath, const char* prefix, const char* suffix, int mode);
43struct VFile* VDirOptionalOpenIncrementFile(struct VDir* dir, const char* realPath, const char* prefix, const char* infix, const char* suffix, int mode);
44
45#endif