[Scummvm-cvs-logs] SF.net SVN: scummvm:[49457] scummvm/trunk/backends/fs/psp/psp-stream.cpp

Bluddy at users.sourceforge.net Bluddy at users.sourceforge.net
Sun Jun 6 16:17:37 CEST 2010


Revision: 49457
          http://scummvm.svn.sourceforge.net/scummvm/?rev=49457&view=rev
Author:   Bluddy
Date:     2010-06-06 14:17:37 +0000 (Sun, 06 Jun 2010)

Log Message:
-----------
PSP: faster way of getting file size

Modified Paths:
--------------
    scummvm/trunk/backends/fs/psp/psp-stream.cpp

Modified: scummvm/trunk/backends/fs/psp/psp-stream.cpp
===================================================================
--- scummvm/trunk/backends/fs/psp/psp-stream.cpp	2010-06-06 14:06:51 UTC (rev 49456)
+++ scummvm/trunk/backends/fs/psp/psp-stream.cpp	2010-06-06 14:17:37 UTC (rev 49457)
@@ -24,6 +24,8 @@
  */
 #ifdef __PSP__
 
+#include <pspiofilemgr_stat.h>
+#include <pspiofilemgr.h>
 #include <SDL/SDL_thread.h>
 #include <SDL/SDL_mutex.h>
 
@@ -106,10 +108,11 @@
 	_handle = fopen(_path.c_str(), _writeMode ? "wb" : "rb"); 	// open
 
 	if (_handle) {
-		// Get the file size
-		fseek((FILE *)_handle, 0, SEEK_END);	// go to the end
-		_fileSize = ftell((FILE *)_handle);
-		fseek((FILE *)_handle, 0, SEEK_SET);	// back to the beginning
+		// Get the file size. This way is much faster than going to the end of the file and back
+		SceIoStat stat;
+		sceIoGetstat(_path.c_str(), &stat);
+		_fileSize = *((uint32 *)(void *)&stat.st_size);	// 4GB file is big enough for us
+		PSP_DEBUG_PRINT("%s filesize = %d\n", _path.c_str(), _fileSize);
 	
 		// Allocate the cache
 		_cache = (char *)memalign(64, CACHE_SIZE);


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