Skip to content

Recursively delete directories on Windows without race conditions #110

Open
@Rufflewind

Description

Niall Douglas' "Racing the File System" at CppCon actually outlines a deletion algorithm that works correctly on Windows. It does not require retries.

The gist of it:

  • Deletion is effectively asynchronous on Windows.
  • If deleting recursively, you want to rename the item you're deleting out of the directory you're deleting first, then delete it.

This provides an alternative solution to the issue described in #96 and #108.

Alternative

It seems there's yet another way to do this using Windows 10 V1607's POSIX-compatible API:

SetFileInformationByHandle(FILE_DISPOSITION_INFO_EX { FILE_DISPOSITION_DELETE | FILE_DISPOSITION_POSIX_SEMANTICS })

But this is limited to NTFS.

https://stackoverflow.com/a/50234974

Metadata

Assignees

No one assigned

    Labels

    type: a-bugThe described behavior is not working as intended.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions