https://git.reactos.org/?p=reactos.git;a=commitdiff;h=c65156002c184222e8307e...
commit c65156002c184222e8307e0299ece359809db4dc Author: Katayama Hirofumi MZ katayama.hirofumi.mz@gmail.com AuthorDate: Mon Apr 8 21:59:33 2019 +0900 Commit: GitHub noreply@github.com CommitDate: Mon Apr 8 21:59:33 2019 +0900
[SHELL32] Fix SHFileOperation Move operation (#1487)
Reduce failures of Move operation of shell32!SHFileOperation function. CORE-13450 --- dll/win32/shell32/shlfileop.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/dll/win32/shell32/shlfileop.cpp b/dll/win32/shell32/shlfileop.cpp index 63486989db1..211b3311c7b 100644 --- a/dll/win32/shell32/shlfileop.cpp +++ b/dll/win32/shell32/shlfileop.cpp @@ -5,6 +5,7 @@ * Copyright 2002 Andriy Palamarchuk * Copyright 2004 Dietrich Teickner (from Odin) * Copyright 2004 Rolf Kalbermatter + * Copyright 2019 Katayama Hirofumi MZ katayama.hirofumi.mz@gmail.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -1064,11 +1065,15 @@ static void add_file_to_entry(FILE_ENTRY *feFile, LPCWSTR szFile) { DWORD dwLen = lstrlenW(szFile) + 1; LPCWSTR ptr; + LPCWSTR ptr2;
feFile->szFullPath = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, dwLen * sizeof(WCHAR)); lstrcpyW(feFile->szFullPath, szFile);
ptr = StrRChrW(szFile, NULL, '\'); + ptr2 = StrRChrW(szFile, NULL, '/'); + if (!ptr || ptr < ptr2) + ptr = ptr2; if (ptr) { dwLen = ptr - szFile + 1; @@ -1085,10 +1090,14 @@ static void add_file_to_entry(FILE_ENTRY *feFile, LPCWSTR szFile) static LPWSTR wildcard_to_file(LPCWSTR szWildCard, LPCWSTR szFileName) { LPCWSTR ptr; + LPCWSTR ptr2; LPWSTR szFullPath; DWORD dwDirLen, dwFullLen;
ptr = StrRChrW(szWildCard, NULL, '\'); + ptr2 = StrRChrW(szWildCard, NULL, '/'); + if (!ptr || ptr < ptr2) + ptr = ptr2; dwDirLen = ptr - szWildCard + 1;
dwFullLen = dwDirLen + lstrlenW(szFileName) + 1; @@ -1630,6 +1639,9 @@ static void move_dir_to_dir(FILE_OPERATION *op, const FILE_ENTRY *feFrom, LPCWST
destroy_file_list(&flFromNew); destroy_file_list(&flToNew); + + if (PathIsDirectoryEmptyW(feFrom->szFullPath)) + Win32RemoveDirectoryW(feFrom->szFullPath); }
/* moves a file or directory to another directory */ @@ -1668,7 +1680,8 @@ static DWORD move_files(FILE_OPERATION *op, BOOL multiDest, const FILE_LIST *flF
if (!(multiDest) && !flFrom->bAnyDirectories && - flFrom->dwNumFiles > flTo->dwNumFiles) + flFrom->dwNumFiles > flTo->dwNumFiles && + !(flTo->bAnyDirectories && flTo->dwNumFiles == 1)) { return ERROR_CANCELLED; } @@ -1779,6 +1792,7 @@ int WINAPI SHFileOperationW(LPSHFILEOPSTRUCTW lpFileOp) if (FAILED(ret)) return ret;
+ lpFileOp->fAnyOperationsAborted = FALSE; check_flags(lpFileOp->fFlags);
ZeroMemory(&flFrom, sizeof(FILE_LIST));