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 /common | |
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 'common')
-rw-r--r-- | common/savefile.h | 90 | ||||
-rw-r--r-- | common/scummsys.h | 1 | ||||
-rw-r--r-- | common/system.h | 7 |
3 files changed, 97 insertions, 1 deletions
diff --git a/common/savefile.h b/common/savefile.h new file mode 100644 index 0000000000..952b07e44f --- /dev/null +++ b/common/savefile.h @@ -0,0 +1,90 @@ +/* ScummVM - Scumm Interpreter + * Copyright (C) 2001 Ludvig Strigeus + * Copyright (C) 2001/2002 The ScummVM project + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Header$ + * + */ + +#ifndef COMMON_SAVEFILE_H +#define COMMON_SAVEFILE_H + +#include <stdio.h> + +class SaveFile { +public: + virtual ~SaveFile() {} + virtual int fread(void *buf, int size, int cnt) = 0; + virtual int fwrite(void *buf, int size, int cnt) = 0; +#ifdef _WIN32_WCE + //Should go away. See scumm/saveload.cpp and scumm/imuse.cpp + virtual int fseek(long offs, int whence) = 0; + virtual int feof() = 0; +#endif +}; + +class StdioSaveFile : public SaveFile { +private: + FILE *fh; +public: + StdioSaveFile(const char *filename, const char *mode) + { fh = ::fopen(filename, mode); } + ~StdioSaveFile() + { if(fh) ::fclose(fh); } + + + bool is_open() { return fh != NULL; } + + + int fread(void *buf, int size, int cnt) + { return ::fread(buf, size, cnt, fh); } + int fwrite(void *buf, int size, int cnt) + { return ::fwrite(buf, size, cnt, fh); } +#ifdef _WIN32_WCE + int fseek(long offs, int whence) + { return ::fseek(fh, offs, whence); } + int feof() + { return ::feof(fh); } +#endif +}; + +class SaveFileManager { + +public: + virtual ~SaveFileManager() {} + + virtual SaveFile *open_savefile(const char *filename, + bool saveOrLoad) + { + StdioSaveFile *sf = new StdioSaveFile(filename, + (saveOrLoad? "wb":"rb")); + if(!sf->is_open()) { + delete sf; + sf = NULL; + } + return sf; + } + + virtual void list_savefiles(const char *prefix, + bool *marks, int num) + { + memset(marks, true, num*sizeof(bool)); + } + +}; + +#endif diff --git a/common/scummsys.h b/common/scummsys.h index 8b0e7fea29..1c63b4f838 100644 --- a/common/scummsys.h +++ b/common/scummsys.h @@ -240,7 +240,6 @@ #define CDECL #define SCUMM_NEED_ALIGNMENT #define SCUMM_LITTLE_ENDIAN - #define NONSTANDARD_SAVE #define scumm_stricmp stricmp #define CHECK_HEAP diff --git a/common/system.h b/common/system.h index 13a1fab3fd..296fb072c8 100644 --- a/common/system.h +++ b/common/system.h @@ -24,6 +24,7 @@ #define COMMON_SYSTEM_H #include "scummsys.h" +#include "savefile.h" class Timer; @@ -180,6 +181,12 @@ public: g = (((color>>5)&0x3F) << 2); b = ((color&0x1F) << 3); } + + // Savefile management + virtual SaveFileManager *get_savefile_manager() + { + return new SaveFileManager(); + } }; |