VFS: RemoveDirectoryW on a non-empty game folder succeeds and hides the folder in every later run #991

Closed
opened 2026-11-24 10:06:38 +00:00 by Conrage · 1 comment
Conrage commented 2026-11-24 10:06:38 +00:00 (Migrated from github.com)
Contributor

Imported from ivall/xcl. Originally posted by Conrage on 2026-11-24T10:06:38Z.


RemoveDirectoryW on a game path goes to Vfs::remove_dir, which never checks that the merged directory is empty:

github.com/ivall/xcl@9aec53d/crates/xcl/src/vfs.rs (L635-L662)

  • If the folder exists only in the game files, it adds a whiteout straight away.
  • If the overlay has a folder of that name, it removes the overlay folder (which fails only if the overlay copy has files), then whites out the game folder. The game files under it are never looked at.

On Windows, RemoveDirectoryW on a non-empty directory fails with ERROR_DIR_NOT_EMPTY (145). Under XCL it returns success and the whole subtree disappears from the title's view. Whiteouts are saved to overlay\.xcl_whiteouts and loaded on start, so the folder stays hidden in every later run until the overlay is cleared.

The repo's own test already shows the behaviour (directories in vfs.rs, line 852): the fixture's data folder holds hello.txt and gone.txt, and remove_dir("data") returns Ok(()).

Why it matters: "remove the folder if it's empty" is a common cleanup pattern: call RemoveDirectoryW on each folder and ignore the failure. A title doing that over its install folder would lose game data folders permanently under XCL.

Expected: remove_dir returns ERROR_DIR_NOT_EMPTY when the merged view of the folder (overlay entries plus game entries that aren't whited out) has any entry. It only whites out an empty folder.

Suggested fix: in remove_dir, list the merged directory (as FindFirstFile already does for listings) and refuse when it isn't empty. Adjust the directories test to match Win32.

Not tested: found by reading the code and the existing unit test; not run (no Windows machine).

AI use: found, checked and written up by Claude Code (Claude Opus 5.5) at my request.

<!-- greyfinch-sync:ivall/xcl:issue:6579363849 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/issues/997). Originally posted by [Conrage](https://github.com/Conrage) on 2026-11-24T10:06:38Z. --- `RemoveDirectoryW` on a game path goes to `Vfs::remove_dir`, which never checks that the merged directory is empty: https://github.com/ivall/xcl/blob/9aec53d/crates/xcl/src/vfs.rs#L635-L662 - If the folder exists only in the game files, it adds a whiteout straight away. - If the overlay has a folder of that name, it removes the overlay folder (which fails only if the *overlay* copy has files), then whites out the game folder. The game files under it are never looked at. On Windows, `RemoveDirectoryW` on a non-empty directory fails with `ERROR_DIR_NOT_EMPTY` (145). Under XCL it returns success and the whole subtree disappears from the title's view. Whiteouts are saved to `overlay\.xcl_whiteouts` and loaded on start, so the folder stays hidden in every later run until the overlay is cleared. The repo's own test already shows the behaviour (`directories` in `vfs.rs`, line 852): the fixture's `data` folder holds `hello.txt` and `gone.txt`, and `remove_dir("data")` returns `Ok(())`. **Why it matters:** "remove the folder if it's empty" is a common cleanup pattern: call `RemoveDirectoryW` on each folder and ignore the failure. A title doing that over its install folder would lose game data folders permanently under XCL. **Expected:** `remove_dir` returns `ERROR_DIR_NOT_EMPTY` when the merged view of the folder (overlay entries plus game entries that aren't whited out) has any entry. It only whites out an empty folder. **Suggested fix:** in `remove_dir`, list the merged directory (as `FindFirstFile` already does for listings) and refuse when it isn't empty. Adjust the `directories` test to match Win32. **Not tested:** found by reading the code and the existing unit test; not run (no Windows machine). **AI use:** found, checked and written up by Claude Code (Claude Opus 5.5) at my request.
ivall commented 2026-11-24 11:06:04 +00:00 (Migrated from github.com)
Author
Contributor

Imported from ivall/xcl. Originally posted by ivall on 2026-11-24T11:04:43Z.


Fixed by #1016 (47efa2e): RemoveDirectoryW on a game folder fails with ERROR_DIR_NOT_EMPTY while its merged view has visible entries, and the overlay is left as it was.

<!-- greyfinch-sync:ivall/xcl:comment:7129625720 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/issues/997#issuecomment-7129625720). Originally posted by [ivall](https://github.com/ivall) on 2026-11-24T11:04:43Z. --- Fixed by #1016 (47efa2e): `RemoveDirectoryW` on a game folder fails with `ERROR_DIR_NOT_EMPTY` while its merged view has visible entries, and the overlay is left as it was.
Sign in to join this conversation.
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
xcl-dev/xcl#991
No description provided.