diff options
author | Marcus Comstedt | 2002-12-17 01:15:13 +0000 |
---|---|---|
committer | Marcus Comstedt | 2002-12-17 01:15:13 +0000 |
commit | 83da387eef75aa1140c81bd9e3e002ae3ea83864 (patch) | |
tree | a66d39aca4ef689a33df4d7ca374e4ad7ebdc817 /backends/gp32/gp32.cpp | |
parent | fadf55aad038286803cb2c1d0b5e75aca0ba3a02 (diff) | |
download | scummvm-rg350-83da387eef75aa1140c81bd9e3e002ae3ea83864.tar.gz scummvm-rg350-83da387eef75aa1140c81bd9e3e002ae3ea83864.tar.bz2 scummvm-rg350-83da387eef75aa1140c81bd9e3e002ae3ea83864.zip |
New savefile backend system (bye bye NONSTANDARD_SAVE...)
svn-id: r6007
Diffstat (limited to 'backends/gp32/gp32.cpp')
-rw-r--r-- | backends/gp32/gp32.cpp | 41 |
1 files changed, 31 insertions, 10 deletions
diff --git a/backends/gp32/gp32.cpp b/backends/gp32/gp32.cpp index 773b4e95ec..19a1aaec57 100644 --- a/backends/gp32/gp32.cpp +++ b/backends/gp32/gp32.cpp @@ -1221,26 +1221,47 @@ extern "C" int write(int fd, void *p, size_t n); int write(int fd, void *p, size_t n) { return 0; } //ph0x hack! // fixme - unnecessary? -int SerializerStream::fwrite(void *buf, int size, int cnt) { +class GP32SaveFile : public SaveFile { +private: + FILE *fh; +public: + GP32SaveFile(FILE *f) : fh(f) { } + + ~GP32SaveFile(); + + int fread(void *buf, int size, int cnt); + int fwrite(void *buf, int size, int cnt); +} + +class GP32SaveFileManager : public SaveFileManager { + SaveFile *open_savefile(const char *filename, bool saveOrLoad); +} + +int GP32SaveFile::fwrite(void *buf, int size, int cnt) { // implement me - return ::fwrite(buf, size, cnt, (FILE*)context); + return ::fwrite(buf, size, cnt, fh); } -bool SerializerStream::fopen(const char *filename, const char *mode) { +SaveFile GP32SaveFileManager::open_savefile(const char *filename, + bool saveOrLoad) { // implement me - (FILE*)context = ::fopen(filename, mode); - //if (tolower(mode[0])=='w') error("Autosaving.."); - return context != NULL; + FILE *fh = ::fopen(filename, (saveOrLoad? "wb":"rb")); + //if (saveOrLoad) error("Autosaving.."); + return fh? new GP32SaveFile(fh) : NULL; } -void SerializerStream::fclose() { +void GP32SaveFile::~GP32SaveFile() { // implement me - ::fclose((FILE*)context); + ::fclose(fh); } -int SerializerStream::fread(void *buf, int size, int cnt) { +int GP32SaveFile::fread(void *buf, int size, int cnt) { // implement me - return ::fread(buf, size, cnt, (FILE*)context); + return ::fread(buf, size, cnt, fh); + +} +SaveFileManager *OSystem_GP32::get_savefile_manager() { + return new GP32SaveFileManager(); } // Converts 8bit rgb values to a GP32 palette value |