From 46551d006f809d2ef2b610628aed380a62668f25 Mon Sep 17 00:00:00 2001 From: Amine Khaldi Date: Fri, 31 Oct 2014 18:46:27 +0000 Subject: [PATCH] [SHELL32] * Apply Wine commit a2c90524 by Aric Stewart: Improve the FO_MOVE operation. * More shell32:shlfileop tests run, less fail. CORE-8540 svn path=/trunk/; revision=65159 --- reactos/dll/win32/shell32/shlfileop.cpp | 41 ++++++++++++++++++------- reactos/dll/win32/shell32/undocshell.h | 3 +- 2 files changed, 32 insertions(+), 12 deletions(-) diff --git a/reactos/dll/win32/shell32/shlfileop.cpp b/reactos/dll/win32/shell32/shlfileop.cpp index 6b28406066d..b036ccd2c82 100644 --- a/reactos/dll/win32/shell32/shlfileop.cpp +++ b/reactos/dll/win32/shell32/shlfileop.cpp @@ -1559,14 +1559,18 @@ static void move_to_dir(LPSHFILEOPSTRUCTW lpFileOp, const FILE_ENTRY *feFrom, co } /* the FO_MOVE operation */ -static HRESULT move_files(LPSHFILEOPSTRUCTW lpFileOp, const FILE_LIST *flFrom, const FILE_LIST *flTo) +static DWORD move_files(LPSHFILEOPSTRUCTW lpFileOp, const FILE_LIST *flFrom, const FILE_LIST *flTo) { DWORD i; + INT mismatched = 0; const FILE_ENTRY *entryToMove; const FILE_ENTRY *fileDest; - if (!flFrom->dwNumFiles || !flTo->dwNumFiles) - return ERROR_CANCELLED; + if (!flFrom->dwNumFiles) + return ERROR_SUCCESS; + + if (!flTo->dwNumFiles) + return ERROR_FILE_NOT_FOUND; if (!(lpFileOp->fFlags & FOF_MULTIDESTFILES) && flTo->dwNumFiles > 1 && flFrom->dwNumFiles > 1) @@ -1584,29 +1588,44 @@ static HRESULT move_files(LPSHFILEOPSTRUCTW lpFileOp, const FILE_LIST *flFrom, c if (!PathFileExistsW(flTo->feFiles[0].szDirectory)) return ERROR_CANCELLED; - if ((lpFileOp->fFlags & FOF_MULTIDESTFILES) && - flFrom->dwNumFiles != flTo->dwNumFiles) - { - return ERROR_CANCELLED; - } + if (lpFileOp->fFlags & FOF_MULTIDESTFILES) + mismatched = flFrom->dwNumFiles - flTo->dwNumFiles; fileDest = &flTo->feFiles[0]; for (i = 0; i < flFrom->dwNumFiles; i++) { entryToMove = &flFrom->feFiles[i]; - if (lpFileOp->fFlags & FOF_MULTIDESTFILES) - fileDest = &flTo->feFiles[i]; - if (!PathFileExistsW(fileDest->szDirectory)) return ERROR_CANCELLED; + if (lpFileOp->fFlags & FOF_MULTIDESTFILES) + { + if (i >= flTo->dwNumFiles) + break; + fileDest = &flTo->feFiles[i]; + if (mismatched && !fileDest->bExists) + { + create_dest_dirs(flTo->feFiles[i].szFullPath); + flTo->feFiles[i].bExists = TRUE; + flTo->feFiles[i].attributes = FILE_ATTRIBUTE_DIRECTORY; + } + } + if (fileDest->bExists && IsAttribDir(fileDest->attributes)) move_to_dir(lpFileOp, entryToMove, fileDest); else SHNotifyMoveFileW(entryToMove->szFullPath, fileDest->szFullPath, IsAttribDir(entryToMove->attributes)); } + if (mismatched > 0) + { + if (flFrom->bAnyDirectories) + return DE_DESTSAMETREE; + else + return DE_SAMEFILE; + } + return ERROR_SUCCESS; } diff --git a/reactos/dll/win32/shell32/undocshell.h b/reactos/dll/win32/shell32/undocshell.h index 043b8f49cd9..9c5d63bcd85 100644 --- a/reactos/dll/win32/shell32/undocshell.h +++ b/reactos/dll/win32/shell32/undocshell.h @@ -83,7 +83,8 @@ BOOL WINAPI StrRetToStrNW(LPWSTR,DWORD,LPSTRRET,const ITEMIDLIST*); #define RFF_NOLABEL 0x08 #define RFF_NOSEPARATEMEM 0x20 /* NT only */ -#define DE_SAMEFILE 0x71 +#define DE_SAMEFILE 0x71 +#define DE_DESTSAMETREE 0x7D /* RunFileFlg notification structure */ typedef struct