[Scummvm-cvs-logs] SF.net SVN: scummvm:[33608] scummvm/trunk/backends/saves/default/ default-saves.cpp

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Mon Aug 4 13:48:34 CEST 2008


Revision: 33608
          http://scummvm.svn.sourceforge.net/scummvm/?rev=33608&view=rev
Author:   fingolfin
Date:     2008-08-04 11:48:33 +0000 (Mon, 04 Aug 2008)

Log Message:
-----------
DefaultSaveFileManager: Killed class StdioSaveFile, used FilesystemNode::openForReading()/openForWriting() instead (may cause regressions, watch out)

Modified Paths:
--------------
    scummvm/trunk/backends/saves/default/default-saves.cpp

Modified: scummvm/trunk/backends/saves/default/default-saves.cpp
===================================================================
--- scummvm/trunk/backends/saves/default/default-saves.cpp	2008-08-04 11:46:52 UTC (rev 33607)
+++ scummvm/trunk/backends/saves/default/default-saves.cpp	2008-08-04 11:48:33 UTC (rev 33608)
@@ -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,14 +136,9 @@
 		FilesystemNode saveDir(getSavePath());
 		FilesystemNode file = saveDir.getChild(filename);
 
-		// TODO: switch to file.openForLoading()
-		StdioSaveFile *sf = new StdioSaveFile(file.getPath().c_str(), false);
+		// Open the file for reading
+		Common::SeekableReadStream *sf = file.openForReading();
 
-		if (!sf->isOpen()) {
-			delete sf;
-			sf = 0;
-		}
-
 		return wrapInSaveFile(sf);
 	} else {
 		return 0;
@@ -206,14 +154,9 @@
 		FilesystemNode saveDir(getSavePath());
 		FilesystemNode file = saveDir.getChild(filename);
 
-		// TODO: switch to file.openForSaving()
-		StdioSaveFile *sf = new StdioSaveFile(file.getPath().c_str(), true);
+		// Open the file for saving
+		Common::WriteStream *sf = file.openForWriting();
 
-		if (!sf->isOpen()) {
-			delete sf;
-			sf = 0;
-		}
-
 		return wrapOutSaveFile(sf);
 	} else {
 		return 0;


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list