aboutsummaryrefslogtreecommitdiff
path: root/backends/fs
diff options
context:
space:
mode:
authorJohannes Schickel2010-10-13 03:57:44 +0000
committerJohannes Schickel2010-10-13 03:57:44 +0000
commit75e8452b6e6a2bf4fb2f588aa00b428a60d873b5 (patch)
treef29541d55309487a94bd1d38e8b53bb3dde9aec6 /backends/fs
parent48ee83b88957dab86bc763e9ef21a70179fa8679 (diff)
parente9f50882ea5b6beeefa994040be9d3bab6a1f107 (diff)
downloadscummvm-rg350-75e8452b6e6a2bf4fb2f588aa00b428a60d873b5.tar.gz
scummvm-rg350-75e8452b6e6a2bf4fb2f588aa00b428a60d873b5.tar.bz2
scummvm-rg350-75e8452b6e6a2bf4fb2f588aa00b428a60d873b5.zip
OPENGL: Merged from trunk, from rev 52105 to 53396.
This includes an rather hacky attempt to merge all the recent gp2x backend changes into the branch. I suppose the gp2x backend and probably all new backends, i.e. gph, dingux etc., might not compile anymore. Since I have no way of testing those it would be nice if porters could look into getting those up to speed in this branch. svn-id: r53399
Diffstat (limited to 'backends/fs')
-rw-r--r--backends/fs/ds/ds-fs.cpp3
-rw-r--r--backends/fs/psp/psp-fs.cpp12
-rw-r--r--backends/fs/psp/psp-stream.cpp362
-rw-r--r--backends/fs/psp/psp-stream.h46
4 files changed, 166 insertions, 257 deletions
diff --git a/backends/fs/ds/ds-fs.cpp b/backends/fs/ds/ds-fs.cpp
index 675084ff56..cbc1c054fe 100644
--- a/backends/fs/ds/ds-fs.cpp
+++ b/backends/fs/ds/ds-fs.cpp
@@ -631,7 +631,10 @@ size_t std_fwrite(const void *ptr, size_t size, size_t numItems, FILE *handle) {
return 0;
if ((handle == stderr) || (handle == stdout)) {
+#ifndef DISABLE_TEXT_CONSOLE
+ nocashMessage((char *) ptr);
// consolePrintf((char *) ptr);
+#endif
return size;
}
diff --git a/backends/fs/psp/psp-fs.cpp b/backends/fs/psp/psp-fs.cpp
index d72c5108dd..5b3d298001 100644
--- a/backends/fs/psp/psp-fs.cpp
+++ b/backends/fs/psp/psp-fs.cpp
@@ -247,11 +247,19 @@ AbstractFSNode *PSPFilesystemNode::getParent() const {
}
Common::SeekableReadStream *PSPFilesystemNode::createReadStream() {
- return PSPIoStream::makeFromPath(getPath(), false);
+ const uint32 READ_BUFFER_SIZE = 1024;
+
+ Common::SeekableReadStream *stream = PspIoStream::makeFromPath(getPath(), false);
+
+ return new Common::BufferedSeekableReadStream(stream, READ_BUFFER_SIZE, DisposeAfterUse::YES);
}
Common::WriteStream *PSPFilesystemNode::createWriteStream() {
- return PSPIoStream::makeFromPath(getPath(), true);
+ const uint32 WRITE_BUFFER_SIZE = 1024;
+
+ Common::WriteStream *stream = PspIoStream::makeFromPath(getPath(), true);
+
+ return new Common::BufferedWriteStream(stream, WRITE_BUFFER_SIZE, DisposeAfterUse::YES);
}
#endif //#ifdef __PSP__
diff --git a/backends/fs/psp/psp-stream.cpp b/backends/fs/psp/psp-stream.cpp
index 67c73beeaa..10b80a0639 100644
--- a/backends/fs/psp/psp-stream.cpp
+++ b/backends/fs/psp/psp-stream.cpp
@@ -24,16 +24,11 @@
*/
#ifdef __PSP__
-#include <pspiofilemgr_stat.h>
#include <pspiofilemgr.h>
-#include <SDL/SDL_thread.h>
-#include <SDL/SDL_mutex.h>
#include "backends/platform/psp/powerman.h"
#include "backends/fs/psp/psp-stream.h"
-#include <errno.h>
-
#define MIN2(a,b) ((a < b) ? a : b)
#define MIN3(a,b,c) ( (a < b) ? (a < c ? a : c) : (b < c ? b : c) )
@@ -48,49 +43,41 @@
#ifdef DEBUG_BUFFERS
void printBuffer(byte *ptr, uint32 len) {
uint32 printLen = len <= 10 ? len : 10;
-
+
for (int i = 0; i < printLen; i++) {
- PSP_INFO_PRINT("%x ", ptr[i]);
+ PSP_INFO_PRINT("%x ", ptr[i]);
}
-
+
if (len > 10) {
PSP_INFO_PRINT("... ");
for (int i = len - 10; i < len; i++)
PSP_INFO_PRINT("%x ", ptr[i]);
}
-
+
PSP_INFO_PRINT("\n");
}
#endif
+// Class PspIoStream ------------------------------------------------
-PSPIoStream::PSPIoStream(const Common::String &path, bool writeMode)
- : StdioStream((void *)1), _path(path), _writeMode(writeMode),
- _ferror(false), _pos(0),
- _physicalPos(0), _fileSize(0), _inCache(false), _eos(false),
- _cacheStartOffset(-1), _cache(0),
- _errorSuspend(0), _errorSource(0),
- _errorPos(0), _errorHandle(0), _suspendCount(0) {
+PspIoStream::PspIoStream(const Common::String &path, bool writeMode)
+ : _handle(0), _path(path), _fileSize(0), _writeMode(writeMode),
+ _physicalPos(0), _pos(0), _eos(false), _error(false),
+ _errorSuspend(0), _errorSource(0), _errorPos(0), _errorHandle(0), _suspendCount(0) {
DEBUG_ENTER_FUNC();
- // assert(!path.empty()); // do we need this?
-
- _handle = (void *)0; // Need to do this since base class asserts not 0.
+ //assert(!path.empty()); // do we need this?
}
-PSPIoStream::~PSPIoStream() {
+PspIoStream::~PspIoStream() {
DEBUG_ENTER_FUNC();
if (PowerMan.beginCriticalSection())
- PSP_DEBUG_PRINT_FUNC("Suspended\n");
-
- PowerMan.unregisterForSuspend(this); // Unregister with powermanager to be suspended
- // Must do this before fclose() or resume() will reopen.
+ PSP_DEBUG_PRINT_FUNC("suspended\n");
- fclose((FILE *)_handle); // We don't need a critical section. Worst case, the handle gets closed on its own
-
- if (_cache)
- free(_cache);
+ PowerMan.unregisterForSuspend(this); // Unregister with powermanager to be suspended
+ // Must do this before fclose() or resume() will reopen.
+ sceIoClose(_handle);
PowerMan.endCriticalSection();
}
@@ -98,277 +85,195 @@ PSPIoStream::~PSPIoStream() {
/* Function to open the file pointed to by the path.
*
*/
-void *PSPIoStream::open() {
+void *PspIoStream::open() {
DEBUG_ENTER_FUNC();
+
if (PowerMan.beginCriticalSection()) {
- // No need to open. Just return the _handle resume() already opened.
- PSP_DEBUG_PRINT_FUNC("Suspended\n");
+ // No need to open? Just return the _handle resume() already opened
+ PSP_DEBUG_PRINT_FUNC("suspended\n");
}
- _handle = fopen(_path.c_str(), _writeMode ? "wb" : "rb"); // open
-
- if (_handle) {
- // 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);
+ _handle = sceIoOpen(_path.c_str(), _writeMode ? PSP_O_WRONLY | PSP_O_CREAT | PSP_O_TRUNC : PSP_O_RDONLY, 0777);
+ if (!_handle) {
+ _error = true;
+ _handle = NULL;
}
+ // 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 (32 bits) is big enough for us
+
+ PSP_DEBUG_PRINT("%s filesize[%d]\n", _path.c_str(), _fileSize);
+
PowerMan.registerForSuspend(this); // Register with the powermanager to be suspended
PowerMan.endCriticalSection();
- return _handle;
+ return (void *)_handle;
}
-bool PSPIoStream::err() const {
+bool PspIoStream::err() const {
DEBUG_ENTER_FUNC();
-
- if (_ferror) // We dump since no printing to screen with suspend
- PSP_ERROR("mem_ferror[%d], source[%d], suspend error[%d], pos[%d], \
- _errorPos[%d], _errorHandle[%p], suspendCount[%d]\n",
- _ferror, _errorSource, _errorSuspend, _pos,
+
+ if (_error) // We dump since no printing to screen with suspend callback
+ PSP_ERROR("mem_error[%d], source[%d], suspend error[%d], pos[%d],"
+ "_errorPos[%d], _errorHandle[%p], suspendCount[%d]\n",
+ _error, _errorSource, _errorSuspend, _pos,
_errorPos, _errorHandle, _suspendCount);
- return _ferror;
+ return _error;
}
-void PSPIoStream::clearErr() {
- _ferror = false;
+void PspIoStream::clearErr() {
+ _error = false;
}
-bool PSPIoStream::eos() const {
+bool PspIoStream::eos() const {
return _eos;
}
-int32 PSPIoStream::pos() const {
+int32 PspIoStream::pos() const {
return _pos;
}
-int32 PSPIoStream::size() const {
+int32 PspIoStream::size() const {
return _fileSize;
}
-bool PSPIoStream::seek(int32 offs, int whence) {
+bool PspIoStream::physicalSeekFromCur(int32 offset) {
+
+ int ret = sceIoLseek32(_handle, offset, PSP_SEEK_CUR);
+
+ if (ret < 0) {
+ _error = true;
+ PSP_ERROR("failed to seek in file[%s] to [%x]. Error[%x]\n", _path.c_str(), offset, ret);
+ return false;
+ }
+ _physicalPos += offset;
+ return true;
+}
+
+bool PspIoStream::seek(int32 offs, int whence) {
DEBUG_ENTER_FUNC();
PSP_DEBUG_PRINT_FUNC("offset[0x%x], whence[%d], _pos[0x%x], _physPos[0x%x]\n", offs, whence, _pos, _physicalPos);
_eos = false;
-
+
int32 posToSearchFor = 0;
switch (whence) {
case SEEK_CUR:
posToSearchFor = _pos;
break;
case SEEK_END:
- posToSearchFor = _fileSize; // unsure. Does it take us here or to EOS - 1?
+ posToSearchFor = _fileSize;
break;
}
posToSearchFor += offs;
-
+
// Check for bad values
if (posToSearchFor < 0) {
- _ferror = true;
+ _error = true;
return false;
- }
-
- if (posToSearchFor > _fileSize) {
- _ferror = true;
+ } else if (posToSearchFor > _fileSize) {
+ _error = true;
_eos = true;
return false;
}
-
- // See if we can find it in cache
- if (isOffsetInCache(posToSearchFor)) {
- PSP_DEBUG_PRINT("seek offset[0x%x] found in cache. Cache starts[0x%x]\n", posToSearchFor, _cacheStartOffset);
- _inCache = true;
- } else { // not in cache
- _inCache = false;
- }
- _pos = posToSearchFor;
+
+ _pos = posToSearchFor;
+
return true;
}
-uint32 PSPIoStream::read(void *ptr, uint32 len) {
+uint32 PspIoStream::read(void *ptr, uint32 len) {
DEBUG_ENTER_FUNC();
- PSP_DEBUG_PRINT_FUNC("filename[%s], len[0x%x], ptr[%p]\n", _path.c_str(), len, ptr);
+ PSP_DEBUG_PRINT_FUNC("filename[%s], len[0x%x], ptr[%p], _pos[%x], _physPos[%x]\n", _path.c_str(), len, ptr, _pos, _physicalPos);
- if (_ferror || _eos)
+ if (_error || _eos || len <= 0)
return 0;
-
- byte *destPtr = (byte *)ptr;
- uint32 lenFromFile = len; // how much we read from the actual file
- uint32 lenFromCache = 0; // how much we read from cache
+
uint32 lenRemainingInFile = _fileSize - _pos;
-
- if (lenFromFile > lenRemainingInFile) {
- lenFromFile = lenRemainingInFile;
+
+ // check for getting EOS
+ if (len > lenRemainingInFile) {
+ len = lenRemainingInFile;
_eos = true;
- }
-
- // Are we in cache?
- if (_inCache && isCacheValid()) {
- uint32 offsetInCache = _pos - _cacheStartOffset;
- // We can read at most what's in the cache or the remaining size of the file
- lenFromCache = MIN2(lenFromFile, CACHE_SIZE - offsetInCache); // unsure
-
- PSP_DEBUG_PRINT("reading 0x%x bytes from cache to %p. pos[0x%x] physPos[0x%x] cacheStart[0x%x]\n", lenFromCache, destPtr, _pos, _physicalPos, _cacheStartOffset);
-
- memcpy(destPtr, &_cache[offsetInCache], lenFromCache);
- _pos += lenFromCache;
-
- if (lenFromCache < lenFromFile) { // there's more to copy from the file
- lenFromFile -= lenFromCache;
- lenRemainingInFile -= lenFromCache; // since we moved pos
- destPtr += lenFromCache;
- } else { // we're done
-#ifdef DEBUG_BUFFERS
- printBuffer((byte *)ptr, len);
-#endif
-
- return lenFromCache; // how much we actually read
- }
}
if (PowerMan.beginCriticalSection())
- PSP_DEBUG_PRINT_FUNC("Suspended\n");
-
-
- synchronizePhysicalPos(); // we need to update our physical position
-
- if (lenFromFile <= MIN_READ_SIZE) { // We load the cache in case the read is small enough
- // This optimization is based on the principle that reading 1 byte is as expensive as 1000 bytes
- uint32 lenToCopyToCache = MIN2((uint32)MIN_READ_SIZE, lenRemainingInFile); // at most remaining file size
-
- PSP_DEBUG_PRINT("filling cache with 0x%x bytes from physicalPos[0x%x]. cacheStart[0x%x], pos[0x%x], fileSize[0x%x]\n", lenToCopyToCache, _physicalPos, _cacheStartOffset, _pos, _fileSize);
-
- size_t ret = fread(_cache, 1, lenToCopyToCache, (FILE *)_handle);
- if (ret != lenToCopyToCache) {
- PSP_ERROR("in filling cache, failed to get 0x%x bytes. Only got 0x%x\n", lenToCopyToCache, ret);
- _ferror = true;
- clearerr((FILE *)_handle);
- }
- _cacheStartOffset = _physicalPos;
- _inCache = true;
-
- _physicalPos += ret;
-
- PSP_DEBUG_PRINT("copying 0x%x bytes from cache to %p\n", lenFromFile, destPtr);
-
- // Copy to the destination buffer from cache
- memcpy(destPtr, _cache, lenFromFile);
- _pos += lenFromFile;
-
- } else { // Too big for cache. No caching
- PSP_DEBUG_PRINT("reading 0x%x bytes from file to %p. Pos[0x%x], physPos[0x%x]\n", lenFromFile, destPtr, _pos, _physicalPos);
- size_t ret = fread(destPtr, 1, lenFromFile, (FILE *)_handle);
-
- _physicalPos += ret; // Update pos
- _pos = _physicalPos;
-
- if (ret != lenFromFile) { // error
- PSP_ERROR("fread returned [0x%x] instead of len[0x%x]\n", ret, lenFromFile);
- _ferror = true;
- clearerr((FILE *)_handle);
- _errorSource = 4;
+ PSP_DEBUG_PRINT_FUNC("suspended\n");
+
+ // check if we need to seek
+ if (_pos != _physicalPos)
+ PSP_DEBUG_PRINT("seeking from %x to %x\n", _physicalPos, _pos);
+ if (!physicalSeekFromCur(_pos - _physicalPos)) {
+ _error = true;
+ return 0;
}
- _inCache = false;
- }
+
+ int ret = sceIoRead(_handle, ptr, len);
PowerMan.endCriticalSection();
-#ifdef DEBUG_BUFFERS
- printBuffer((byte *)ptr, len);
-#endif
-
- return lenFromCache + lenFromFile; // total of what was copied
-}
+ _physicalPos += ret; // Update position
+ _pos = _physicalPos;
-// TODO: Test if seeking backwards/forwards has any effect on performance
-inline bool PSPIoStream::synchronizePhysicalPos() {
- if (_pos != _physicalPos) {
- if (fseek((FILE *)_handle, _pos - _physicalPos, SEEK_CUR) != 0)
- return false;
- _physicalPos = _pos;
+ if (ret != (int)len) { // error
+ PSP_ERROR("sceIoRead returned [0x%x] instead of len[0x%x]\n", ret, len);
+ _error = true;
+ _errorSource = 4;
}
-
- return true;
-}
-
-inline bool PSPIoStream::isOffsetInCache(uint32 offset) {
- if (_cacheStartOffset != -1 &&
- offset >= (uint32)_cacheStartOffset &&
- offset < (uint32)(_cacheStartOffset + CACHE_SIZE))
- return true;
- return false;
+ return ret;
}
-uint32 PSPIoStream::write(const void *ptr, uint32 len) {
+uint32 PspIoStream::write(const void *ptr, uint32 len) {
DEBUG_ENTER_FUNC();
- // Check if we can access the file
- if (PowerMan.beginCriticalSection())
- PSP_DEBUG_PRINT_FUNC("Suspended\n");
-
- PSP_DEBUG_PRINT_FUNC("filename[%s], len[0x%x]\n", _path.c_str(), len);
+ PSP_DEBUG_PRINT_FUNC("filename[%s], len[0x%x], ptr[%p], _pos[%x], _physPos[%x]\n", _path.c_str(), len, ptr, _pos, _physicalPos);
- if (_ferror)
+ if (!len || _error) // we actually get some calls with len == 0!
return 0;
-
- _eos = false; // we can't have eos with write
- synchronizePhysicalPos();
-
- size_t ret = fwrite(ptr, 1, len, (FILE *)_handle);
-
- // If we're making the file bigger, adjust the size
- if (_physicalPos + (int)ret > _fileSize)
- _fileSize = _physicalPos + ret;
- _physicalPos += ret;
- _pos = _physicalPos;
- _inCache = false;
- _cacheStartOffset = -1; // invalidate cache
- if (ret != len) { // Set error
- _ferror = true;
- clearerr((FILE *)_handle);
- _pos = ftell((FILE *)_handle); // Update pos
- _errorSource = 5;
- PSP_ERROR("fwrite returned[0x%x] instead of len[0x%x]\n", ret, len);
- }
+ _eos = false; // we can't have eos with write
- PowerMan.endCriticalSection();
+ if (PowerMan.beginCriticalSection())
+ PSP_DEBUG_PRINT_FUNC("suspended\n");
- return ret;
-}
+ // check if we need to seek
+ if (_pos != _physicalPos)
+ if (!physicalSeekFromCur(_pos - _physicalPos)) {
+ _error = true;
+ return 0;
+ }
-bool PSPIoStream::flush() {
- DEBUG_ENTER_FUNC();
- // Enter critical section
- if (PowerMan.beginCriticalSection())
- PSP_DEBUG_PRINT_FUNC("Suspended\n");
+ int ret = sceIoWrite(_handle, ptr, len);
- int ret = fflush((FILE *)_handle);
+ PowerMan.endCriticalSection();
- if (ret != 0) {
- _ferror = true;
- clearerr((FILE *)_handle);
- _errorSource = 6;
- PSP_ERROR("fflush returned ret[%d]\n", ret);
+ if (ret != (int)len) {
+ _error = true;
+ _errorSource = 5;
+ PSP_ERROR("sceIoWrite returned[0x%x] instead of len[0x%x]\n", ret, len);
}
- PowerMan.endCriticalSection();
+ _physicalPos += ret;
+ _pos = _physicalPos;
+
+ if (_pos > _fileSize)
+ _fileSize = _pos;
- return (ret == 0);
+ return ret;
+}
+
+bool PspIoStream::flush() {
+ return true;
}
// For the PSP, since we're building in suspend support, we moved opening
-// the actual file to an open function since we need an actual PSPIoStream object to suspend.
+// the actual file to an open function since we need an actual PspIoStream object to suspend.
//
-PSPIoStream *PSPIoStream::makeFromPath(const Common::String &path, bool writeMode) {
+PspIoStream *PspIoStream::makeFromPath(const Common::String &path, bool writeMode) {
DEBUG_ENTER_FUNC();
- PSPIoStream *stream = new PSPIoStream(path, writeMode);
+ PspIoStream *stream = new PspIoStream(path, writeMode);
if (stream->open() <= 0) {
delete stream;
@@ -382,7 +287,7 @@ PSPIoStream *PSPIoStream::makeFromPath(const Common::String &path, bool writeMod
* Function to suspend the IO stream (called by PowerManager)
* we can have no output here
*/
-int PSPIoStream::suspend() {
+int PspIoStream::suspend() {
DEBUG_ENTER_FUNC();
_suspendCount++;
@@ -393,8 +298,8 @@ int PSPIoStream::suspend() {
}
if (_handle > 0) {
- fclose((FILE *)_handle); // close our file descriptor
- _handle = (void *)0xFFFFFFFF; // Set handle to non-null invalid value so makeFromPath doesn't return error
+ sceIoClose(_handle); // close our file descriptor
+ _handle = 0xFFFFFFFF; // Set handle to non-null invalid value so makeFromPath doesn't return error
}
return 0;
@@ -403,25 +308,25 @@ int PSPIoStream::suspend() {
/*
* Function to resume the IO stream (called by Power Manager)
*/
-int PSPIoStream::resume() {
+int PspIoStream::resume() {
DEBUG_ENTER_FUNC();
int ret = 0;
_suspendCount--;
// We reopen our file descriptor
- _handle = fopen(_path.c_str(), _writeMode ? "wb" : "rb");
+ _handle = sceIoOpen(_path.c_str(), _writeMode ? PSP_O_RDWR | PSP_O_CREAT : PSP_O_RDONLY, 0777); // open
if (_handle <= 0) {
- PSP_ERROR("Couldn't reopen file %s\n", _path.c_str());
+ _errorSuspend = ResumeError;
+ _errorPos = _pos;
}
- // Resume our previous position
+ // Resume our previous position if needed
if (_handle > 0 && _pos > 0) {
- ret = fseek((FILE *)_handle, _pos, SEEK_SET);
-
+ ret = sceIoLseek32(_handle, _pos, PSP_SEEK_SET);
+
_physicalPos = _pos;
- _inCache = false;
- if (ret != 0) { // Check for problem
+ if (ret < 0) { // Check for problem
_errorSuspend = ResumeError;
_errorPos = _pos;
_errorHandle = _handle;
@@ -430,5 +335,4 @@ int PSPIoStream::resume() {
return ret;
}
-
#endif /* __PSP__ */
diff --git a/backends/fs/psp/psp-stream.h b/backends/fs/psp/psp-stream.h
index 9fd1ad0470..d4497aa79f 100644
--- a/backends/fs/psp/psp-stream.h
+++ b/backends/fs/psp/psp-stream.h
@@ -26,58 +26,51 @@
#ifndef PSPSTREAM_H_
#define PSPSTREAM_H_
-#include "backends/fs/stdiostream.h"
+#include <pspkerneltypes.h>
#include "backends/platform/psp/powerman.h"
-#include "common/list.h"
+//#include "common/list.h"
+#include "common/noncopyable.h"
+#include "common/stream.h"
+#include "common/str.h"
-/*
+/**
* Class to handle special suspend/resume needs of PSP IO Streams
*/
-class PSPIoStream : public StdioStream, public Suspendable {
+class PspIoStream : public Common::SeekableReadStream, public Common::WriteStream, public Common::NonCopyable, public Suspendable {
protected:
+ SceUID _handle; // file handle
Common::String _path;
int _fileSize;
bool _writeMode; // for resuming in the right mode
- int _physicalPos; // position in the real file
+ int _physicalPos; // physical position in file
int _pos; // position. Sometimes virtual
- bool _inCache; // whether we're in cache (virtual) mode
bool _eos; // EOS flag
-
+
enum {
SuspendError = 2,
ResumeError = 3
};
- enum {
- CACHE_SIZE = 1024,
- MIN_READ_SIZE = 1024 // reading less than 1024 takes exactly the same time as 1024
- };
-
- // For caching
- char *_cache;
- int _cacheStartOffset; // starting offset of the cache. -1 when cache is invalid
-
- mutable int _ferror; // file error state
+ // debug stuff
+ mutable int _error; // file error state
int _errorSuspend; // for debugging
mutable int _errorSource;
int _errorPos;
- void * _errorHandle;
+ SceUID _errorHandle;
int _suspendCount;
- bool synchronizePhysicalPos(); // synchronize the physical and virtual positions
- bool isOffsetInCache(uint32 pos); // check if an offset is found in cache
- bool isCacheValid() { return _cacheStartOffset != -1; }
-
+ bool physicalSeekFromCur(int32 offset);
+
public:
/**
* Given a path, invoke fopen on that path and wrap the result in a
- * PSPIoStream instance.
+ * PspIoStream instance.
*/
- static PSPIoStream *makeFromPath(const Common::String &path, bool writeMode);
+ static PspIoStream *makeFromPath(const Common::String &path, bool writeMode);
- PSPIoStream(const Common::String &path, bool writeMode);
- virtual ~PSPIoStream();
+ PspIoStream(const Common::String &path, bool writeMode);
+ virtual ~PspIoStream();
void * open(); // open the file pointed to by the file path
@@ -93,6 +86,7 @@ public:
virtual bool seek(int32 offs, int whence = SEEK_SET);
virtual uint32 read(void *dataPtr, uint32 dataSize);
+ // for suspending
int suspend(); /* Suspendable interface (power manager) */
int resume(); /* " " */
};