#ifndef __MDFN_FILEWRAPPER_H1#define __MDFN_FILEWRAPPER_H23// A stdio FILE wrapper(with some BSD and POSIXisms, and a little dash of Win32, thrown in for special behaviors)4class FileWrapper5{6public:78enum9{10MODE_READ = 0,11MODE_WRITE,12MODE_WRITE_SAFE // Will throw an exception instead of overwriting an existing file.13};1415FileWrapper(const char *path, const int mode, const char *purpose = NULL);16~FileWrapper();1718uint64 read(void *data, uint64 count, bool error_on_eof = true);1920void write(const void *data, uint64 count);2122int scanf(const char *format, ...) MDFN_FORMATSTR(scanf, 2, 3);2324void put_char(int c);2526void put_string(const char *str);27void put_string(const std::string &str);2829char *get_line(char *s, int size); // Same semantics as fgets(), for now3031void seek(int64 offset, int whence);3233int64 tell(void);3435int64 size(void);3637void flush(void);3839void close(void); // Flushes and closes the underlying OS/C lib file. Calling any other method of this class after a call to40// this method is illegal(except for the implicit call to the destructor).41//42// This is necessary since there can be errors when closing a file, and we can't safely throw an43// exception from the destructor.44//45// Manually calling this method isn't strictly necessary, it'll be called from the destructor46// automatically, but calling is strongly recommended when the file is opened for writing.47private:4849FileWrapper & operator=(const FileWrapper &); // Assignment operator50FileWrapper(const FileWrapper &); // Copy constructor5152FILE *fp;53const int OpenedMode;54};5556#endif575859