[Scummvm-cvs-logs] CVS: scummvm/backends/PalmOS/Src palmstart.cpp,1.10,1.11

Chris Apers chrilith at users.sourceforge.net
Tue Jul 15 03:32:15 CEST 2003


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

Modified Files:
	palmstart.cpp 
Log Message:
Check path before launching a game

Index: palmstart.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/PalmOS/Src/palmstart.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- palmstart.cpp	7 Jul 2003 08:49:27 -0000	1.10
+++ palmstart.cpp	15 Jul 2003 10:31:25 -0000	1.11
@@ -29,7 +29,8 @@
 #include "globals.h"
 #include "pa1lib.h"
 #include "scumm_globals.h"
-#include "extend.h"			// for disable state
+#include "extend.h"	// for disable state
+#include "stdio.h" // used in checkPath
 
 #include "mathlib.h"
 #include "vibrate.h"
@@ -2539,6 +2540,18 @@
 #define aOutSndKindHp       (2) /* HeadPhone volume */
 ////////////////////////////////////////////////////////////
 #define MAX_ARG	20
+
+static Boolean checkPath(const Char *pathP) {
+	FileRef *tmpRef;
+
+	if (!(tmpRef = fopen(pathP, "r"))) {
+		return false;
+	} else {
+		fclose(tmpRef);
+		return true;
+	}
+}
+
 static void StartScummVM() {
 	Char *argvP[MAX_ARG];
 	UInt8 argc	= 0;
@@ -2564,24 +2577,20 @@
 		recordH = DmQueryRecord(_dbP,index);
 		gameInfoP = (GameInfoType *)MemHandleLock(recordH);
 
-		// check path
+		// build path
 		StrCopy(pathP,"/Palm/Programs/ScummVM/Games/");
-		if (gameInfoP->pathP[0]=='/')
+		if (gameInfoP->pathP[0] == '/')
 			StrCopy(pathP,gameInfoP->pathP);
 		else
 			StrCat(pathP,gameInfoP->pathP);
-	/*	{
-			FileRef tmpRef;
-			// TODO : enable empty path -> /Palm/Programs/ScummVM/Games/ as default
-			if (VFSFileOpen(gPrefs->volRefNum, pathP, vfsModeRead, &tmpRef) != errNone) {
-				MemHandleUnlock(recordH);
-				FrmCustomAlert(FrmErrorAlert,"The specified path was not found !",0,0);
-				return;
-			} else {
-				VFSFileClose(tmpRef);
-			}
+		
+		// path exists ?
+		if (!checkPath(pathP)) {
+			MemHandleUnlock(recordH);
+			FrmCustomAlert(FrmErrorAlert,"The specified path was not found !",0,0);
+			return;
 		}
-	*/
+
 		AddArg(&argvP[argc], "ScummVM", NULL, &argc);
 
 		// save scummvm.ini ?





More information about the Scummvm-git-logs mailing list