[Scummvm-git-logs] scummvm branch-2-9 -> ff9a7b3105f4613b21145043a494659e19180ced

criezy noreply at scummvm.org
Tue Dec 3 22:35:09 UTC 2024


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

Summary:
365653e76a MACOS: Change default savepath to use the Application Support folder
ff9a7b3105 NEWS: Mention change of default savegame path on macOS


Commit: 365653e76a99df2bf02ccbd8f3520d4b38b58d7a
    https://github.com/scummvm/scummvm/commit/365653e76a99df2bf02ccbd8f3520d4b38b58d7a
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2024-12-03T22:32:56Z

Commit Message:
MACOS: Change default savepath to use the Application Support folder

The default savepath on macOS used to be in the user Document folder.
However ScummVM requires special permission to access that folder,
and if the user denied it, this caused various issues.
This implement ticket #11428.

This commit also contains migration code that that old configs that
used the default path are set explicitly to use the old default path.
So the change of savepath will only be for new users.

Changed paths:
    backends/platform/sdl/macosx/macosx.cpp
    backends/platform/sdl/macosx/macosx_wrapper.h
    backends/platform/sdl/macosx/macosx_wrapper.mm
    backends/saves/posix/posix-saves.cpp
    dists/macosx/Info.plist
    dists/macosx/Info.plist.in
    doc/cz/PrectiMe
    doc/de/LIESMICH
    doc/docportal/use_scummvm/save_load_games.rst
    doc/se/LasMig


diff --git a/backends/platform/sdl/macosx/macosx.cpp b/backends/platform/sdl/macosx/macosx.cpp
index 67f7bb5b1d2..4b653dd7255 100644
--- a/backends/platform/sdl/macosx/macosx.cpp
+++ b/backends/platform/sdl/macosx/macosx.cpp
@@ -117,6 +117,20 @@ void OSystem_MacOSX::initBackend() {
 	_textToSpeechManager = new MacOSXTextToSpeechManager();
 #endif
 
+	// Migrate savepath.
+	// It used to be in ~/Documents/ScummVM Savegames/, but was changed to use the application support
+	// directory. To migrate old config files we use a flag to indicate if the config file was migrated.
+	// This allows detecting old config files. If the flag is not set we:
+	// 1. Set the flag
+	// 2. If the config file has no custom savepath and has some games, we set the savepath to the old default.
+	if (!ConfMan.hasKey("macos_savepath_migrated", Common::ConfigManager::kApplicationDomain)) {
+		if (!ConfMan.hasKey("savepath", Common::ConfigManager::kApplicationDomain) && !ConfMan.getGameDomains().empty()) {
+			ConfMan.set("savepath", getDocumentsPathMacOSX() + "/ScummVM Savegames", Common::ConfigManager::kApplicationDomain);
+		}
+		ConfMan.setBool("macos_savepath_migrated", true, Common::ConfigManager::kApplicationDomain);
+		ConfMan.flushToDisk();
+	}
+
 	// Invoke parent implementation of this method
 	OSystem_POSIX::initBackend();
 }
diff --git a/backends/platform/sdl/macosx/macosx_wrapper.h b/backends/platform/sdl/macosx/macosx_wrapper.h
index d081d070045..41e064fc389 100644
--- a/backends/platform/sdl/macosx/macosx_wrapper.h
+++ b/backends/platform/sdl/macosx/macosx_wrapper.h
@@ -25,6 +25,7 @@
 #include <common/str.h>
 
 Common::String getDesktopPathMacOSX();
+Common::String getDocumentsPathMacOSX();
 Common::String getResourceAppBundlePathMacOSX();
 Common::String getAppSupportPathMacOSX();
 Common::String getMacBundleName();
diff --git a/backends/platform/sdl/macosx/macosx_wrapper.mm b/backends/platform/sdl/macosx/macosx_wrapper.mm
index 4a27d24dfcb..ece5b32f422 100644
--- a/backends/platform/sdl/macosx/macosx_wrapper.mm
+++ b/backends/platform/sdl/macosx/macosx_wrapper.mm
@@ -46,6 +46,17 @@ Common::String getDesktopPathMacOSX() {
 	return Common::String([path fileSystemRepresentation]);
 }
 
+Common::String getDocumentsPathMacOSX() {
+	// See comment in getDesktopPathMacOSX()
+	NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
+	if ([paths count] == 0)
+		return Common::String();
+	NSString *path = [paths objectAtIndex:0];
+	if (path == nil)
+		return Common::String();
+	return Common::String([path fileSystemRepresentation]);
+}
+
 Common::String getResourceAppBundlePathMacOSX() {
 	NSString *bundlePath = [[NSBundle mainBundle] resourcePath];
 	if (bundlePath == nil)
diff --git a/backends/saves/posix/posix-saves.cpp b/backends/saves/posix/posix-saves.cpp
index 04cbcb335df..b8b3932d1ab 100644
--- a/backends/saves/posix/posix-saves.cpp
+++ b/backends/saves/posix/posix-saves.cpp
@@ -32,6 +32,9 @@
 
 #include "backends/saves/posix/posix-saves.h"
 #include "backends/fs/posix/posix-fs.h"
+#if defined(MACOSX)
+#include "backends/platform/sdl/macosx/macosx_wrapper.h"
+#endif
 
 #include "common/config-manager.h"
 #include "common/savefile.h"
@@ -44,14 +47,11 @@ POSIXSaveFileManager::POSIXSaveFileManager() {
 	Common::Path savePath;
 
 #if defined(MACOSX)
-	const char *home = getenv("HOME");
-	if (home && *home && strlen(home) < MAXPATHLEN) {
-		savePath = home;
-		savePath.joinInPlace("Documents/ScummVM Savegames");
-
+	savePath = getAppSupportPathMacOSX();
+	if (!savePath.empty()) {
+		savePath.joinInPlace("Savegames");
 		ConfMan.registerDefault("savepath", savePath);
 	}
-
 #else
 	const char *envVar;
 
diff --git a/dists/macosx/Info.plist b/dists/macosx/Info.plist
index 2c4875b7560..d33a0a59020 100644
--- a/dists/macosx/Info.plist
+++ b/dists/macosx/Info.plist
@@ -78,8 +78,6 @@
 	<string>scummvm.docktileplugin</string>
 	<key>NSRequiresAquaSystemAppearance</key>
 	<false/>
-	<key>NSDocumentsFolderUsageDescription</key>
-	<string>ScummVM saves and loads savegames in the Documents folder by default.</string>
 	<key>SUPublicDSAKeyFile</key>
 	<string>dsa_pub.pem</string>
 	<key>NSHighResolutionCapable</key>
diff --git a/dists/macosx/Info.plist.in b/dists/macosx/Info.plist.in
index c05f0e0a853..61c1ed852ee 100644
--- a/dists/macosx/Info.plist.in
+++ b/dists/macosx/Info.plist.in
@@ -78,8 +78,6 @@
 	<string>scummvm.docktileplugin</string>
 	<key>NSRequiresAquaSystemAppearance</key>
 	<false/>
-	<key>NSDocumentsFolderUsageDescription</key>
-	<string>ScummVM saves and loads savegames in the Documents folder by default.</string>
 	<key>SUPublicDSAKeyFile</key>
 	<string>dsa_pub.pem</string>
 	<key>NSHighResolutionCapable</key>
diff --git a/doc/cz/PrectiMe b/doc/cz/PrectiMe
index 8cb9a096bf1..618ae55cfa9 100644
--- a/doc/cz/PrectiMe
+++ b/doc/cz/PrectiMe
@@ -1352,7 +1352,7 @@ Uložené hry jsou na některých platformách standardně umístěny do součas
 
 Platformy, které v současnosti mají jiné výchozí složky jsou:
     macOS:
-    $HOME/Documents/ScummVM Savegames/
+    $HOME/Library/Application Support/ScummVM/Savegames/
 
     Jiné unixy:
     Řídíme se specifikacemi základního adresáře XDG. To znamená, že nastavení lze nalézt v:
diff --git a/doc/de/LIESMICH b/doc/de/LIESMICH
index 5a622effd76..080fd91d063 100644
--- a/doc/de/LIESMICH
+++ b/doc/de/LIESMICH
@@ -2017,7 +2017,7 @@ Sehen Sie sich das Beispiel weiter unten in dieser Liesmich-Datei an.
 
 Die folgenden Plattformen haben ein anderes Standard-Verzeichnis:
     macOS:
-    $HOME/Documents/ScummVM Savegames/
+    $HOME/Library/Application Support/ScummVM/Savegames/
 
     Andere UNIX-Systeme:
     Wir befolgen die Spezifikation XDG Base Directory. Dies bedeutet, dass
diff --git a/doc/docportal/use_scummvm/save_load_games.rst b/doc/docportal/use_scummvm/save_load_games.rst
index c5372539c67..b1f70a9c2bd 100644
--- a/doc/docportal/use_scummvm/save_load_games.rst
+++ b/doc/docportal/use_scummvm/save_load_games.rst
@@ -60,7 +60,7 @@ Default saved game paths are shown below.
 
     .. tab-item:: macOS
 
-        ``~/Documents/ScummVM Savegames/``
+        ``~/Library/Application Support/ScummVM/Savegames/`` (with versions of ScummVM prior to 2.9 it was in ``~/Documents/ScummVM Savegames/``).
 
 
     .. tab-item:: Linux/Unix
diff --git a/doc/se/LasMig b/doc/se/LasMig
index af1bcf84d47..8dab0497a92 100644
--- a/doc/se/LasMig
+++ b/doc/se/LasMig
@@ -1031,7 +1031,7 @@ Spardata lagras som standard i den aktiva katalogen på vissa plattformar och i
 
 Plattformar som för närvarande har annorlunda standardkataloger:
     macOS:
-    $HOME/Documents/ScummVM Savegames/
+    $HOME/Library/Application Support/ScummVM/Savegames/
 
     Övriga unix-system:
     $HOME/.scummvm/


Commit: ff9a7b3105f4613b21145043a494659e19180ced
    https://github.com/scummvm/scummvm/commit/ff9a7b3105f4613b21145043a494659e19180ced
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2024-12-03T22:34:48Z

Commit Message:
NEWS: Mention change of default savegame path on macOS

Changed paths:
    NEWS.md


diff --git a/NEWS.md b/NEWS.md
index e9439eecc26..960bca011a7 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -276,6 +276,7 @@ For a more comprehensive changelog of the latest experimental code, see:
 
  macOS port:
    - Autoupdates now use Sparkle 2.x.
+   - Default savegame path was changed to use the Application Support folder.
 
  3DS port:
    - Integrated the port-specific options dialog with the main GUI.




More information about the Scummvm-git-logs mailing list