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

Open
opened 2026-11-26 21:21:02 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/2375
Author: @syfyra
Created: 11/26/2026
Status: 🔄 Open

Base: main ← Head: fix/fs-move-onto-folder


📝 Commits (1)

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

📊 Changes

2 files changed (+28 additions, -1 deletions)

View changed files

📝 runtime/shims/file_system.cpp (+3 -1)
📝 runtime/test/file_system_test.cpp (+25 -0)

📄 Description

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


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/2375 **Author:** [@syfyra](https://github.com/syfyra) **Created:** 11/26/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/fs-move-onto-folder` --- ### 📝 Commits (1) - [`cea424f`](https://github.com/ubiquitarianism/leonida/commit/cea424f3573900e973732f726161a901a1d666de) file_system: a move onto an existing GAME: folder reports ERROR_ALREADY_EXISTS (FS-MOVE-ONTO-FOLDER) ### 📊 Changes **2 files changed** (+28 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `runtime/shims/file_system.cpp` (+3 -1) 📝 `runtime/test/file_system_test.cpp` (+25 -0) </details> ### 📄 Description 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) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#2377
No description provided.