Mikołaj Zalewski : shell32: If needed show a confirmation dialog when deleting with SHFileOperation.
Alexandre Julliard
julliard at wine.codeweavers.com
Wed Jun 28 10:38:52 CDT 2006
Module: wine
Branch: refs/heads/master
Commit: ce9471f18ed06566b7d84accceacf262212fb3cb
URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=ce9471f18ed06566b7d84accceacf262212fb3cb
Author: Mikołaj Zalewski <mikolaj at zalewski.pl>
Date: Tue Jun 27 21:51:35 2006 +0200
shell32: If needed show a confirmation dialog when deleting with SHFileOperation.
Show a confirmation dialog in SHFileOperationW for the FO_DELETE
operation when called without FOF_NOCONFIRMATION or with
FOF_WANTNUKEWARNING. That way the user's files won't be deleted
without a warning.
---
dlls/shell32/shlfileop.c | 34 +++++++++++++++++++++++++++++++---
1 files changed, 31 insertions(+), 3 deletions(-)
diff --git a/dlls/shell32/shlfileop.c b/dlls/shell32/shlfileop.c
index b5e2e74..4651614 100644
--- a/dlls/shell32/shlfileop.c
+++ b/dlls/shell32/shlfileop.c
@@ -1043,17 +1043,45 @@ static HRESULT copy_files(LPSHFILEOPSTRU
return ERROR_SUCCESS;
}
+static BOOL confirm_delete_list(DWORD fFlags, FILE_LIST *flFrom)
+{
+ if (flFrom->dwNumFiles > 1)
+ {
+ WCHAR tmp[8];
+ const WCHAR format[] = {'%','d',0};
+
+ wnsprintfW(tmp, sizeof(tmp)/sizeof(tmp[0]), format, flFrom->dwNumFiles);
+ return SHELL_ConfirmDialogW(ASK_DELETE_MULTIPLE_ITEM, tmp);
+ }
+ else
+ {
+ FILE_ENTRY *fileEntry = &flFrom->feFiles[0];
+
+ if (IsAttribFile(fileEntry->attributes))
+ return SHELL_ConfirmDialogW(ASK_DELETE_FILE, fileEntry->szFullPath);
+ else if (!(fFlags & FOF_FILESONLY && fileEntry->bFromWildcard))
+ return SHELL_ConfirmDialogW(ASK_DELETE_FOLDER, fileEntry->szFullPath);
+ }
+ return TRUE;
+}
+
/* the FO_DELETE operation */
static HRESULT delete_files(LPSHFILEOPSTRUCTW lpFileOp, FILE_LIST *flFrom)
{
FILE_ENTRY *fileEntry;
DWORD i;
BOOL bPathExists;
- BOOL bConfirm = !(lpFileOp->fFlags & FOF_NOCONFIRMATION);
if (!flFrom->dwNumFiles)
return ERROR_SUCCESS;
+ if (!(lpFileOp->fFlags & FOF_NOCONFIRMATION) || (lpFileOp->fFlags & FOF_WANTNUKEWARNING))
+ if (!confirm_delete_list(lpFileOp->fFlags, flFrom))
+ {
+ lpFileOp->fAnyOperationsAborted = TRUE;
+ return 0;
+ }
+
for (i = 0; i < flFrom->dwNumFiles; i++)
{
bPathExists = TRUE;
@@ -1063,7 +1091,7 @@ static HRESULT delete_files(LPSHFILEOPST
if (IsAttribFile(fileEntry->attributes))
bPathExists = DeleteFileW(fileEntry->szFullPath);
else if (!(lpFileOp->fFlags & FOF_FILESONLY && fileEntry->bFromWildcard))
- bPathExists = SHELL_DeleteDirectoryW(fileEntry->szFullPath, bConfirm);
+ bPathExists = SHELL_DeleteDirectoryW(fileEntry->szFullPath, FALSE);
if (!bPathExists)
return ERROR_PATH_NOT_FOUND;
@@ -1192,7 +1220,7 @@ static HRESULT rename_files(LPSHFILEOPST
static void check_flags(FILEOP_FLAGS fFlags)
{
WORD wUnsupportedFlags = FOF_ALLOWUNDO | FOF_NO_CONNECTED_ELEMENTS |
- FOF_NOCOPYSECURITYATTRIBS | FOF_NORECURSEREPARSE | FOF_WANTNUKEWARNING |
+ FOF_NOCOPYSECURITYATTRIBS | FOF_NORECURSEREPARSE |
FOF_RENAMEONCOLLISION | FOF_WANTMAPPINGHANDLE;
if (fFlags & wUnsupportedFlags)
More information about the wine-cvs
mailing list