file_system: a move onto an existing GAME: folder reports ERROR_ALREADY_EXISTS (FS-MOVE-ONTO-FOLDER) #2375

Closed
syfyra wants to merge 1 commit from upstream-pr/2375 into main
syfyra commented 2026-11-26 16:27:44 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by syfyra on 2026-11-26T16:27:44Z.


Claimed in the coordination issue as: FS-MOVE-ONTO-FOLDER

What and why

MoveFileExW on console paths refused a move onto an existing folder with ERROR_ACCESS_DENIED, whatever the flags. The host only does that with MOVEFILE_REPLACE_EXISTING. Without it, any existing destination, a folder included, is "already there". Measured on Windows 11 with a small probe on an NTFS temp folder:

source → destination flags 0 or COPY_ALLOWED REPLACE_EXISTING (with or without COPY_ALLOWED)
file → empty folder 183 ERROR_ALREADY_EXISTS 5 ERROR_ACCESS_DENIED
file → non-empty folder 183 5
folder → folder (empty or not) 183 5
file → file 183 succeeds

A title that checks for ERROR_ALREADY_EXISTS to clear the way first and move again got ERROR_ACCESS_DENIED instead. MoveFileW, which passes no replace flag, has the same problem.

The shim now reports any existing destination as ERROR_ALREADY_EXISTS when MOVEFILE_REPLACE_EXISTING is not set, and a folder as ERROR_ACCESS_DENIED when it is. Nothing else changes. One case still differs from the host, as before this change: the host lets MOVEFILE_REPLACE_EXISTING move a folder over an existing file, and the shim keeps refusing that with ERROR_ACCESS_DENIED.

Tested

Windows 11, MSVC 14.44 (Build Tools), RelWithDebInfo:

  • file_system_test gets checks in its MoveFile block. A package file is moved onto a package folder (GAME:\data\sub) and onto an overlay folder (GAME:\cache\renamed) with MoveFileExW(0), MoveFileW and MoveFileExW(MOVEFILE_REPLACE_EXISTING), then an overlay folder onto a package folder. The checks confirm that the file and the folder stay where they were.
    • main: 5 of the new checks fail (each one that expects ERROR_ALREADY_EXISTS).
    • this branch: 546 of 546 pass.
  • Merges without new conflicts against the 18 open pull requests that change file_system.cpp or its test (checked with scripts/pr_overlap.py from #2349). The six it lists as conflicting already conflict with main, and none of them touches these lines.
  • scripts/check_no_game_data.py on both files.

Not tested under Wine.

GPUs tested: n/a (CPU tests)

AI-assisted: yes (Claude Code, Claude Opus 5.5)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator change)

🤖 Generated with Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5513666871 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2375). Originally posted by [syfyra](https://github.com/syfyra) on 2026-11-26T16:27:44Z. --- Claimed in the coordination issue as: FS-MOVE-ONTO-FOLDER ### What and why `MoveFileExW` on console paths refused a move onto an existing folder with `ERROR_ACCESS_DENIED`, whatever the flags. The host only does that with `MOVEFILE_REPLACE_EXISTING`. Without it, any existing destination, a folder included, is "already there". Measured on Windows 11 with a small probe on an NTFS temp folder: | source → destination | flags 0 or `COPY_ALLOWED` | `REPLACE_EXISTING` (with or without `COPY_ALLOWED`) | |---|---|---| | file → empty folder | 183 `ERROR_ALREADY_EXISTS` | 5 `ERROR_ACCESS_DENIED` | | file → non-empty folder | 183 | 5 | | folder → folder (empty or not) | 183 | 5 | | file → file | 183 | succeeds | A title that checks for `ERROR_ALREADY_EXISTS` to clear the way first and move again got `ERROR_ACCESS_DENIED` instead. `MoveFileW`, which passes no replace flag, has the same problem. The shim now reports any existing destination as `ERROR_ALREADY_EXISTS` when `MOVEFILE_REPLACE_EXISTING` is not set, and a folder as `ERROR_ACCESS_DENIED` when it is. Nothing else changes. One case still differs from the host, as before this change: the host lets `MOVEFILE_REPLACE_EXISTING` move a folder over an existing file, and the shim keeps refusing that with `ERROR_ACCESS_DENIED`. ### Tested Windows 11, MSVC 14.44 (Build Tools), RelWithDebInfo: - `file_system_test` gets checks in its MoveFile block. A package file is moved onto a package folder (`GAME:\data\sub`) and onto an overlay folder (`GAME:\cache\renamed`) with `MoveFileExW(0)`, `MoveFileW` and `MoveFileExW(MOVEFILE_REPLACE_EXISTING)`, then an overlay folder onto a package folder. The checks confirm that the file and the folder stay where they were. - `main`: 5 of the new checks fail (each one that expects `ERROR_ALREADY_EXISTS`). - this branch: 546 of 546 pass. - Merges without new conflicts against the 18 open pull requests that change `file_system.cpp` or its test (checked with `scripts/pr_overlap.py` from #2349). The six it lists as conflicting already conflict with `main`, and none of them touches these lines. - `scripts/check_no_game_data.py` on both files. Not tested under Wine. GPUs tested: n/a (CPU tests) AI-assisted: yes (Claude Code, Claude Opus 5.5) ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a: no translator change) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
fiestorra commented 2026-11-30 11:05:05 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-11-30T11:05:05Z.


Independent verification on this machine (Windows 11, MSVC 19.44.35226), with a negative control that bites on two assertions.

1. It applies. merge-tree clean; the commits cherry-pick onto main d367675c7 without a conflict. Two files: runtime/shims/file_system.cpp and its test.

2. With the branch its test passes:

ctest -R 'file_system'
100% tests passed, 0 tests failed out of 1

3. The control - revert only the shim, keep the test:

git checkout origin/main -- runtime/shims/file_system.cpp
cmake --build … --target file_system_test
ctest -R 'file_system' --output-on-failure
0% tests passed, 1 tests failed out of 1
FAIL MoveFileExW of a file onto GAME:\data\sub reports ERROR_ALREADY_EXISTS
FAIL MoveFileW   of a file onto GAME:\data\sub reports ERROR_ALREADY_EXISTS

Both failures name the rule the change adds: moving a file onto an existing directory (GAME:\data\sub) must fail with ERROR_ALREADY_EXISTS, on both the ExW and the plain W entry point. main's shim lets one or both through.

One thing I noticed and did not judge: the assertion text uses GAME:\ as a root, which is the shim's own virtual root rather than a host path - so the check exercises the shim's path handling, not a real disk. That is consistent with the file being a shim test, and I have not checked that the error mapping matches what the console's file system actually returns for that case.

Why I am commenting: I verify open pull requests that replay onto current main, build the binaries their tests name in ctest --show-only=json-v1, run them, and then revert only the source change. 23 controls so far: 16 bite.

Written with an AI assistant.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7276511816 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2375#issuecomment-7276511816). Originally posted by [fiestorra](https://github.com/fiestorra) on 2026-11-30T11:05:05Z. --- Independent verification on this machine (Windows 11, MSVC 19.44.35226), with a negative control that bites on two assertions. **1. It applies.** `merge-tree` clean; the commits cherry-pick onto `main` `d367675c7` without a conflict. Two files: `runtime/shims/file_system.cpp` and its test. **2. With the branch its test passes:** ``` ctest -R 'file_system' 100% tests passed, 0 tests failed out of 1 ``` **3. The control - revert only the shim, keep the test:** ``` git checkout origin/main -- runtime/shims/file_system.cpp cmake --build … --target file_system_test ctest -R 'file_system' --output-on-failure 0% tests passed, 1 tests failed out of 1 FAIL MoveFileExW of a file onto GAME:\data\sub reports ERROR_ALREADY_EXISTS FAIL MoveFileW of a file onto GAME:\data\sub reports ERROR_ALREADY_EXISTS ``` **Both failures name the rule the change adds**: moving a **file** onto an existing **directory** (`GAME:\data\sub`) must fail with `ERROR_ALREADY_EXISTS`, on both the `ExW` and the plain `W` entry point. `main`'s shim lets one or both through. **One thing I noticed and did not judge:** the assertion text uses **`GAME:\`** as a root, which is the shim's own virtual root rather than a host path - so the check exercises the shim's path handling, not a real disk. **That is consistent with the file being a shim test, and I have not checked that the error mapping matches what the console's file system actually returns for that case.** **Why I am commenting:** I verify open pull requests that replay onto current `main`, build the binaries their tests name in `ctest --show-only=json-v1`, run them, and then revert **only** the source change. **23 controls so far: 16 bite.** Written with an AI assistant.
aslan2142 commented 2026-12-01 12:33:24 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T12:33:24Z.


Marking Ready for Review since no WIP/blocker reason for draft status is specified on this PR, so it can enter normal CI and review.

(AI-assisted triage.)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7311307631 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2375#issuecomment-7311307631). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T12:33:24Z. --- Marking Ready for Review since no WIP/blocker reason for draft status is specified on this PR, so it can enter normal CI and review. *(AI-assisted triage.)*
aslan2142 commented 2026-12-01 16:44:23 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T16:44:23Z.


Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (d3d12/) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, d3d12/, or general docs), please feel free to reopen it.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7318135942 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2375#issuecomment-7318135942). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T16:44:23Z. --- Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (`d3d12/`) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, `d3d12/`, or general docs), please feel free to reopen it.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!2375
No description provided.