Skip to content

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

Done

Description

@Conrage

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.

Activity

  1. ivall commented on Nov 24, 2026

    @ivall
    Collaborator

    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 up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions