[PATCH 5/7] shell32: Add parameter to ISFHelper::DeleteItems to allow deleting files without confirmation.

Alistair Leslie-Hughes leslie_alistair at hotmail.com
Thu May 24 23:49:57 CDT 2018


From: Michael Müller <michael at fds-team.de>

Signed-off-by: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
---
 dlls/shell32/recyclebin.c    | 6 +++---
 dlls/shell32/shellfolder.h   | 4 ++--
 dlls/shell32/shfldr_fs.c     | 3 ++-
 dlls/shell32/shfldr_unixfs.c | 7 ++++---
 dlls/shell32/shlview.c       | 2 +-
 dlls/shell32/shlview_cmenu.c | 2 +-
 6 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/dlls/shell32/recyclebin.c b/dlls/shell32/recyclebin.c
index 0d80e63..66c5cc2 100644
--- a/dlls/shell32/recyclebin.c
+++ b/dlls/shell32/recyclebin.c
@@ -182,7 +182,7 @@ static void DoErase(RecycleBinMenu *This)
     ISFHelper *helper;
     IShellFolder2_QueryInterface(This->folder,&IID_ISFHelper,(void**)&helper);
     if(helper)
-        ISFHelper_DeleteItems(helper,This->cidl,(LPCITEMIDLIST*)This->apidl);
+        ISFHelper_DeleteItems(helper, This->cidl, (LPCITEMIDLIST *)This->apidl, TRUE);
 }
 
 static void DoRestore(RecycleBinMenu *This)
@@ -815,10 +815,10 @@ static HRESULT erase_items(HWND parent,const LPCITEMIDLIST * apidl, UINT cidl, B
 }
 
 static HRESULT WINAPI RecycleBin_DeleteItems(ISFHelper * iface, UINT cidl,
-                                             LPCITEMIDLIST * apidl)
+                                             LPCITEMIDLIST * apidl, BOOL confirm)
 {
     TRACE("(%p,%u,%p)\n",iface,cidl,apidl);
-    return erase_items(GetActiveWindow(),apidl,cidl,TRUE);
+    return erase_items(GetActiveWindow(), apidl, cidl, confirm);
 }
 
 static HRESULT WINAPI RecycleBin_CopyItems(ISFHelper * iface,
diff --git a/dlls/shell32/shellfolder.h b/dlls/shell32/shellfolder.h
index 942e0e7..b8083a2 100644
--- a/dlls/shell32/shellfolder.h
+++ b/dlls/shell32/shellfolder.h
@@ -48,7 +48,7 @@ DECLARE_INTERFACE_(ISFHelper,IUnknown)
     /*** ISFHelper methods ***/
     STDMETHOD(GetUniqueName)(THIS_ LPWSTR  lpName, UINT  uLen) PURE;
     STDMETHOD(AddFolder)(THIS_ HWND  hwnd, LPCWSTR  lpName, LPITEMIDLIST * ppidlOut) PURE;
-    STDMETHOD(DeleteItems)(THIS_ UINT  cidl, LPCITEMIDLIST * apidl) PURE;
+    STDMETHOD(DeleteItems)(THIS_ UINT cidl, LPCITEMIDLIST *apidl, BOOL confirm) PURE;
     STDMETHOD(CopyItems)(THIS_ IShellFolder * pSFFrom, UINT  cidl, LPCITEMIDLIST * apidl) PURE;
 };
 #undef INTERFACE
@@ -61,7 +61,7 @@ DECLARE_INTERFACE_(ISFHelper,IUnknown)
 /*** ISFHelper methods ***/
 #define ISFHelper_GetUniqueName(p,a,b)          (p)->lpVtbl->GetUniqueName(p,a,b)
 #define ISFHelper_AddFolder(p,a,b,c)            (p)->lpVtbl->AddFolder(p,a,b,c)
-#define ISFHelper_DeleteItems(p,a,b)            (p)->lpVtbl->DeleteItems(p,a,b)
+#define ISFHelper_DeleteItems(p,a,b,c)          (p)->lpVtbl->DeleteItems(p,a,b,c)
 #define ISFHelper_CopyItems(p,a,b,c)            (p)->lpVtbl->CopyItems(p,a,b,c)
 #endif
 
diff --git a/dlls/shell32/shfldr_fs.c b/dlls/shell32/shfldr_fs.c
index 66150f4..32178be 100644
--- a/dlls/shell32/shfldr_fs.c
+++ b/dlls/shell32/shfldr_fs.c
@@ -1225,7 +1225,7 @@ static WCHAR *build_paths_list(LPCWSTR wszBasePath, int cidl, const LPCITEMIDLIS
  * deletes items in folder
  */
 static HRESULT WINAPI
-ISFHelper_fnDeleteItems (ISFHelper * iface, UINT cidl, LPCITEMIDLIST * apidl)
+ISFHelper_fnDeleteItems (ISFHelper *iface, UINT cidl, LPCITEMIDLIST *apidl, BOOL confirm)
 {
     IGenericSFImpl *This = impl_from_ISFHelper(iface);
     UINT i;
@@ -1250,6 +1250,7 @@ ISFHelper_fnDeleteItems (ISFHelper * iface, UINT cidl, LPCITEMIDLIST * apidl)
     op.wFunc = FO_DELETE;
     op.pFrom = wszPathsList;
     op.fFlags = FOF_ALLOWUNDO;
+    if (!confirm) op.fFlags |= FOF_NOCONFIRMATION;
     if (SHFileOperationW(&op))
     {
         WARN("SHFileOperation failed\n");
diff --git a/dlls/shell32/shfldr_unixfs.c b/dlls/shell32/shfldr_unixfs.c
index 732a103..a2ca852 100644
--- a/dlls/shell32/shfldr_unixfs.c
+++ b/dlls/shell32/shfldr_unixfs.c
@@ -1942,7 +1942,7 @@ static HRESULT WINAPI SFHelper_AddFolder(ISFHelper* iface, HWND hwnd, LPCWSTR pw
  * be converted, S_FALSE is returned. In such situation DeleteItems will try to delete
  * the files using syscalls
  */
-static HRESULT UNIXFS_delete_with_shfileop(UnixFolder *This, UINT cidl, const LPCITEMIDLIST *apidl)
+static HRESULT UNIXFS_delete_with_shfileop(UnixFolder *This, UINT cidl, const LPCITEMIDLIST *apidl, BOOL confirm)
 {
     char szAbsolute[FILENAME_MAX], *pszRelative;
     LPWSTR wszPathsList, wszListPos;
@@ -1984,6 +1984,7 @@ static HRESULT UNIXFS_delete_with_shfileop(UnixFolder *This, UINT cidl, const LP
     op.wFunc = FO_DELETE;
     op.pFrom = wszPathsList;
     op.fFlags = FOF_ALLOWUNDO;
+    if (!confirm) op.fFlags |= FOF_NOCONFIRMATION;
     if (SHFileOperationW(&op))
     {
         WARN("SHFileOperationW failed\n");
@@ -2022,7 +2023,7 @@ static HRESULT UNIXFS_delete_with_syscalls(UnixFolder *This, UINT cidl, const LP
     return S_OK;
 }
 
-static HRESULT WINAPI SFHelper_DeleteItems(ISFHelper* iface, UINT cidl, LPCITEMIDLIST* apidl)
+static HRESULT WINAPI SFHelper_DeleteItems(ISFHelper *iface, UINT cidl, LPCITEMIDLIST *apidl, BOOL confirm)
 {
     UnixFolder *This = impl_from_ISFHelper(iface);
     char szAbsolute[FILENAME_MAX], *pszRelative;
@@ -2033,7 +2034,7 @@ static HRESULT WINAPI SFHelper_DeleteItems(ISFHelper* iface, UINT cidl, LPCITEMI
     
     TRACE("(%p)->(%d %p)\n", This, cidl, apidl);
 
-    hr = UNIXFS_delete_with_shfileop(This, cidl, apidl);
+    hr = UNIXFS_delete_with_shfileop(This, cidl, apidl, confirm);
     if (hr == S_FALSE)
         hr = UNIXFS_delete_with_syscalls(This, cidl, apidl);
 
diff --git a/dlls/shell32/shlview.c b/dlls/shell32/shlview.c
index c0c027f..9f23bfe 100644
--- a/dlls/shell32/shlview.c
+++ b/dlls/shell32/shlview.c
@@ -1577,7 +1577,7 @@ static LRESULT ShellView_OnNotify(IShellViewImpl * This, UINT CtlID, LPNMHDR lpn
 		  }
 
 		  /* perform the item deletion */
-		  ISFHelper_DeleteItems(psfhlp, i, (LPCITEMIDLIST*)pItems);
+		  ISFHelper_DeleteItems(psfhlp, i, (LPCITEMIDLIST *)pItems, TRUE);
 		  ISFHelper_Release(psfhlp);
 
 		  /* free pidl array memory */
diff --git a/dlls/shell32/shlview_cmenu.c b/dlls/shell32/shlview_cmenu.c
index c9b2ebf..f84ce31 100644
--- a/dlls/shell32/shlview_cmenu.c
+++ b/dlls/shell32/shlview_cmenu.c
@@ -294,7 +294,7 @@ static void DoDelete(ContextMenu *This)
     IShellFolder_QueryInterface(This->parent, &IID_ISFHelper, (void**)&helper);
     if (helper)
     {
-        ISFHelper_DeleteItems(helper, This->cidl, (LPCITEMIDLIST*)This->apidl);
+        ISFHelper_DeleteItems(helper, This->cidl, (LPCITEMIDLIST *)This->apidl, TRUE);
         ISFHelper_Release(helper);
     }
 }
-- 
1.9.1



More information about the wine-devel mailing list