Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/libsnes/bsnes/nall/stream/file.hpp
2 views
1
#ifdef NALL_STREAM_INTERNAL_HPP
2
3
namespace nall {
4
5
struct filestream : stream {
6
inline bool seekable() const { return true; }
7
inline bool readable() const { return true; }
8
inline bool writable() const { return pwritable; }
9
inline bool randomaccess() const { return false; }
10
11
inline unsigned size() const { return pfile.size(); }
12
inline unsigned offset() const { return pfile.offset(); }
13
inline void seek(unsigned offset) const { pfile.seek(offset); }
14
15
inline uint8_t read() const { return pfile.read(); }
16
inline void write(uint8_t data) const { pfile.write(data); }
17
18
inline filestream(const string &filename) {
19
pfile.open(filename, file::mode::readwrite);
20
pwritable = pfile.open();
21
if(!pwritable) pfile.open(filename, file::mode::read);
22
}
23
24
private:
25
mutable file pfile;
26
bool pwritable;
27
};
28
29
}
30
31
#endif
32
33