From 0d1b044436f67e20af9b134aee1df4889e442a82 Mon Sep 17 00:00:00 2001 From: ljh0121 Date: Tue, 20 May 2025 16:56:02 +0900 Subject: [PATCH] fix: [channel,drive] Fix failure when renaming non-empty directories --- channels/drive/client/drive_file.c | 5 ++++- channels/drive/client/drive_main.c | 7 ++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/channels/drive/client/drive_file.c b/channels/drive/client/drive_file.c index 1689f20bb..9d79e89e4 100644 --- a/channels/drive/client/drive_file.c +++ b/channels/drive/client/drive_file.c @@ -755,7 +755,10 @@ BOOL drive_file_set_information(DRIVE_FILE* file, UINT32 FsInformationClass, UIN /* http://msdn.microsoft.com/en-us/library/cc232098.aspx */ /* http://msdn.microsoft.com/en-us/library/cc241371.aspx */ if (file->is_dir && !PathIsDirectoryEmptyW(file->fullpath)) - break; /* TODO: SetLastError ??? */ + { + SetLastError(ERROR_DIR_NOT_EMPTY); + return FALSE; + } if (Length) { diff --git a/channels/drive/client/drive_main.c b/channels/drive/client/drive_main.c index 304ec91fe..70daacb8d 100644 --- a/channels/drive/client/drive_main.c +++ b/channels/drive/client/drive_main.c @@ -122,6 +122,10 @@ static NTSTATUS drive_map_windows_err(DWORD fs_errno) rc = STATUS_OBJECT_PATH_NOT_FOUND; break; + case ERROR_DIR_NOT_EMPTY: + rc = STATUS_DIRECTORY_NOT_EMPTY; + break; + default: rc = STATUS_UNSUCCESSFUL; WLog_ERR(TAG, "Error code not found: %" PRIu32 "", fs_errno); @@ -436,9 +440,6 @@ static UINT drive_process_irp_set_information(DRIVE_DEVICE* drive, IRP* irp) irp->IoStatus = drive_map_windows_err(GetLastError()); } - if (file && file->is_dir && !PathIsDirectoryEmptyW(file->fullpath)) - irp->IoStatus = STATUS_DIRECTORY_NOT_EMPTY; - Stream_Write_UINT32(irp->output, Length); WINPR_ASSERT(irp->Complete);