[Scummvm-cvs-logs] scummvm master -> 8701e0a382b4b42d75cf38006234612c344808cf

Kirben kirben at optusnet.com.au
Mon Jan 23 13:23:56 CET 2012


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
8701e0a382 WINDOWS: Add default save paths for Windows NT4 onwards


Commit: 8701e0a382b4b42d75cf38006234612c344808cf
    https://github.com/scummvm/scummvm/commit/8701e0a382b4b42d75cf38006234612c344808cf
Author: Travis Howell (kirben at optusnet.com.au)
Date: 2012-01-23T04:18:21-08:00

Commit Message:
WINDOWS: Add default save paths for Windows NT4 onwards

Changed paths:
  A backends/saves/windows/windows-saves.cpp
  A backends/saves/windows/windows-saves.h
    README
    backends/module.mk
    backends/platform/sdl/win32/win32.cpp



diff --git a/README b/README
index 35af23e..d5c8fe1 100644
--- a/README
+++ b/README
@@ -1340,8 +1340,20 @@ config file by setting the savepath parameter. See the example config
 file later in this README.
 
 The platforms that currently have a different default directory are:
-    Mac OS X:     $HOME/Documents/ScummVM Savegames/
-    Other unices: $HOME/.scummvm/
+    Mac OS X:
+    $HOME/Documents/ScummVM Savegames/
+
+    Other unices:
+    $HOME/.scummvm/
+
+    Windows Vista/7:
+    \Users\username\AppData\Roaming\ScummVM\Saved games\
+
+    Windows 2000/XP:
+    \Documents and Settings\username\Application Data\ScummVM\Saved games\
+
+    Windows NT4:
+    <windir>\Profiles\username\Application Data\ScummVM\Saved games\
 
 
 6.1) Autosaves:
diff --git a/backends/module.mk b/backends/module.mk
index 6be595a..37209ff 100644
--- a/backends/module.mk
+++ b/backends/module.mk
@@ -98,6 +98,7 @@ MODULE_OBJS += \
 	fs/windows/windows-fs-factory.o \
 	midi/windows.o \
 	plugins/win32/win32-provider.o \
+	saves/windows/windows-saves.o \
 	taskbar/win32/win32-taskbar.o
 endif
 
diff --git a/backends/platform/sdl/win32/win32.cpp b/backends/platform/sdl/win32/win32.cpp
index 3e09aa2..453d566 100644
--- a/backends/platform/sdl/win32/win32.cpp
+++ b/backends/platform/sdl/win32/win32.cpp
@@ -38,6 +38,7 @@
 #include <SDL_syswm.h> // For setting the icon
 
 #include "backends/platform/sdl/win32/win32.h"
+#include "backends/saves/windows/windows-saves.h"
 #include "backends/fs/windows/windows-fs-factory.h"
 #include "backends/taskbar/win32/win32-taskbar.h"
 
@@ -74,6 +75,10 @@ void OSystem_Win32::initBackend() {
 		FreeConsole();
 	}
 
+	// Create the savefile manager
+	if (_savefileManager == 0)
+		_savefileManager = new WindowsSaveFileManager();
+
 	// Invoke parent implementation of this method
 	OSystem_SDL::initBackend();
 }
diff --git a/backends/saves/windows/windows-saves.cpp b/backends/saves/windows/windows-saves.cpp
new file mode 100644
index 0000000..87348c3
--- /dev/null
+++ b/backends/saves/windows/windows-saves.cpp
@@ -0,0 +1,78 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/scummsys.h"
+
+#include "backends/saves/windows/windows-saves.h"
+
+#if defined(WIN32) && !defined(_WIN32_WCE) && !defined(DISABLE_DEFAULT_SAVEFILEMANAGER)
+
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+
+#include "common/config-manager.h"
+#include "common/savefile.h"
+
+WindowsSaveFileManager::WindowsSaveFileManager() {
+	char defaultSavepath[MAXPATHLEN];
+
+	OSVERSIONINFO win32OsVersion;
+	ZeroMemory(&win32OsVersion, sizeof(OSVERSIONINFO));
+	win32OsVersion.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+	GetVersionEx(&win32OsVersion);
+	// Check for non-9X version of Windows.
+	if (win32OsVersion.dwPlatformId != VER_PLATFORM_WIN32_WINDOWS) {
+		// Use the Application Data directory of the user profile.
+		if (win32OsVersion.dwMajorVersion >= 5) {
+			if (!GetEnvironmentVariable("APPDATA", defaultSavepath, sizeof(defaultSavepath)))
+				error("Unable to access application data directory");
+		} else {
+			if (!GetEnvironmentVariable("USERPROFILE", defaultSavepath, sizeof(defaultSavepath)))
+				error("Unable to access user profile directory");
+
+			strcat(defaultSavepath, "\\Application Data");
+
+			// If the directory already exists (as it should in most cases),
+			// we don't want to fail, but we need to stop on other errors (such as ERROR_PATH_NOT_FOUND)
+			if (!CreateDirectory(defaultSavepath, NULL)) {
+				if (GetLastError() != ERROR_ALREADY_EXISTS)
+					error("Cannot create Application data folder");
+			}
+		}
+
+		strcat(defaultSavepath, "\\ScummVM");
+		if (!CreateDirectory(defaultSavepath, NULL)) {
+			if (GetLastError() != ERROR_ALREADY_EXISTS)
+				error("Cannot create ScummVM application data folder");
+		}
+
+		strcat(defaultSavepath, "\\Saved games");
+		if (!CreateDirectory(defaultSavepath, NULL)) {
+			if (GetLastError() != ERROR_ALREADY_EXISTS)
+				error("Cannot create ScummVM Saved games folder");
+		}
+
+		ConfMan.registerDefault("savepath", defaultSavepath);
+	}
+}
+
+#endif
diff --git a/backends/saves/windows/windows-saves.h b/backends/saves/windows/windows-saves.h
new file mode 100644
index 0000000..a705aa2
--- /dev/null
+++ b/backends/saves/windows/windows-saves.h
@@ -0,0 +1,36 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef BACKEND_WINDOWS_SAVES_H
+#define BACKEND_WINDOWS_SAVES_H
+
+#include "backends/saves/default/default-saves.h"
+
+/**
+ * Provides a default savefile manager implementation for common platforms.
+ */
+class WindowsSaveFileManager : public DefaultSaveFileManager {
+public:
+	WindowsSaveFileManager();
+};
+
+#endif






More information about the Scummvm-git-logs mailing list