# windows.DeleteFile: Use FileDispositionInformationEx if possible, but fallback if not · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/1ae378e7a253ec845d8ee8d52b5505c9aa177369)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: 1ae378e7a253ec845d8ee8d52b5505c9aa177369

Requested commit: 1ae378e7a253ec845d8ee8d52b5505c9aa177369

Commit: 1ae378e7a253ec845d8ee8d52b5505c9aa177369

Tree: 9870995f852bef3b240fd3375edfdecdba1eb855

Author: Ryan Liptak

Committer: Ryan Liptak

## Message

```
windows.DeleteFile: Use FileDispositionInformationEx if possible, but fallback if not

Using FileDispositionInformationEx (and therefore flags like FILE_DISPOSITION_POSIX_SEMANTICS and FILE_DISPOSITION_IGNORE_READONLY_ATTRIBUTE) is only supported on NTFS, so the comptime Windows version range check is not enough to determine whether or not the NtSetInformationFile will succeed.

This commit makes DeleteFile always try using FileDispositionInformationEx first, but if INVALID_PARAMETER is received (which is the status that occurs when the filesystem doesn't support FileDispositionInformationEx), then it will fallback and try calling NtSetInformationFile with FileDispositionInformation.

This keeps NTFS as fast as it was before, since it will do at most 1 NtSetInformationFile call, but on non-NTFS filesystems (e.g. FAT32), DeleteFile may need to do 2 NtSetInformationFile calls.

Closes #16497

```

## Parents

- [1bf16b1723445ba307ca556dc050d6d13bb0ebff](https://git.cafe/gitcafe/zig/commit/1bf16b1723445ba307ca556dc050d6d13bb0ebff?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/1ae378e7a253ec845d8ee8d52b5505c9aa177369?format=markdown)
