Play your Steam library's Windows games on a jailbroken PS5.
C++
Keep the web page's files out of Cloud and copies
Leonardo Lobato0feaf3358c16
diff --git a/README.md b/README.mdindex 0c2e36e..90593ad 100644--- a/README.md+++ b/README.md@@ -155,7 +155,7 @@ ShadowMountPlus adds its tile to the Home screen.- Logs: `/data/playden/logs/`. The first startup lines, written before Playden gets its root access,stay in `logs/` in the app folder.- Downloaded games: `/data/playden-games/`. Each game's Windows folder, with its saves, stays under- `/data/playden/games/` (see [Saves and game configs over FTP](#saves-and-game-configs-over-ftp)).+ `/data/playden/games/` (see [Saves and game configs](#saves-and-game-configs)).The app folder keeps empty `playden-data` and `logs` folders, and a `MOVED.txt` in each old place says wherethe data went.@@ -214,9 +214,26 @@ The kit is built on a **Linux x86-64 machine or VM** from prospero-win, Wine, Mesee [Build the kit](docs/building.md#build-the-kit). The scripts are a record of how we built it, not a turnkey buildyet, so most people should use the release download.-### Saves and game configs over FTP+### Saves and game configs-Each game's Windows user folder holds its saves and most of its `.ini` configs:+Open Playden's web page from a phone or computer on the same network: Settings › Web access shows the address and a+QR code. In the **Files** tab, pair the browser with the 6-digit code the TV shows. The pairing ends when Playden closes.++Pick a game to download, upload, replace or delete its files. Playden answers only while it is open, and starting a+game closes it.++- **Saves and most configs** are in the game's Windows user folder (`Documents`, `AppData`, `Saved Games`). They are on+ the console even when the game plays from a USB drive, and they stay when you uninstall the game.+- **The game folder** has mods and game-side configs. A game update can overwrite the game's own files, and+ uninstalling removes the folder with everything you added. `steam_settings` is read-only, because Playden writes it.+- **Replacing a file** keeps the old one as its previous version, which you can download or restore.+- A game that is still running can overwrite what you change, so close it on the PS5 first. The page marks a game as+ Running when it can tell.+- A save you upload can replace the one in Steam Cloud at the next sync.++Playden's web page uses plain HTTP, so use it only on a network you trust.++**Over FTP** instead, each game's Windows user folder is:```text/data/playden/games/steam-<Steam app ID>/library/prefixes/game/drive_c/users/prospero/diff --git a/src/stores/local/copy_plan.cpp b/src/stores/local/copy_plan.cppindex de01295..f21c56c 100644--- a/src/stores/local/copy_plan.cpp+++ b/src/stores/local/copy_plan.cpp@@ -216,6 +216,8 @@ CopyPlanBuild BuildCopyPlan(const std::string& source_path, std::size_t max_filebuild.skipped.push_back(name);continue;}+ // Half of a file the web page is writing, or was when a crash stopped it (web/file_policy.h).+ if (name.rfind(".playden-upload-", 0) == 0 || name.rfind(".playden-restore-", 0) == 0) continue;const auto relative = frame.relative.empty() ? name : frame.relative + "/" + name;if (entry->d_type == DT_LNK) return fail(LinkWords(relative), ELOOP);const int child = platform::OpenWalkChildUnprivileged(frame.fd, name.c_str(), kOpenAny, static_cast<std::uint64_t>(entry->d_fileno));diff --git a/src/stores/local/copy_plan.h b/src/stores/local/copy_plan.hindex 4ab92c6..e7c2319 100644--- a/src/stores/local/copy_plan.h+++ b/src/stores/local/copy_plan.h@@ -58,7 +58,8 @@ struct CopyPlanBuild {// A link anywhere fails it, naming the link; so do an unreadable entry and more than `max_files`// files or `max_bytes` bytes. Other kinds of entries (sockets, devices) are left out, and so are// Playden's own names at the top level (the copy journal, the install record and file list, the-// download journal): never copied over Playden's, and never deleted from a drop folder.+// download journal): never copied over Playden's, and never deleted from a drop folder. The web page's+// temporary files are left out at any depth; its previous versions are copied with their files.CopyPlanBuild BuildCopyPlan(const std::string& source, std::size_t max_files = kMaxCopyFiles,std::uint64_t max_bytes = kMaxCopyBytes);diff --git a/tests/depot_installer_test.cpp b/tests/depot_installer_test.cppindex 33b9185..e2da00a 100644--- a/tests/depot_installer_test.cpp+++ b/tests/depot_installer_test.cpp@@ -1554,6 +1554,10 @@ void RemovesOnlyManagedFolders(const std::filesystem::path& base) {// Files the install did not record (written by the game or other tools, in open folders) go too.InstallsMergedDepotsAndWritesRecord(managed);+ // The web page's previous versions among them, wherever they are.+ std::ofstream(managed / ".playden-bak.top.sav") << "older";+ std::filesystem::create_directories(managed / "web/sub");+ std::ofstream(managed / "web/sub/.playden-bak.deep.sav") << "older";std::filesystem::create_directories(managed / "bottle/drive_c");std::filesystem::permissions(managed / "bottle", std::filesystem::perms::all);std::ofstream(managed / "bottle/drive_c/user.reg") << "written later";@@ -1686,9 +1690,14 @@ void MeasureUpdateMatchesTheUpdate(const std::filesystem::path& root) {CHECK(measured.error == InstallError::kNone && world.chunk_calls == 0);CHECK(!std::filesystem::exists(root / DepotInstaller::kUpdateDir));CHECK(measured.staged_bytes == 27 + 5 && measured.install_bytes == 27 + 13 + 5);+ // The web page's previous versions, at the top and in a folder, stay through an update and don't count in it.+ std::ofstream(root / ".playden-bak.top.sav") << "older";+ std::filesystem::create_directories(root / "web");+ std::ofstream(root / "web/.playden-bak.deep.sav") << "older";InstallProgress last;CHECK(installer.Run({}, target, cancel, [&](const InstallProgress& progress) { last = progress; }).error == InstallError::kNone);CHECK(measured.download_bytes == last.download_total && measured.download_bytes > 0);+ CHECK(std::filesystem::exists(root / ".playden-bak.top.sav") && std::filesystem::exists(root / "web/.playden-bak.deep.sav"));// Up to date: nothing to download.const auto same = installer.MeasureUpdate({}, target.app_id, target.depots, {}, root.string(), cancel);CHECK(same.error == InstallError::kNone && same.download_bytes == 0 && same.staged_bytes == 0);diff --git a/tests/homebrew_library_model_test.cpp b/tests/homebrew_library_model_test.cppindex c1660c9..9c15d2d 100644--- a/tests/homebrew_library_model_test.cpp+++ b/tests/homebrew_library_model_test.cpp@@ -1883,6 +1883,10 @@ void live_storage_section_and_installed_games() {address->section == "Web access" && address->subtitle.find("your Steam name removed") != std::string::npos &&!address->enabled,"the page's address shows with its QR code");+ model.ApplyLiveWebAccess({"on", "http://192.168.1.50:7031/", 7031, {}, "481207"});+ check(model.state().web_pairing_code == "481207", "a browser's pairing code reaches the screen");+ model.ApplyLiveWebAccess({"on", "http://192.168.1.50:7031/", 7031, {}});+ check(model.state().web_pairing_code.empty(), "and goes when pairing ends");model.ApplyLiveWebAccess({"on", "", 7032, {}});check(find_row(model, "settings-web-address") && find_row(model, "settings-web-address")->qr.empty() &&find_row(model, "settings-web-address")->title == "Address unknown" &&diff --git a/tests/local_copy_test.cpp b/tests/local_copy_test.cppindex 5ce03ea..57f82b8 100644--- a/tests/local_copy_test.cpp+++ b/tests/local_copy_test.cpp@@ -220,6 +220,22 @@ struct Fixture {}};+void PlanLeavesOutTheWebPagesTemporaryFiles() {+ Fixture fixture;+ const auto base = fixture.source / "saves";+ std::ofstream(base / ".playden-upload-1234") << "half";+ std::ofstream(fixture.source / ".playden-restore-1234") << "half";+ std::ofstream(base / ".playden-bak.slot.sav") << "previous";+ const auto build = BuildCopyPlan(fixture.source.string());+ CHECK(build.ok);+ bool previous = false;+ for (const auto& file : build.plan.files) {+ CHECK(file.path.find(".playden-upload-") == std::string::npos && file.path.find(".playden-restore-") == std::string::npos);+ previous = previous || file.path == "saves/.playden-bak.slot.sav";+ }+ CHECK(previous);+}+void PlanCoversTheTree() {Fixture fixture;const auto build = BuildCopyPlan(fixture.source.string());@@ -1162,6 +1178,7 @@ void DropFolderCopyFreesTheDropFolder() {int main() {PlanCoversTheTree();+ PlanLeavesOutTheWebPagesTemporaryFiles();LinksAreRefused();CopiesIntoPlayden();UninstallWithoutTheSourceDrive();diff --git a/tests/runtime_redist_test.cpp b/tests/runtime_redist_test.cppindex 00bfacf..b8efd95 100644--- a/tests/runtime_redist_test.cpp+++ b/tests/runtime_redist_test.cpp@@ -534,6 +534,10 @@ void TestFoundPhysx() {prefix = fresh_prefix("bare-prefix");result = InstallRedistributables(bare.string(), "Z:\\games\\4", prefix.string(), 1700000100, true);CHECK(result.outcomes.empty() && result.physx_missing && result.physx_searched);+ // The installer added afterwards (from the web page, say): the next Play finds it.+ WriteText(bare / "_Redist/PhysX_9.09.msi", "not really a package");+ result = InstallRedistributables(bare.string(), "Z:\\games\\4", prefix.string(), 1700000200, true);+ CHECK(!result.physx_missing && result.physx_searched && result.outcomes.size() == 1 && result.outcomes[0].result == "failed");std::filesystem::remove_all(base);}diff --git a/tests/steam_cloud_test.cpp b/tests/steam_cloud_test.cppindex 92d1fdc..64f7456 100644--- a/tests/steam_cloud_test.cpp+++ b/tests/steam_cloud_test.cpp@@ -686,6 +686,21 @@ void QuickCheckAndIndex() {CHECK(steps.size() == 2 && steps.front().first == 0 && steps.back().first == 14 && steps.back().second == 14);// The Apply refreshed the index: in step again.CHECK(sync.QuickCheck(session, {location}, cancel) == std::vector<Drift>{Drift::kUnchanged});+ // The web page's previous versions and temporary files beside a save are not saves.+ WriteText(docs / ".playden-bak.slot1.sav", "older progress");+ WriteText(docs / ".playden-upload-1234", "half an upload");+ WriteText(docs / ".playden-restore-1234", "a restore's other half");+ CHECK(sync.QuickCheck(session, {location}, cancel) == std::vector<Drift>{Drift::kUnchanged});+ plan = sync.Check(session, location, cancel);+ CHECK(plan.status == PlanStatus::kUpToDate);+ std::filesystem::remove(docs / ".playden-upload-1234");+ std::filesystem::remove(docs / ".playden-restore-1234");+ // A save replaced from the web page is a local change.+ WriteText(docs / "slot1.sav", "uploaded from a computer");+ CHECK(sync.QuickCheck(session, {location}, cancel) == std::vector<Drift>{Drift::kLocal});+ outcome = sync.Apply(session, location, sync.Check(session, location, cancel), Resolution::kUseLocal, false, cancel, nullptr);+ CHECK(outcome.ok && outcome.uploaded == 1);+ CHECK(cloud.files.count("%WinMyDocuments%My Games/Cloud Game/.playden-bak.slot1.sav") == 0);cloud.files["%WinMyDocuments%My Games/Cloud Game/slot2.sav"] = {Bytes("other device"), 3'000, false};++cloud.change;// A new file in a save folder is a local change too; a game without an index stays unknown.@@ -705,7 +720,7 @@ void QuickCheckAndIndex() {CHECK(sync.RemoveLocal(location, &message) && message == "1 save deleted");CHECK(!std::filesystem::exists(docs / "slot1.sav"));CHECK(ReadText(base / "state/backup/1800000000/prefix/drive_c/users/prospero/Documents/My Games/Cloud Game/slot1.sav") ==- "local progress");+ "uploaded from a computer");CHECK(cloud.files.count("%WinMyDocuments%My Games/Cloud Game/slot1.sav") == 1);CHECK(!sync.RemoveLocal(fresh, &message));std::filesystem::remove_all(base);