forked from techtronics/bermuda
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathfs.h
46 lines (34 loc) · 721 Bytes
/
fs.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
* Bermuda Syndrome engine rewrite
* Copyright (C) 2007-2011 Gregory Montoir
*/
#ifndef FS_H__
#define FS_H__
#include "intern.h"
struct File;
struct FileSystem_impl;
struct FileSystem {
FileSystem(const char *dataPath);
~FileSystem();
File *openFile(const char *path, bool errorIfNotFound = true);
void closeFile(File *f);
bool existFile(const char *path);
FileSystem_impl *_impl;
bool _romfs;
};
struct FileHolder {
FileHolder(FileSystem &fs, const char *path, bool errorIfNotFound = true)
: _fs(fs) {
_fp = _fs.openFile(path, errorIfNotFound);
}
~FileHolder() {
_fs.closeFile(_fp);
_fp = 0;
}
File *operator->() {
return _fp;
}
FileSystem &_fs;
File *_fp;
};
#endif // FS_H__