Skip to content

Play your Steam library's Windows games on a jailbroken PS5.

C++

Save the Library's Imported rail like Installed

Leonardo Lobato1ca201f1364b
diff --git a/src/library/organization.cpp b/src/library/organization.cpp
index b080fc5..f6d6e53 100644
--- a/src/library/organization.cpp
+++ b/src/library/organization.cpp
@@ -100,8 +100,11 @@ bool BuiltInScope(const std::string& value) {
return value == "all" || value == "favorites" || value == "hidden";
}
+// The Library rails of installed and imported games: scopes, never collection IDs.
+bool RailScope(const std::string& value) { return value == "installed" || value == "imported"; }
+
bool ReservedCollectionId(const std::string& value) {
- return BuiltInScope(value) || value == "installed" || value == "new-collection";
+ return BuiltInScope(value) || RailScope(value) || value == "new-collection";
}
bool ValidSort(const std::string& value) {
@@ -153,8 +156,7 @@ bool Validate(const OrganizationSnapshot& snapshot, std::uint16_t version) {
}
for (const GameId& id : collection.members) if (!AddGameId(game_ids, id, version)) return false;
}
- // "installed" is the Library rail of installed games; it is a scope, never a collection ID.
- if (!BuiltInScope(snapshot.scope) && snapshot.scope != "installed" && !collection_ids.count(snapshot.scope))
+ if (!BuiltInScope(snapshot.scope) && !RailScope(snapshot.scope) && !collection_ids.count(snapshot.scope))
return false;
if (snapshot.ratings.size() > kMaximumGameIds || snapshot.notes.size() > kMaximumGameIds)
diff --git a/tests/library_organization_test.cpp b/tests/library_organization_test.cpp
index ed55918..caa5479 100644
--- a/tests/library_organization_test.cpp
+++ b/tests/library_organization_test.cpp
@@ -131,6 +131,7 @@ void RejectsInvalidValuesWithoutReplacingGoodData() {
invalid = expected; invalid.collections.push_back(invalid.collections.front()); rejects(invalid, "duplicate collection ID rejected");
invalid = expected; invalid.collections.front().id = "../escape"; rejects(invalid, "unsafe collection ID rejected");
invalid = expected; invalid.collections.front().id = "installed"; rejects(invalid, "simulation rail ID cannot be a collection ID");
+ invalid = expected; invalid.collections.front().id = "imported"; rejects(invalid, "Imported rail ID cannot be a collection ID");
invalid = expected; invalid.collections.front().id = "new-collection"; rejects(invalid, "collection action ID cannot be a collection ID");
invalid = expected; invalid.collections.front().name.assign(129, 'n'); rejects(invalid, "oversized collection name rejected");
invalid = expected; invalid.collections.front().name = " \t"; rejects(invalid, "whitespace-only collection name rejected");
@@ -151,6 +152,14 @@ void RejectsInvalidValuesWithoutReplacingGoodData() {
Check(restored.ok() && restored.value() && restored.value()->scope == "installed", "installed scope restored");
Check(store.Save(kDevice, expected).ok(), "restore the expected organization file after installed scope");
}
+ {
+ // So is the Imported rail: choosing it was undone as "too large to save".
+ auto imported = expected; imported.scope = "imported";
+ Check(store.Save(kDevice, imported).ok(), "imported scope accepted");
+ const auto restored = store.Load(kDevice);
+ Check(restored.ok() && restored.value() && restored.value()->scope == "imported", "imported scope restored");
+ Check(store.Save(kDevice, expected).ok(), "restore the expected organization file after imported scope");
+ }
invalid = expected; invalid.scope = "new-collection"; rejects(invalid, "collection action cannot be restored as scope");
invalid = expected; invalid.sort = "install-size"; rejects(invalid, "simulation-only metadata sort rejected");
{