diff options
author | Max Horn | 2008-08-04 11:48:33 +0000 |
---|---|---|
committer | Max Horn | 2008-08-04 11:48:33 +0000 |
commit | d061e50a7efc5d5201daff760341b10bc80f55bd (patch) | |
tree | 841d9dd964d3c42d5fdf1b9cf6ba0942d307e51d | |
parent | 73cbcd33e0b8ffc9a089aa7d8dbf9e5b2c25d6de (diff) | |
download | scummvm-rg350-d061e50a7efc5d5201daff760341b10bc80f55bd.tar.gz scummvm-rg350-d061e50a7efc5d5201daff760341b10bc80f55bd.tar.bz2 scummvm-rg350-d061e50a7efc5d5201daff760341b10bc80f55bd.zip |
DefaultSaveFileManager: Killed class StdioSaveFile, used FilesystemNode::openForReading()/openForWriting() instead (may cause regressions, watch out)
svn-id: r33608
-rw-r--r-- | backends/saves/default/default-saves.cpp | 65 |
1 files changed, 4 insertions, 61 deletions
diff --git a/backends/saves/default/default-saves.cpp b/backends/saves/default/default-saves.cpp index 3eb18da8bc..26dd55cec8 100644 --- a/backends/saves/default/default-saves.cpp +++ b/backends/saves/default/default-saves.cpp @@ -41,53 +41,6 @@ #include <sys/stat.h> #endif - -class StdioSaveFile : public Common::InSaveFile, public Common::OutSaveFile { -private: - FILE *fh; -public: - StdioSaveFile(const char *filename, bool saveOrLoad) { - fh = ::fopen(filename, (saveOrLoad? "wb" : "rb")); - } - ~StdioSaveFile() { - if (fh) - ::fclose(fh); - } - - bool eos() const { return feof(fh) != 0; } - bool ioFailed() const { return ferror(fh) != 0; } - void clearIOFailed() { clearerr(fh); } - - bool isOpen() const { return fh != 0; } - - uint32 read(void *dataPtr, uint32 dataSize) { - assert(fh); - return fread(dataPtr, 1, dataSize, fh); - } - uint32 write(const void *dataPtr, uint32 dataSize) { - assert(fh); - return fwrite(dataPtr, 1, dataSize, fh); - } - - uint32 pos() const { - assert(fh); - return ftell(fh); - } - uint32 size() const { - assert(fh); - uint32 oldPos = ftell(fh); - fseek(fh, 0, SEEK_END); - uint32 length = ftell(fh); - fseek(fh, oldPos, SEEK_SET); - return length; - } - - void seek(int32 offs, int whence = SEEK_SET) { - assert(fh); - fseek(fh, offs, whence); - } -}; - Common::StringList DefaultSaveFileManager::listSavefiles(const char *pattern) { FilesystemNode savePath(getSavePath()); FSList savefiles; @@ -183,13 +136,8 @@ Common::InSaveFile *DefaultSaveFileManager::openForLoading(const char *filename) FilesystemNode saveDir(getSavePath()); FilesystemNode file = saveDir.getChild(filename); - // TODO: switch to file.openForLoading() - StdioSaveFile *sf = new StdioSaveFile(file.getPath().c_str(), false); - - if (!sf->isOpen()) { - delete sf; - sf = 0; - } + // Open the file for reading + Common::SeekableReadStream *sf = file.openForReading(); return wrapInSaveFile(sf); } else { @@ -206,13 +154,8 @@ Common::OutSaveFile *DefaultSaveFileManager::openForSaving(const char *filename) FilesystemNode saveDir(getSavePath()); FilesystemNode file = saveDir.getChild(filename); - // TODO: switch to file.openForSaving() - StdioSaveFile *sf = new StdioSaveFile(file.getPath().c_str(), true); - - if (!sf->isOpen()) { - delete sf; - sf = 0; - } + // Open the file for saving + Common::WriteStream *sf = file.openForWriting(); return wrapOutSaveFile(sf); } else { |