// 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: a read opens the overlay copy when one exists, else \; // an open that can write opens \, 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*, DeleteFile*, CreateDirectory*/RemoveDirectory*, MoveFile*/MoveFileEx*, // CopyFile*/CopyFileEx*/CopyFile2 and SetFileAttributes* (the rules for each are in docs/runtime_imports.md). #pragma once #include namespace rt::fs { inline constexpr wchar_t kPersistentStorageDir[] = L".gta6rt-persistent"; // 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(); // The folder "T:\" names in this process: \.gta6rt-temp\, or -2, -3, ... when that name was // taken (scratch_stem(), reserve_unique_dir). Reserved on the first T: call or the first call of this function for the // overlay and kept for the rest of the process; empty while no overlay is configured or when no folder could be made. std::filesystem::path scratch_dir(); // The first name tried for that folder: the process's start time (UTC) and id, "YYYYMMDD-HHMMSS-mmm-pid". std::wstring scratch_stem(); // Makes a new folder base\stem, or base\stem-2 ... base\stem- when the names before it exist, each with a // create-only CreateDirectoryW, so the folder returned did not exist before and no other process got it. Makes `base` // first. Returns an empty path, with the Win32 error in `error`, when every name was taken (ERROR_ALREADY_EXISTS) or // a create failed for another reason. std::filesystem::path reserve_unique_dir(const std::filesystem::path& base, const std::wstring& stem, unsigned long& error, unsigned max_tries = 1000); // For tests: true makes the CopyFile2 shim use its CopyFileExW fallback even where the host has CopyFile2, so the // path Wine 9 takes can be checked on Windows. Off by default; main.cpp never sets it. void force_copy_file2_fallback(bool force); } // namespace rt::fs