[Scummvm-cvs-logs] SF.net SVN: scummvm: [24273] scummvm/trunk/backends/platform/gp32/ gp32std_file.cpp

wonst719 at users.sourceforge.net wonst719 at users.sourceforge.net
Wed Oct 11 15:53:35 CEST 2006


Revision: 24273
          http://svn.sourceforge.net/scummvm/?rev=24273&view=rev
Author:   wonst719
Date:     2006-10-11 06:53:30 -0700 (Wed, 11 Oct 2006)

Log Message:
-----------
Fix file caching

Modified Paths:
--------------
    scummvm/trunk/backends/platform/gp32/gp32std_file.cpp

Modified: scummvm/trunk/backends/platform/gp32/gp32std_file.cpp
===================================================================
--- scummvm/trunk/backends/platform/gp32/gp32std_file.cpp	2006-10-11 12:03:47 UTC (rev 24272)
+++ scummvm/trunk/backends/platform/gp32/gp32std_file.cpp	2006-10-11 13:53:30 UTC (rev 24273)
@@ -45,13 +45,11 @@
 
 
 // CACHE
-inline bool gp_cacheInPos(GPFILE *stream)
-{
+inline bool gp_cacheInPos(GPFILE *stream) {
 	return (stream->cachePos <= stream->filePos && stream->filePos < stream->cachePos + stream->bytesInCache);
 }
 
-int gp_cacheMiss(GPFILE *stream)
-{
+int gp_cacheMiss(GPFILE *stream) {
 	unsigned long readcount = 0;
 
 	int copyLen = stream->fileSize - stream->filePos;
@@ -70,6 +68,9 @@
 }
 
 int gp_flushWriteCache(GPFILE *stream) {
+	if (stream->bytesInCache == 0)
+		return 0;
+
 	ERR_CODE err = GpFileWrite(stream->handle, stream->cacheData, stream->bytesInCache); // flush cache
 
 	stream->filePos += stream->bytesInCache;
@@ -82,7 +83,6 @@
 ///////////////////////////////////////////////////////////////
 
 GPFILE *gp_fopen(const char *fileName, const char *openMode) {
-	//FIXME: allocation, mode
 	uint32 mode;
 	GPFILE *file;
 	ERR_CODE err;
@@ -184,8 +184,7 @@
 		err = GpFileSeek(stream->handle, whence, offset, (long *)&stream->physFilePos);
 		stream->filePos = stream->physFilePos;
 
-		if (gp_cacheInPos(stream)) {
-		} else { // cache miss
+		if (!gp_cacheInPos(stream)) { // cache miss
 			gp_cacheMiss(stream);
 		}
 	}
@@ -249,10 +248,7 @@
 		len -= copyLen;
 
 		if (stream->bytesInCache == FCACHE_SIZE) {
-			ERR_CODE err = GpFileWrite(stream->handle, stream->cacheData, stream->bytesInCache); // flush cache
-			stream->filePos += stream->bytesInCache;
-			stream->physFilePos += stream->bytesInCache;
-			stream->bytesInCache = 0;
+			gp_flushWriteCache(stream);
 		}
 	}
 #else


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