[Scummvm-cvs-logs] SF.net SVN: scummvm: [30918] scummvm/branches/branch-0-11-0
vinterstum at users.sourceforge.net
vinterstum at users.sourceforge.net
Fri Feb 22 21:11:51 CET 2008
Revision: 30918
http://scummvm.svn.sourceforge.net/scummvm/?rev=30918&view=rev
Author: vinterstum
Date: 2008-02-22 12:11:51 -0800 (Fri, 22 Feb 2008)
Log Message:
-----------
Backport of trunk rev 30761: Migration code for iPhone firmware 1.1.3
Revision Links:
--------------
http://scummvm.svn.sourceforge.net/scummvm/?rev=30761&view=rev
Modified Paths:
--------------
scummvm/branches/branch-0-11-0/backends/platform/iphone/osys_iphone.cpp
scummvm/branches/branch-0-11-0/backends/platform/iphone/osys_iphone.h
scummvm/branches/branch-0-11-0/base/commandLine.cpp
scummvm/branches/branch-0-11-0/common/config-manager.cpp
Modified: scummvm/branches/branch-0-11-0/backends/platform/iphone/osys_iphone.cpp
===================================================================
--- scummvm/branches/branch-0-11-0/backends/platform/iphone/osys_iphone.cpp 2008-02-22 09:13:27 UTC (rev 30917)
+++ scummvm/branches/branch-0-11-0/backends/platform/iphone/osys_iphone.cpp 2008-02-22 20:11:51 UTC (rev 30918)
@@ -27,15 +27,14 @@
#include <CoreGraphics/CGDirectDisplay.h>
#include <CoreSurface/CoreSurface.h>
-#include <AudioToolbox/AudioQueue.h>
#include <unistd.h>
#include <pthread.h>
-#include "common/system.h"
#include "common/scummsys.h"
#include "common/util.h"
#include "common/rect.h"
-#include "common/events.h"
+#include "common/file.h"
+#include "common/fs.h"
#include "base/main.h"
@@ -55,6 +54,7 @@
AQCallbackStruct OSystem_IPHONE::s_AudioQueue;
SoundProc OSystem_IPHONE::s_soundCallback = NULL;
void *OSystem_IPHONE::s_soundParam = NULL;
+bool OSystem_IPHONE::s_is113OrHigher = false;
OSystem_IPHONE::OSystem_IPHONE() :
_savefile(NULL), _mixer(NULL), _timer(NULL), _offscreen(NULL),
@@ -1173,8 +1173,47 @@
return new OSystem_IPHONE();
}
+const char* OSystem_IPHONE::getConfigPath() {
+ if (s_is113OrHigher)
+ return SCUMMVM_PREFS_PATH;
+ else
+ return SCUMMVM_OLD_PREFS_PATH;
+}
+
+const char* OSystem_IPHONE::getSavePath() {
+ if (s_is113OrHigher)
+ return SCUMMVM_SAVE_PATH;
+ else
+ return SCUMMVM_OLD_SAVE_PATH;
+}
+
+void OSystem_IPHONE::migrateApp() {
+ // Migrate to the new 1.1.3 directory structure, if needed.
+
+ FilesystemNode file("/var/mobile");
+ if (file.exists() && file.isDirectory()) {
+ // We have 1.1.3 or above.
+ s_is113OrHigher = true;
+ file = FilesystemNode(SCUMMVM_ROOT_PATH);
+ if (!file.exists()) {
+ system("mkdir " SCUMMVM_ROOT_PATH);
+ system("mkdir " SCUMMVM_SAVE_PATH);
+
+ // Copy over the prefs file
+ system("cp " SCUMMVM_OLD_PREFS_PATH " " SCUMMVM_PREFS_PATH);
+
+ file = FilesystemNode(SCUMMVM_OLD_SAVE_PATH);
+ // Copy over old savegames to the new directory.
+ if (file.exists() && file.isDirectory())
+ system("cp " SCUMMVM_OLD_SAVE_PATH "/* " SCUMMVM_SAVE_PATH "/");
+ }
+ }
+}
+
void iphone_main(int argc, char *argv[]) {
+ OSystem_IPHONE::migrateApp();
+
// Redirect stdout and stderr if we're launching from the Springboard.
if (argc == 2 && strcmp(argv[1], "--launchedFromSB") == 0) {
FILE *newfp = fopen("/tmp/scummvm.log", "a");
Modified: scummvm/branches/branch-0-11-0/backends/platform/iphone/osys_iphone.h
===================================================================
--- scummvm/branches/branch-0-11-0/backends/platform/iphone/osys_iphone.h 2008-02-22 09:13:27 UTC (rev 30917)
+++ scummvm/branches/branch-0-11-0/backends/platform/iphone/osys_iphone.h 2008-02-22 20:11:51 UTC (rev 30918)
@@ -27,11 +27,21 @@
#include "graphics/surface.h"
#include "iphone_common.h"
+#include "common/system.h"
+#include "common/events.h"
+#include <AudioToolbox/AudioQueue.h>
+
#define AUDIO_BUFFERS 3
#define WAVE_BUFFER_SIZE 8192
#define AUDIO_SAMPLE_RATE 44100
+#define SCUMMVM_ROOT_PATH "/var/mobile/Library/ScummVM"
+#define SCUMMVM_SAVE_PATH SCUMMVM_ROOT_PATH "/Savegames"
+#define SCUMMVM_OLD_SAVE_PATH "/var/root/.scummvm"
+#define SCUMMVM_PREFS_PATH SCUMMVM_ROOT_PATH "/Preferences"
+#define SCUMMVM_OLD_PREFS_PATH "/var/root/.scummvmrc"
+
typedef void (*SoundProc)(void *param, byte *buf, int len);
typedef int (*TimerProc)(int interval);
@@ -49,7 +59,8 @@
static AQCallbackStruct s_AudioQueue;
static SoundProc s_soundCallback;
static void *s_soundParam;
-
+ static bool s_is113OrHigher;
+
Common::SaveFileManager *_savefile;
Audio::Mixer *_mixer;
Common::TimerManager *_timer;
@@ -154,6 +165,10 @@
virtual Audio::Mixer *getMixer();
virtual Common::TimerManager *getTimerManager();
+ static void migrateApp();
+ static const char* getConfigPath();
+ static const char* getSavePath();
+
protected:
inline void addDirtyRect(int16 x1, int16 y1, int16 w, int16 h);
void internUpdateScreen();
Modified: scummvm/branches/branch-0-11-0/base/commandLine.cpp
===================================================================
--- scummvm/branches/branch-0-11-0/base/commandLine.cpp 2008-02-22 09:13:27 UTC (rev 30917)
+++ scummvm/branches/branch-0-11-0/base/commandLine.cpp 2008-02-22 20:11:51 UTC (rev 30918)
@@ -35,6 +35,10 @@
#include "sound/mididrv.h"
#include "sound/mixer.h"
+#ifdef IPHONE
+#include "backends/platform/iphone/osys_iphone.h"
+#endif
+
#ifdef UNIX
#ifdef MACOSX
#define DEFAULT_SAVE_PATH "Documents/ScummVM Savegames"
@@ -224,10 +228,8 @@
strcpy(savePath, Symbian::GetExecutablePath());
strcat(savePath, DEFAULT_SAVE_PATH);
ConfMan.registerDefault("savepath", savePath);
-#elif defined (IPHONE) // The iphone has / set as home dir when launching from the Springboard.
- strcpy(savePath, "/var/root/");
- strcat(savePath, DEFAULT_SAVE_PATH);
- ConfMan.registerDefault("savepath", savePath);
+#elif defined (IPHONE)
+ ConfMan.registerDefault("savepath", OSystem_IPHONE::getSavePath());
#endif
#endif // #ifdef DEFAULT_SAVE_PATH
Modified: scummvm/branches/branch-0-11-0/common/config-manager.cpp
===================================================================
--- scummvm/branches/branch-0-11-0/common/config-manager.cpp 2008-02-22 09:13:27 UTC (rev 30917)
+++ scummvm/branches/branch-0-11-0/common/config-manager.cpp 2008-02-22 20:11:51 UTC (rev 30918)
@@ -39,6 +39,10 @@
#include "backends/platform/ps2/systemps2.h"
#endif
+#ifdef IPHONE
+#include "backends/platform/iphone/osys_iphone.h"
+#endif
+
#if defined(UNIX)
#ifdef MACOSX
#define DEFAULT_CONFIG_FILE "Library/Preferences/ScummVM Preferences"
@@ -138,7 +142,7 @@
#elif defined(PALMOS_MODE)
strcpy(configFile,"/PALM/Programs/ScummVM/" DEFAULT_CONFIG_FILE);
#elif defined(IPHONE)
- strcpy(configFile,"/var/root/" DEFAULT_CONFIG_FILE);
+ strcpy(configFile, OSystem_IPHONE::getConfigPath());
#elif defined(__PLAYSTATION2__)
((OSystem_PS2*)g_system)->makeConfigPath(configFile);
#elif defined(__PSP__)
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