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(
27702770 .SUCCESS => return,
27712771 // INVALID_PARAMETER here means that the filesystem does not support FileRenameInformationEx
27722772 .INVALID_PARAMETER => {},
2773 .DIRECTORY_NOT_EMPTY => return error.PathAlreadyExists,
2774 .FILE_IS_A_DIRECTORY => return error.IsDir,
2775 .NOT_A_DIRECTORY => return error.NotDir,
27762773 // For all other statuses, fall down to the switch below to handle them.
27772774 else => need_fallback = false,
27782775 }
......@@ -2815,6 +2812,9 @@ pub fn renameatW(
28152812 .OBJECT_PATH_NOT_FOUND => return error.FileNotFound,
28162813 .NOT_SAME_DEVICE => return error.RenameAcrossMountPoints,
28172814 .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,
28182818 else => return windows.unexpectedStatus(rc),
28192819 }
28202820}