Skip to content

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

Draft
syfyra wants to merge 1 commit into
ProjectLeonida:mainfrom
syfyra:fix/fs-move-onto-folder
Draft

syfyra wants to merge 1 commit into
ProjectLeonida:mainfrom
syfyra:fix/fs-move-onto-folder

Conversation

@syfyra

@syfyra syfyra commented Nov 26, 2026

Copy link
Copy Markdown

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 scripts: pr_overlap.py lists the open pull requests that change the same files (PR-OVERLAP-CHECK) #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

…DY_EXISTS (FS-MOVE-ONTO-FOLDER)

MoveFileEx onto a folder failed with ERROR_ACCESS_DENIED whatever the
flags. The host reports any existing destination, a folder too, as
ERROR_ALREADY_EXISTS without MOVEFILE_REPLACE_EXISTING, and
ERROR_ACCESS_DENIED only with it (measured on Windows 11 for a file and
a folder source, onto an empty and a non-empty folder). A title that
checks for ERROR_ALREADY_EXISTS to decide to clear the way first now
gets it. MoveFileW, which passes no replace flag, follows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant