diff options
author | Marcus Comstedt | 2003-08-10 20:49:13 +0000 |
---|---|---|
committer | Marcus Comstedt | 2003-08-10 20:49:13 +0000 |
commit | a5aa5c0d73fa3c9faec0ba167cb88d3595f089e5 (patch) | |
tree | 252958493844e9bf628dcaeb84a9e658557af648 /backends/PalmOS/Src | |
parent | 9d09512765bcca0a507361297aa70c8f122ce512 (diff) | |
download | scummvm-rg350-a5aa5c0d73fa3c9faec0ba167cb88d3595f089e5.tar.gz scummvm-rg350-a5aa5c0d73fa3c9faec0ba167cb88d3595f089e5.tar.bz2 scummvm-rg350-a5aa5c0d73fa3c9faec0ba167cb88d3595f089e5.zip |
Harmonized SaveFile API with File API a bit.
svn-id: r9626
Diffstat (limited to 'backends/PalmOS/Src')
-rw-r--r-- | backends/PalmOS/Src/palmsave.cpp | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/backends/PalmOS/Src/palmsave.cpp b/backends/PalmOS/Src/palmsave.cpp index b19e8494f4..224a5c12a7 100644 --- a/backends/PalmOS/Src/palmsave.cpp +++ b/backends/PalmOS/Src/palmsave.cpp @@ -36,10 +36,9 @@ public: ~PalmSaveFile(); bool is_open() { return file != NULL; } +protected: int fread(void *buf, int size, int cnt); - int fwrite(void *buf, int size, int cnt); -// must be removed - int feof() { return ::feof(file); } + int fwrite(const void *buf, int size, int cnt); private : FILE *file; @@ -71,7 +70,7 @@ int PalmSaveFile::fread(void *buf, int size, int cnt) { return ::fread(buf, size, cnt, file); } -int PalmSaveFile::fwrite(void *buf, int size, int cnt) { +int PalmSaveFile::fwrite(const void *buf, int size, int cnt) { UInt32 fullsize = size*cnt; if (fullsize <= MAX_BLOCK) @@ -104,8 +103,12 @@ public: void list_savefiles(const char *prefix, bool *marks, int num); }; -SaveFile *PalmSaveFileManager::open_savefile(const char *filename, bool saveOrLoad) { - PalmSaveFile *sf = new PalmSaveFile(filename, (saveOrLoad? "wb":"rb")); +SaveFile *PalmSaveFileManager::open_savefile(const char *filename, const char *dirname, bool saveOrLoad) { + char buf[256]; + + join_paths(filename, dirname, buf, sizeof(buf)); + + PalmSaveFile *sf = new PalmSaveFile(buf, (saveOrLoad? "wb":"rb")); if(!sf->is_open()) { delete sf; @@ -115,21 +118,20 @@ SaveFile *PalmSaveFileManager::open_savefile(const char *filename, bool saveOrLo return sf; } -void PalmSaveFileManager::list_savefiles(const char *prefix, bool *marks, int num) { +void PalmSaveFileManager::list_savefiles(const char *prefix, const char *direcory, bool *marks, int num) { FileRef fileRef; // try to open the dir - Err e = VFSFileOpen(gVars->volRefNum, SCUMMVM_SAVEPATH, vfsModeRead, &fileRef); + Err e = VFSFileOpen(gVars->volRefNum, directory, vfsModeRead, &fileRef); memset(marks, false, num*sizeof(bool)); if (e != errNone) return; // enumerate all files - Char *nameonly = strrchr(prefix,'/') + 1; UInt32 dirEntryIterator = vfsIteratorStart; Char filename[32]; FileInfoType info = {0, filename, 32}; - UInt16 length = StrLen(nameonly); + UInt16 length = StrLen(prefix); int slot = 0; while (dirEntryIterator != vfsIteratorStop) { @@ -138,7 +140,7 @@ void PalmSaveFileManager::list_savefiles(const char *prefix, bool *marks, int nu if (e != expErrEnumerationEmpty) { // there is something if (StrLen(info.nameP) == (length + 2)) { // consider max 99, filename length is ok - if (StrNCaselessCompare(nameonly, info.nameP, length) == 0) { // this seems to be a save file + if (StrNCaselessCompare(prefix, info.nameP, length) == 0) { // this seems to be a save file if (isdigit(info.nameP[length]) && isdigit(info.nameP[length+1])) { slot = StrAToI(filename + length); |