From a40f637b41b6efb41822792a24b5c1897ab9294b Mon Sep 17 00:00:00 2001 From: Gregor Schneider Date: Fri, 16 Apr 2010 21:22:06 +0000 Subject: [PATCH] [SHELL32] - Add support for deleting multiple files from the context menu - Fix error debug print See issue #4383 for more details. svn path=/trunk/; revision=46900 --- reactos/dll/win32/shell32/shv_def_cmenu.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/reactos/dll/win32/shell32/shv_def_cmenu.c b/reactos/dll/win32/shell32/shv_def_cmenu.c index 71c25a7d407..08c9c3c9c74 100644 --- a/reactos/dll/win32/shell32/shv_def_cmenu.c +++ b/reactos/dll/win32/shell32/shv_def_cmenu.c @@ -48,7 +48,7 @@ static LPIDefaultContextMenuImpl __inline impl_from_IContextMenu( IContextMenu2 } VOID INewItem_SetCurrentShellFolder(IShellFolder * psfParent); // HACK - +WCHAR *build_paths_list(LPCWSTR wszBasePath, int cidl, LPCITEMIDLIST *pidls); static HRESULT @@ -1297,12 +1297,12 @@ DoDelete( HRESULT hr; STRRET strTemp; WCHAR szPath[MAX_PATH]; + LPWSTR wszPath, wszPos; SHFILEOPSTRUCTW op; int ret; LPSHELLBROWSER lpSB; HWND hwnd; - hr = IShellFolder2_GetDisplayNameOf(This->dcm.psf, This->dcm.apidl[0], SHGDN_FORPARSING, &strTemp); if(hr != S_OK) { @@ -1316,20 +1316,26 @@ DoDelete( ERR("StrRetToBufW failed with %x\n", hr); return hr; } - /* FIXME - * implement deletion with multiple files - */ + + /* Only keep the base path */ + wszPos = strrchrW(szPath, '\\'); + if (wszPos != NULL) + { + *(wszPos + 1) = '\0'; + } + + wszPath = build_paths_list(szPath, This->dcm.cidl, This->dcm.apidl); ZeroMemory(&op, sizeof(op)); op.hwnd = GetActiveWindow(); op.wFunc = FO_DELETE; - op.pFrom = szPath; + op.pFrom = wszPath; op.fFlags = FOF_ALLOWUNDO; ret = SHFileOperationW(&op); if (ret) { - TRACE("SHFileOperation failed with %0x%x", GetLastError()); + ERR("SHFileOperation failed with 0x%x for %s\n", GetLastError(), debugstr_w(wszPath)); return S_OK; } @@ -1348,6 +1354,7 @@ DoDelete( } NotifyShellViewWindow(lpcmi, TRUE); + HeapFree(GetProcessHeap(), 0, wszPath); return S_OK; }