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

Closed
opened 2026-11-26 04:39:52 +00:00 by github-bot · 1 comment
Owner

@⁠Conrage on GitHub · 2026-11-24 10:06 UTC · original

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.

**@⁠Conrage** on GitHub · 2026-11-24 10:06 UTC · [original](https://github.com/xcl-dev/xcl/issues/997) `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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:39:52 +00:00
Author
Owner

@⁠ivall on GitHub · 2026-11-24 11:04 UTC · original

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.

**@⁠ivall** on GitHub · 2026-11-24 11:04 UTC · [original](https://github.com/xcl-dev/xcl/issues/997#issuecomment-7129625720) 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.
This discussion has been locked. Commenting is limited to contributors.
No description provided.