[Scummvm-cvs-logs] CVS: scummvm/base gameDetector.cpp,1.90,1.91

Jonathan Gray khalek at users.sourceforge.net
Wed Dec 15 04:32:05 CET 2004


Update of /cvsroot/scummvm/scummvm/base
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9610/base

Modified Files:
	gameDetector.cpp 
Log Message:
- Move MAXPATHLEN includes/defines into common location
- Save files are now stored in $HOME/.scummvm/ by default if no other
  save path is specified on non MacOS X unices.


Index: gameDetector.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/base/gameDetector.cpp,v
retrieving revision 1.90
retrieving revision 1.91
diff -u -d -r1.90 -r1.91
--- gameDetector.cpp	2 Dec 2004 00:33:38 -0000	1.90
+++ gameDetector.cpp	15 Dec 2004 12:30:58 -0000	1.91
@@ -36,6 +36,14 @@
 #include "config.h"
 #endif
 
+#ifdef UNIX
+#include <sys/errno.h>
+#include <sys/stat.h>
+#ifndef MACOSX
+#define DEFAULT_SAVE_PATH ".scummvm"
+#endif
+#endif
+
 // DONT FIXME: DO NOT ORDER ALPHABETICALLY, THIS IS ORDERED BY IMPORTANCE/CATEGORY! :)
 #ifdef __PALM_OS__
 static const char USAGE_STRING[] = "NoUsageString"; // save more data segment space
@@ -99,6 +107,7 @@
 ;
 #endif
 
+
 GameDetector::GameDetector() {
 
 	// Graphics
@@ -152,6 +161,29 @@
 	ConfMan.registerDefault("alsa_port", "65:0");
 #endif
 
+#ifdef DEFAULT_SAVE_PATH 
+	char savePath[MAXPATHLEN];
+#ifdef UNIX
+	struct stat sb;
+	if (getenv("HOME") != NULL) {
+		snprintf(savePath, MAXPATHLEN, "%s/%s", getenv("HOME"), DEFAULT_SAVE_PATH);	
+		if (stat(savePath, &sb) == -1) {
+			/* create the dir if it does not exist */
+			if (errno == ENOENT) {
+				if (mkdir(savePath, 0755) != 0) {
+					perror("mkdir");
+					exit(1);
+				}
+			}
+		}
+		/* check that we can the dir is there */
+		if (stat(savePath, &sb) == 0) {
+			ConfMan.registerDefault("savepath", savePath);
+		}
+	}
+#endif
+#endif
+
 	_dumpScripts = false;
 
 	memset(&_game, 0, sizeof(_game));





More information about the Scummvm-git-logs mailing list