all repos — mgba @ a6001496bce5ff9c2ef2f93df2ab4fe396f48266

mGBA Game Boy Advance Emulator

src/util/vfs.h (view raw)

 1/* Copyright (c) 2013-2014 Jeffrey Pfau
 2 *
 3 * This Source Code Form is subject to the terms of the Mozilla Public
 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 6#ifndef VFS_H
 7#define VFS_H
 8
 9#include "util/common.h"
10
11enum {
12	MAP_READ = 1,
13	MAP_WRITE = 2
14};
15
16struct VFile {
17	bool (*close)(struct VFile* vf);
18	off_t (*seek)(struct VFile* vf, off_t offset, int whence);
19	ssize_t (*read)(struct VFile* vf, void* buffer, size_t size);
20	ssize_t (*readline)(struct VFile* vf, char* buffer, size_t size);
21	ssize_t (*write)(struct VFile* vf, const void* buffer, size_t size);
22	void* (*map)(struct VFile* vf, size_t size, int flags);
23	void (*unmap)(struct VFile* vf, void* memory, size_t size);
24	void (*truncate)(struct VFile* vf, size_t size);
25	ssize_t (*size)(struct VFile* vf);
26};
27
28struct VDirEntry {
29	const char* (*name)(struct VDirEntry* vde);
30};
31
32struct VDir {
33	bool (*close)(struct VDir* vd);
34	void (*rewind)(struct VDir* vd);
35	struct VDirEntry* (*listNext)(struct VDir* vd);
36	struct VFile* (*openFile)(struct VDir* vd, const char* name, int mode);
37};
38
39struct VFile* VFileOpen(const char* path, int flags);
40struct VFile* VFileFromFD(int fd);
41
42struct VDir* VDirOpen(const char* path);
43
44#ifdef ENABLE_LIBZIP
45struct VDir* VDirOpenZip(const char* path, int flags);
46#endif
47
48struct VFile* VDirOptionalOpenFile(struct VDir* dir, const char* realPath, const char* prefix, const char* suffix, int mode);
49struct VFile* VDirOptionalOpenIncrementFile(struct VDir* dir, const char* realPath, const char* prefix, const char* infix, const char* suffix, int mode);
50
51#endif