[Scummvm-cvs-logs] CVS: scummvm/backends/PalmOS/Src palmsave.cpp,1.3,1.4

Marcus Comstedt marcus_c at users.sourceforge.net
Sun Aug 10 13:50:02 CEST 2003


Update of /cvsroot/scummvm/scummvm/backends/PalmOS/Src
In directory sc8-pr-cvs1:/tmp/cvs-serv7711/backends/PalmOS/Src

Modified Files:
	palmsave.cpp 
Log Message:
Harmonized SaveFile API with File API a bit.

Index: palmsave.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/PalmOS/Src/palmsave.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- palmsave.cpp	6 May 2003 08:19:51 -0000	1.3
+++ palmsave.cpp	10 Aug 2003 20:49:12 -0000	1.4
@@ -36,10 +36,9 @@
 	~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 @@
 	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 @@
 	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 @@
 	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 @@
 		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);





More information about the Scummvm-git-logs mailing list