| ... | @@ -940,8 +940,13 @@ pub fn DeleteFile(sub_path_w: []const u16, options: DeleteFileOptions) DeleteFil | ... | @@ -940,8 +940,13 @@ pub fn DeleteFile(sub_path_w: []const u16, options: DeleteFileOptions) DeleteFil |
| 940 | } | 940 | } |
| 941 | defer CloseHandle(tmp_handle); | 941 | defer CloseHandle(tmp_handle); |
| 942 | | 942 | |
| | 943 | // FileDispositionInformationEx (and therefore FILE_DISPOSITION_POSIX_SEMANTICS and FILE_DISPOSITION_IGNORE_READONLY_ATTRIBUTE) |
| | 944 | // are only supported on NTFS filesystems, so the version check on its own is only a partial solution. To support non-NTFS filesystems |
| | 945 | // like FAT32, we need to fallback to FileDispositionInformation if the usage of FileDispositionInformationEx gives |
| | 946 | // us INVALID_PARAMETER. |
| | 947 | var need_fallback = true; |
| 943 | if (comptime builtin.target.os.version_range.windows.min.isAtLeast(.win10_rs1)) { | 948 | if (comptime builtin.target.os.version_range.windows.min.isAtLeast(.win10_rs1)) { |
| 944 | // Deletion with posix semantics. | 949 | // Deletion with posix semantics if the filesystem supports it. |
| 945 | var info = FILE_DISPOSITION_INFORMATION_EX{ | 950 | var info = FILE_DISPOSITION_INFORMATION_EX{ |
| 946 | .Flags = FILE_DISPOSITION_DELETE | | 951 | .Flags = FILE_DISPOSITION_DELETE | |
| 947 | FILE_DISPOSITION_POSIX_SEMANTICS | | 952 | FILE_DISPOSITION_POSIX_SEMANTICS | |
| ... | @@ -955,7 +960,14 @@ pub fn DeleteFile(sub_path_w: []const u16, options: DeleteFileOptions) DeleteFil | ... | @@ -955,7 +960,14 @@ pub fn DeleteFile(sub_path_w: []const u16, options: DeleteFileOptions) DeleteFil |
| 955 | @sizeOf(FILE_DISPOSITION_INFORMATION_EX), | 960 | @sizeOf(FILE_DISPOSITION_INFORMATION_EX), |
| 956 | .FileDispositionInformationEx, | 961 | .FileDispositionInformationEx, |
| 957 | ); | 962 | ); |
| 958 | } else { | 963 | switch (rc) { |
| | 964 | // INVALID_PARAMETER here means that the filesystem does not support FileDispositionInformationEx |
| | 965 | .INVALID_PARAMETER => {}, |
| | 966 | // For all other statuses, fall down to the switch below to handle them. |
| | 967 | else => need_fallback = false, |
| | 968 | } |
| | 969 | } |
| | 970 | if (need_fallback) { |
| 959 | // Deletion with file pending semantics, which requires waiting or moving | 971 | // Deletion with file pending semantics, which requires waiting or moving |
| 960 | // files to get them removed (from here). | 972 | // files to get them removed (from here). |
| 961 | var file_dispo = FILE_DISPOSITION_INFORMATION{ | 973 | var file_dispo = FILE_DISPOSITION_INFORMATION{ |