| 1 | #ifndef MDFN_FILE_H |
| 2 | #define MDFN_FILE_H |
| 3 | |
| 4 | #include <string> |
| 5 | |
| 6 | #define MDFNFILE_EC_NOTFOUND 1 |
| 7 | #define MDFNFILE_EC_OTHER 2 |
| 8 | |
| 9 | class MDFNFILE |
| 10 | { |
| 11 | public: |
| 12 | |
| 13 | MDFNFILE(); |
| 14 | // WIP constructors: |
| 15 | MDFNFILE(const char *path, const void *known_ext, const char *purpose = NULL); |
| 16 | |
| 17 | ~MDFNFILE(); |
| 18 | |
| 19 | bool Open(const char *path, const void *known_ext, const char *purpose = NULL, const bool suppress_notfound_pe = FALSE); |
| 20 | INLINE bool Open(const std::string &path, const void *known_ext, const char *purpose = NULL, const bool suppress_notfound_pe = FALSE) |
| 21 | { |
| 22 | return(Open(path.c_str(), known_ext, purpose, suppress_notfound_pe)); |
| 23 | } |
| 24 | |
| 25 | bool ApplyIPS(void*); |
| 26 | bool Close(void); |
| 27 | |
| 28 | uint64 fread(void *ptr, size_t size, size_t nmemb); |
| 29 | int fseek(int64 offset, int whence); |
| 30 | |
| 31 | inline uint64 ftell(void) |
| 32 | { |
| 33 | return(location); |
| 34 | } |
| 35 | |
| 36 | inline void rewind(void) |
| 37 | { |
| 38 | location = 0; |
| 39 | } |
| 40 | |
| 41 | int read32le(uint32 *Bufo); |
| 42 | int read16le(uint16 *Bufo); |
| 43 | |
| 44 | inline int _fgetc(void) |
| 45 | { |
| 46 | if(location < f_size) |
| 47 | return f_data[location++]; |
| 48 | |
| 49 | return EOF; |
| 50 | } |
| 51 | |
| 52 | inline int fisarchive(void) |
| 53 | { |
| 54 | return(0); |
| 55 | } |
| 56 | |
| 57 | char *fgets(char *s, int size); |
| 58 | uint8 *f_data; |
| 59 | int64 f_size; |
| 60 | char *f_ext; |
| 61 | |
| 62 | private: |
| 63 | |
| 64 | int64 location; |
| 65 | |
| 66 | bool MakeMemWrapAndClose(void *tz); |
| 67 | }; |
| 68 | |
| 69 | #endif |