[Scummvm-cvs-logs] SF.net SVN: scummvm: [24258] scummvm/trunk/backends/platform/gp2x/gp2x.cpp

djwillis at users.sourceforge.net djwillis at users.sourceforge.net
Mon Oct 9 22:48:36 CEST 2006


Revision: 24258
          http://svn.sourceforge.net/scummvm/?rev=24258&view=rev
Author:   djwillis
Date:     2006-10-09 13:48:30 -0700 (Mon, 09 Oct 2006)

Log Message:
-----------
Update GP2X backend with overloads for default config file stuff (including save location).

Modified Paths:
--------------
    scummvm/trunk/backends/platform/gp2x/gp2x.cpp

Modified: scummvm/trunk/backends/platform/gp2x/gp2x.cpp
===================================================================
--- scummvm/trunk/backends/platform/gp2x/gp2x.cpp	2006-10-09 20:38:59 UTC (rev 24257)
+++ scummvm/trunk/backends/platform/gp2x/gp2x.cpp	2006-10-09 20:48:30 UTC (rev 24258)
@@ -34,6 +34,13 @@
 #include "common/util.h"
 #include "base/main.h"
 
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <limits.h>
+#include <errno.h>
+#include <sys/stat.h>
+
 #if defined(HAVE_CONFIG_H)
 #include "config.h"
 #endif
@@ -78,6 +85,38 @@
 	// TODO: Clean way of flushing the file on every write without resorting to this or hacking the POSIX FS code.
 	//system("/bin/mount -t vfat -o remount,sync,iocharset=utf8 /dev/mmcsd/disc0/part1 /mnt/sd");
 
+	// Setup default save path to be workingdir/saves
+	#ifndef PATH_MAX
+		#define PATH_MAX 255
+	#endif
+
+	char savePath[PATH_MAX+1];
+	char workDirName[PATH_MAX+1]; /* To be passed to getcwd system call. */
+	if (getcwd(workDirName, PATH_MAX) == NULL) {
+		error("Could not obtain current working directory.");
+	} else {
+		printf("Current working directory: %s\n", workDirName);
+	}
+
+	strcpy(savePath, workDirName);
+	strcat(savePath, "/saves");
+	printf("Current save directory: %s\n", savePath);
+	struct stat sb;
+	if (stat(savePath, &sb) == -1)
+		if (errno == ENOENT) // Create the dir if it does not exist
+			if (mkdir(savePath, 0755) != 0)
+				warning("mkdir for '%s' failed!", savePath);
+
+	ConfMan.registerDefault("savepath", savePath);
+
+	// Setup other defaults.
+
+	ConfMan.registerDefault("aspect_ratio", true);
+	ConfMan.registerDefault("music_volume", 250); // Up default volume as we use a seperate volume system anyway.
+	ConfMan.registerDefault("sfx_volume", 250);
+	ConfMan.registerDefault("speech_volume", 250);
+	ConfMan.registerDefault("autosave_period", 3 * 60);	// Trigger autosave every 3 minutes - On low batts 4 mins is about your warning time.
+
 	_graphicsMutex = createMutex();
 
 	_cksumValid = false;


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list