Files
mandy/runtime/shims/file_system.h
HQasper a98f9925b0 gta6rt: map GAME: console paths, and send writes to an overlay (RT-97)
A mapped title names its files on the console's drives, but nothing mapped them: the file calls went
straight to the host and --game-dir was only used to find modules, so the first file a title opens at boot
would fail. New shims for CreateFile*, FindFirstFile*/FindNextFile*/FindClose, GetFileAttributes*/
GetFileAttributesEx* and DeleteFile* (kernel32, kernelbase and the api-ms-win-core-file sets) map a GAME:
path under --game-dir, and send every open that can write and every delete to --overlay (default
<game-dir>\overlay), which reads and listings prefer. A write-open copies the package file into the overlay
first, so OPEN_EXISTING keeps its bytes, and a delete of a package file leaves a marker instead of removing
it, so the package is never modified. A path that climbs above GAME: with ".." or names another drive is
refused with ERROR_INVALID_NAME. A path without the prefix is still a host path.

The prefixes and the overlay come from ivall/xcl (GPL-2.0-only), as facts only, no code.

file_system ctest: 43 checks over folders in %TEMP%, covering mapping and case, copy-up and read
preference, a new file in folders the package lacks, delete and re-create, the merged listing, host-path
passthrough, the escape refusal and the narrow variants.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
2026-11-22 13:11:57 +01:00

30 lines
1.5 KiB
C++

// Console (GDK) file paths for a mapped title.
//
// A title's file API sees the console's drives: "GAME:\\data\\shaders\\x.sps" is a file inside the installed game
// folder. ivall/xcl (GPL-2.0-only; facts only here) documents for Xbox Series GDK titles that GAME: names the game
// folder and that writes go to a writable overlay rather than to the package, which is read-only. gta6rt does the
// same:
// GAME:<rest> a read opens the overlay copy when one exists, else <game dir>\<rest>;
// an open that can write opens <overlay dir>\<rest>, copying the package file there first when the
// disposition keeps its contents, so the package is never modified;
// a delete leaves a marker in the overlay instead of removing a package file.
// anything else is a host path and is passed through unchanged.
// A GAME: path that climbs above the root with ".." or names another drive is refused with ERROR_INVALID_NAME.
//
// The shims that use this live in file_system.cpp: CreateFile*, FindFirstFile*/FindNextFile*/FindClose,
// GetFileAttributes*/GetFileAttributesEx* and DeleteFile*.
#pragma once
#include <filesystem>
namespace rt::fs {
// Sets the roots. main.cpp calls this once, before anything is mapped; the test calls it per case. The overlay is
// created on the first write, not here.
void configure(const std::filesystem::path& game_dir, const std::filesystem::path& overlay_dir);
std::filesystem::path game_dir();
std::filesystem::path overlay_dir();
} // namespace rt::fs