2012-06-03 15:48:14 +00:00
|
|
|
#ifndef MDFN_FILE_H
|
|
|
|
#define MDFN_FILE_H
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#define MDFNFILE_EC_NOTFOUND 1
|
|
|
|
#define MDFNFILE_EC_OTHER 2
|
|
|
|
|
|
|
|
class MDFNFILE
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
MDFNFILE();
|
|
|
|
// WIP constructors:
|
2012-12-30 03:04:25 +00:00
|
|
|
MDFNFILE(const char *path, const void *known_ext, const char *purpose = NULL);
|
2012-06-03 15:48:14 +00:00
|
|
|
|
|
|
|
~MDFNFILE();
|
|
|
|
|
2012-12-30 03:04:25 +00:00
|
|
|
bool Open(const char *path, const void *known_ext, const char *purpose = NULL, const bool suppress_notfound_pe = FALSE);
|
|
|
|
INLINE bool Open(const std::string &path, const void *known_ext, const char *purpose = NULL, const bool suppress_notfound_pe = FALSE)
|
2012-06-03 15:48:14 +00:00
|
|
|
{
|
|
|
|
return(Open(path.c_str(), known_ext, purpose, suppress_notfound_pe));
|
|
|
|
}
|
|
|
|
|
2012-12-30 03:04:25 +00:00
|
|
|
bool ApplyIPS(void*);
|
2012-06-03 15:48:14 +00:00
|
|
|
bool Close(void);
|
|
|
|
|
|
|
|
uint64 fread(void *ptr, size_t size, size_t nmemb);
|
|
|
|
int fseek(int64 offset, int whence);
|
|
|
|
|
|
|
|
inline uint64 ftell(void)
|
|
|
|
{
|
|
|
|
return(location);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void rewind(void)
|
|
|
|
{
|
|
|
|
location = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int read32le(uint32 *Bufo);
|
|
|
|
int read16le(uint16 *Bufo);
|
|
|
|
|
2016-03-01 21:29:35 +00:00
|
|
|
inline int _fgetc(void)
|
2012-06-03 15:48:14 +00:00
|
|
|
{
|
|
|
|
if(location < f_size)
|
|
|
|
return f_data[location++];
|
|
|
|
|
|
|
|
return EOF;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline int fisarchive(void)
|
|
|
|
{
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
char *fgets(char *s, int size);
|
2012-11-27 04:20:47 +00:00
|
|
|
uint8 *f_data;
|
|
|
|
int64 f_size;
|
|
|
|
char *f_ext;
|
2012-06-03 15:48:14 +00:00
|
|
|
|
2012-10-20 23:47:02 +00:00
|
|
|
private:
|
|
|
|
|
2012-06-03 15:48:14 +00:00
|
|
|
int64 location;
|
|
|
|
|
2012-11-16 15:33:10 +00:00
|
|
|
bool MakeMemWrapAndClose(void *tz);
|
2012-06-03 15:48:14 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|