authorgravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2024-04-29 02:59:52-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-06-13 10:50:46-04:00
log8e155959ca95abbc243e276fa8596964f2fed3b2
treec61b2f0dda8c011275beed00b1ff0a80589091f6
parent45c77931c2f292574c0049cab574b0208914b9b9

posix.renameW: Handle DIRECTORY_NOT_EMPTY more generally

Before this commit, the DIRECTORY_NOT_EMPTY/FILE_IS_A_DIRECTORY/NOT_A_DIRECTORY statuses were assumed only to be possible when using `FILE_RENAME_INFORMATION_EX` and `FILE_RENAME_POSIX_SEMANTICS`, but that has empirically been shown to be false; a networked samba share can return the DIRECTORY_NOT_EMPTY status from `FILE_RENAME_INFORMATION` (which doesn't support `FILE_RENAME_POSIX_SEMANTICS`). `FILE_IS_A_DIRECTORY` and `NOT_A_DIRECTORY` were not proven to be possible, but they were also moved to the outer switch just in case. Fixes #19785

1 files changed, 3 insertions(+), 3 deletions(-)

lib/std/posix.zig+3-3
...@@ -2770,9 +2770,6 @@ pub fn renameatW(...@@ -2770,9 +2770,6 @@ pub fn renameatW(
2770 .SUCCESS => return,2770 .SUCCESS => return,
2771 // INVALID_PARAMETER here means that the filesystem does not support FileRenameInformationEx2771 // INVALID_PARAMETER here means that the filesystem does not support FileRenameInformationEx
2772 .INVALID_PARAMETER => {},2772 .INVALID_PARAMETER => {},
2773 .DIRECTORY_NOT_EMPTY => return error.PathAlreadyExists,
2774 .FILE_IS_A_DIRECTORY => return error.IsDir,
2775 .NOT_A_DIRECTORY => return error.NotDir,
2776 // For all other statuses, fall down to the switch below to handle them.2773 // For all other statuses, fall down to the switch below to handle them.
2777 else => need_fallback = false,2774 else => need_fallback = false,
2778 }2775 }
...@@ -2815,6 +2812,9 @@ pub fn renameatW(...@@ -2815,6 +2812,9 @@ pub fn renameatW(
2815 .OBJECT_PATH_NOT_FOUND => return error.FileNotFound,2812 .OBJECT_PATH_NOT_FOUND => return error.FileNotFound,
2816 .NOT_SAME_DEVICE => return error.RenameAcrossMountPoints,2813 .NOT_SAME_DEVICE => return error.RenameAcrossMountPoints,
2817 .OBJECT_NAME_COLLISION => return error.PathAlreadyExists,2814 .OBJECT_NAME_COLLISION => return error.PathAlreadyExists,
2815 .DIRECTORY_NOT_EMPTY => return error.PathAlreadyExists,
2816 .FILE_IS_A_DIRECTORY => return error.IsDir,
2817 .NOT_A_DIRECTORY => return error.NotDir,
2818 else => return windows.unexpectedStatus(rc),2818 else => return windows.unexpectedStatus(rc),
2819 }2819 }
2820}2820}