From 5b958defa7656e4d0134e0edd80ea3d2adca5539 Mon Sep 17 00:00:00 2001
From: asvitkine <>
Date: Thu, 23 Jul 2009 19:12:51 +0000
Subject: [PATCH] support for .sheepvm bundles on macosx, containing "prefs"
and "nvram" files
---
SheepShaver/src/BeOS/main_beos.cpp | 2 +-
SheepShaver/src/BeOS/prefs_beos.cpp | 2 +-
SheepShaver/src/MacOSX/Info.plist.in | 17 ++++++++++++++
SheepShaver/src/Unix/main_unix.cpp | 28 +++++++++++++++++++++--
SheepShaver/src/Unix/prefs_unix.cpp | 14 +++++++++++-
SheepShaver/src/Windows/main_windows.cpp | 2 +-
SheepShaver/src/Windows/prefs_windows.cpp | 2 +-
SheepShaver/src/include/main.h | 2 +-
SheepShaver/src/main.cpp | 4 ++--
9 files changed, 63 insertions(+), 10 deletions(-)
diff --git a/SheepShaver/src/BeOS/main_beos.cpp b/SheepShaver/src/BeOS/main_beos.cpp
index ddf3304c..6305e5c9 100644
--- a/SheepShaver/src/BeOS/main_beos.cpp
+++ b/SheepShaver/src/BeOS/main_beos.cpp
@@ -318,7 +318,7 @@ void SheepShaver::ReadyToRun(void)
// Read preferences
int argc = 0;
char **argv = NULL;
- PrefsInit(argc, argv);
+ PrefsInit(NULL, argc, argv);
// Init system routines
SysInit();
diff --git a/SheepShaver/src/BeOS/prefs_beos.cpp b/SheepShaver/src/BeOS/prefs_beos.cpp
index 4d7d33a8..cad4a888 100644
--- a/SheepShaver/src/BeOS/prefs_beos.cpp
+++ b/SheepShaver/src/BeOS/prefs_beos.cpp
@@ -49,7 +49,7 @@ time_t PrefsFileDate = 0;
* Load preferences from settings file
*/
-void LoadPrefs(void)
+void LoadPrefs(const char *vmdir)
{
// Construct prefs path
find_directory(B_USER_SETTINGS_DIRECTORY, &prefs_path, true);
diff --git a/SheepShaver/src/MacOSX/Info.plist.in b/SheepShaver/src/MacOSX/Info.plist.in
index 11fb3bb1..25fc2a5d 100644
--- a/SheepShaver/src/MacOSX/Info.plist.in
+++ b/SheepShaver/src/MacOSX/Info.plist.in
@@ -18,5 +18,22 @@
SheepShaver.icns
CSResourcesFileMapped
+ CFBundleDocumentTypes
+
+
+ CFBundleTypeExtensions
+
+ sheepvm
+
+ CFBundleTypeIconFile
+ SheepShaver.icns
+ CFBundleTypeName
+ SheepShaver VM
+ CFBundleTypeRole
+ Editor
+ LSTypeIsPackage
+
+
+
diff --git a/SheepShaver/src/Unix/main_unix.cpp b/SheepShaver/src/Unix/main_unix.cpp
index b8f04c51..9c5328f0 100644
--- a/SheepShaver/src/Unix/main_unix.cpp
+++ b/SheepShaver/src/Unix/main_unix.cpp
@@ -89,6 +89,7 @@
#include
#include
#include
+#include
#include
#include "sysdeps.h"
@@ -360,6 +361,19 @@ static void usage(const char *prg_name)
exit(0);
}
+static bool valid_vmdir(const char *path)
+{
+ const int suffix_len = sizeof(".sheepvm") - 1;
+ int len = strlen(path);
+ if (len > suffix_len && !strcmp(path + len - suffix_len, ".sheepvm")) {
+ struct stat d;
+ if (!stat(path, &d) && S_ISDIR(d.st_mode)) {
+ return true;
+ }
+ }
+ return false;
+}
+
int main(int argc, char **argv)
{
char str[256];
@@ -370,6 +384,7 @@ int main(int argc, char **argv)
uint8 *rom_tmp;
time_t now, expire;
bool memory_mapped_from_zero;
+ const char *vmdir = NULL;
#ifdef USE_SDL_VIDEO
// Don't let SDL block the screensaver
@@ -414,6 +429,15 @@ int main(int argc, char **argv)
gui_connection_path = argv[i];
argv[i] = NULL;
}
+ } else if (valid_vmdir(argv[i])) {
+ vmdir = argv[i];
+ argv[i] = NULL;
+ printf("Using %s as vmdir.\n", vmdir);
+ if (chdir(vmdir)) {
+ printf("Failed to chdir to %s. Good bye.", vmdir);
+ exit(1);
+ }
+ break;
}
}
@@ -448,7 +472,7 @@ int main(int argc, char **argv)
#endif
// Read preferences
- PrefsInit(argc, argv);
+ PrefsInit(vmdir, argc, argv);
// Any command line arguments left?
for (int i=1; i