diff options
author | Yotam Barnoy | 2010-06-06 14:17:37 +0000 |
---|---|---|
committer | Yotam Barnoy | 2010-06-06 14:17:37 +0000 |
commit | 857f3ab550e015f9560bafa6bf080619216140fa (patch) | |
tree | c2d40c8693f1104a6a6af660b978413a7821e927 /backends/fs/psp | |
parent | 536e6a9bc308153f36d3eaf509bc0e66bcefc5e7 (diff) | |
download | scummvm-rg350-857f3ab550e015f9560bafa6bf080619216140fa.tar.gz scummvm-rg350-857f3ab550e015f9560bafa6bf080619216140fa.tar.bz2 scummvm-rg350-857f3ab550e015f9560bafa6bf080619216140fa.zip |
PSP: faster way of getting file size
svn-id: r49457
Diffstat (limited to 'backends/fs/psp')
-rw-r--r-- | backends/fs/psp/psp-stream.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/backends/fs/psp/psp-stream.cpp b/backends/fs/psp/psp-stream.cpp index 9bcbe9d7cf..83ff095aa8 100644 --- a/backends/fs/psp/psp-stream.cpp +++ b/backends/fs/psp/psp-stream.cpp @@ -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 @@ void *PSPIoStream::open() { _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); |