Skip to content

Run Windows games on Apple Silicon — free, open source, with an open compatibility database that tells you what actually works.

A GOG Mac save location is never a folder many games share one level down

Gabec9fbeef56749
diff --git a/Sources/HighballKit/GOGSaves.swift b/Sources/HighballKit/GOGSaves.swift
index 873bb1c..25ef029 100644
--- a/Sources/HighballKit/GOGSaves.swift
+++ b/Sources/HighballKit/GOGSaves.swift
@@ -143,20 +143,30 @@ public struct GOGSaves: Sendable {
/// Desktop and the rest), every folder straight inside its Library (Preferences, Application
/// Support, Caches, Containers, Group Containers, Saved Application State and the rest), and
/// the top of a synced drive or a container there (iCloud Drive's com~apple~CloudDocs, a
- /// CloudStorage provider's folder, an app's container). A game's own folder sits deeper, as
- /// in ~/Library/Application Support/<studio>/<game>. Compared without case, as the Mac's
- /// disks are.
+ /// CloudStorage provider's folder, an app's container). Also the few folders many games share
+ /// one level deeper: ~/Documents/My Games, and a launcher's or porting house's folder in
+ /// Application Support (sharedVendorFolders). A game's own folder sits deeper, as in
+ /// ~/Library/Application Support/<studio>/<game>. Compared without case, as the Mac's disks
+ /// are.
static func isSharedFolder(_ folder: URL, home: URL) -> Bool {
let homeParts = home.standardizedFileURL.pathComponents.map { $0.lowercased() }
let parts = folder.standardizedFileURL.pathComponents.map { $0.lowercased() }
guard parts.count >= homeParts.count, Array(parts.prefix(homeParts.count)) == homeParts else { return false }
let inside = Array(parts.dropFirst(homeParts.count))
if inside.count <= 1 { return true }
+ if inside == ["documents", "my games"] { return true }
guard inside[0] == "library" else { return false }
if inside.count == 2 { return true }
- return inside.count == 3 && ["mobile documents", "cloudstorage", "containers", "group containers"].contains(inside[1])
+ guard inside.count == 3 else { return false }
+ return ["mobile documents", "cloudstorage", "containers", "group containers"].contains(inside[1])
+ || (inside[1] == "application support" && sharedVendorFolders.contains(inside[2]))
}
+ /// Folders in ~/Library/Application Support that hold many games' files, each game in its own
+ /// folder below: the stores' launchers and the porting houses whose Mac versions keep their
+ /// saves there. Lowercased.
+ static let sharedVendorFolders: Set<String> = ["gog.com", "steam", "epic", "epic games", "feral interactive", "aspyr"]
+
/// A location as a folder on the Mac, inside the environment. GOG's variables are the Windows
/// known folders; Wine keeps them under drive_c/users/<Mac user name>. A Documents folder the
/// environment links to the Mac's (UserFolders) resolves through the link, as Wine does.
diff --git a/Tests/HighballKitTests/StoreMacVersionTests.swift b/Tests/HighballKitTests/StoreMacVersionTests.swift
index a5480c4..ee85c99 100644
--- a/Tests/HighballKitTests/StoreMacVersionTests.swift
+++ b/Tests/HighballKitTests/StoreMacVersionTests.swift
@@ -238,9 +238,19 @@ final class GOGMacSavesTests: XCTestCase {
"<?LIBRARY?>/Containers", "<?LIBRARY?>/Group Containers", "<?LIBRARY?>/preferences/",
"<?LIBRARY?>", "<?PREFERENCES?>", "<?APPLICATION_SUPPORT?>", "<?CACHES?>",
"<?LIBRARY?>/Mobile Documents/com~apple~CloudDocs", "<?LIBRARY?>/CloudStorage/Dropbox",
- "<?LIBRARY?>/Containers/com.studio.game", "<?DOCUMENTS?>/../Desktop"] {
+ "<?LIBRARY?>/Containers/com.studio.game", "<?DOCUMENTS?>/../Desktop",
+ // Folders many games share one level deeper, each game in its own folder below.
+ "<?DOCUMENTS?>/My Games", "<?DOCUMENTS?>/my games/", "<?APPLICATION_SUPPORT?>/GOG.com",
+ "<?APPLICATION_SUPPORT?>/Steam", "<?APPLICATION_SUPPORT?>/Epic", "<?APPLICATION_SUPPORT?>/Epic Games",
+ "<?LIBRARY?>/Application Support/Feral Interactive", "<?APPLICATION_SUPPORT?>/Aspyr"] {
XCTAssertNil(GOGSaves.resolveMac(whole, installFolder: install, home: home), whole)
}
+ XCTAssertEqual(GOGSaves.resolveMac("<?DOCUMENTS?>/My Games/Studio Game", installFolder: install, home: home)?.path,
+ "/Users/someone/Documents/My Games/Studio Game")
+ XCTAssertEqual(GOGSaves.resolveMac("<?APPLICATION_SUPPORT?>/Feral Interactive/Game/Saves", installFolder: install, home: home)?.path,
+ "/Users/someone/Library/Application Support/Feral Interactive/Game/Saves")
+ XCTAssertEqual(GOGSaves.resolveMac("<?APPLICATION_SUPPORT?>/GOG.com/Galaxy/Applications/c/Storage/Shared/Files", installFolder: install, home: home)?.path,
+ "/Users/someone/Library/Application Support/GOG.com/Galaxy/Applications/c/Storage/Shared/Files")
XCTAssertEqual(GOGSaves.resolveMac("<?LIBRARY?>/Preferences/Studio Game", installFolder: install, home: home)?.path,
"/Users/someone/Library/Preferences/Studio Game")
XCTAssertEqual(GOGSaves.resolveMac("<?LIBRARY?>/Containers/com.studio.game/Data/Saves", installFolder: install, home: home)?.path,