[Scummvm-cvs-logs] SF.net SVN: scummvm:[33604] scummvm/trunk/common
fingolfin at users.sourceforge.net
fingolfin at users.sourceforge.net
Mon Aug 4 13:30:48 CEST 2008
Revision: 33604
http://scummvm.svn.sourceforge.net/scummvm/?rev=33604&view=rev
Author: fingolfin
Date: 2008-08-04 11:30:47 +0000 (Mon, 04 Aug 2008)
Log Message:
-----------
Moved the OutSaveFile::finalize method to WriteStream; implemented DumpFile::flush()
Modified Paths:
--------------
scummvm/trunk/common/file.cpp
scummvm/trunk/common/file.h
scummvm/trunk/common/savefile.h
scummvm/trunk/common/stream.h
Modified: scummvm/trunk/common/file.cpp
===================================================================
--- scummvm/trunk/common/file.cpp 2008-08-04 10:46:33 UTC (rev 33603)
+++ scummvm/trunk/common/file.cpp 2008-08-04 11:30:47 UTC (rev 33604)
@@ -553,5 +553,12 @@
return (uint32)fwrite(ptr, 1, len, (FILE *)_handle);
}
+void DumpFile::flush() {
+ assert(_handle);
+ // TODO: Should check the return value of fflush, and if it is non-zero,
+ // check errno and set an error flag.
+ fflush((FILE *)_handle);
+}
+
} // End of namespace Common
Modified: scummvm/trunk/common/file.h
===================================================================
--- scummvm/trunk/common/file.h 2008-08-04 10:46:33 UTC (rev 33603)
+++ scummvm/trunk/common/file.h 2008-08-04 11:30:47 UTC (rev 33604)
@@ -148,7 +148,9 @@
*/
virtual bool eof() const;
- uint32 write(const void *dataPtr, uint32 dataSize);
+ virtual uint32 write(const void *dataPtr, uint32 dataSize);
+
+ virtual void flush();
};
Modified: scummvm/trunk/common/savefile.h
===================================================================
--- scummvm/trunk/common/savefile.h 2008-08-04 10:46:33 UTC (rev 33603)
+++ scummvm/trunk/common/savefile.h 2008-08-04 11:30:47 UTC (rev 33604)
@@ -39,6 +39,7 @@
* That typically means "save games", but also includes things like the
* IQ points in Indy3.
*/
+//typedef SeekableReadStream InSaveFile;
class InSaveFile : public SeekableReadStream {};
/**
@@ -46,20 +47,8 @@
* That typically means "save games", but also includes things like the
* IQ points in Indy3.
*/
-class OutSaveFile : public WriteStream {
-public:
- /**
- * Close this savefile, to be called right before destruction of this
- * savefile. The idea is that this ways, I/O errors that occur
- * during closing/flushing of the file can still be handled by the
- * game engine.
- *
- * By default, this just flushes the stream.
- */
- virtual void finalize() {
- flush();
- }
-};
+//typedef WriteStream OutSaveFile;
+class OutSaveFile : public WriteStream {};
/**
Modified: scummvm/trunk/common/stream.h
===================================================================
--- scummvm/trunk/common/stream.h 2008-08-04 10:46:33 UTC (rev 33603)
+++ scummvm/trunk/common/stream.h 2008-08-04 11:30:47 UTC (rev 33604)
@@ -78,6 +78,22 @@
*/
virtual void flush() {}
+ /**
+ * Finalize and close this stream. To be called right before this
+ * stream instance is deleted. The goal here is to enable calling
+ * code to detect and handle I/O errors which might occur when
+ * closing (and this flushing, if buffered) the stream.
+ *
+ * After this method has been called, no further writes may be
+ * peformed on the stream. Calling ioFailed() is allowed.
+ *
+ * By default, this just flushes the stream.
+ */
+ virtual void finalize() {
+ flush();
+ }
+
+
// The remaining methods all have default implementations; subclasses
// need not (and should not) overload them.
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