Commit e187b3ff authored by Chris Morgan's avatar Chris Morgan Committed by Alexandre Julliard

Confirm file deletes. Make delete confirmation messages more

consistent. Improve trace messages on delete failure.
parent 0cd448c4
......@@ -13,16 +13,39 @@
DEFAULT_DEBUG_CHANNEL(shell);
#define ASK_DELETE_FILE 1
#define ASK_DELETE_FOLDER 2
#define ASK_DELETE_MULTIPLE_FILE 3
static BOOL SHELL_WarnFolderDelete (int nKindOfDialog, LPCSTR szDir)
BOOL SHELL_WarnItemDelete (int nKindOfDialog, LPCSTR szDir)
{
char szCaption[255], szText[255], szBuffer[MAX_PATH + 256];
LoadStringA(shell32_hInstance, IDS_DELETEFOLDER_TEXT, szText, sizeof(szText));
LoadStringA(shell32_hInstance, IDS_DELETEFOLDER_CAPTION, szCaption, sizeof(szCaption));
if(nKindOfDialog == ASK_DELETE_FILE)
{
LoadStringA(shell32_hInstance, IDS_DELETEITEM_TEXT, szText,
sizeof(szText));
LoadStringA(shell32_hInstance, IDS_DELETEITEM_CAPTION,
szCaption, sizeof(szCaption));
}
else if(nKindOfDialog == ASK_DELETE_FOLDER)
{
LoadStringA(shell32_hInstance, IDS_DELETEITEM_TEXT, szText,
sizeof(szText));
LoadStringA(shell32_hInstance, IDS_DELETEFOLDER_CAPTION,
szCaption, sizeof(szCaption));
}
else if(nKindOfDialog == ASK_DELETE_MULTIPLE_ITEM)
{
LoadStringA(shell32_hInstance, IDS_DELETEMULTIPLE_TEXT, szText,
sizeof(szText));
LoadStringA(shell32_hInstance, IDS_DELETEITEM_CAPTION,
szCaption, sizeof(szCaption));
}
else {
FIXME("Called without a valid nKindOfDialog specified!");
LoadStringA(shell32_hInstance, IDS_DELETEITEM_TEXT, szText,
sizeof(szText));
LoadStringA(shell32_hInstance, IDS_DELETEITEM_CAPTION,
szCaption, sizeof(szCaption));
}
FormatMessageA(FORMAT_MESSAGE_FROM_STRING|FORMAT_MESSAGE_ARGUMENT_ARRAY,
szText, 0, 0, szBuffer, sizeof(szBuffer), (va_list*)&szDir);
......@@ -46,7 +69,8 @@ BOOL SHELL_DeleteDirectoryA(LPCSTR pszDir, BOOL bShowUI)
PathAddBackslashA(szTemp);
strcat(szTemp, "*.*");
if (bShowUI && !SHELL_WarnFolderDelete(ASK_DELETE_FOLDER, pszDir)) return FALSE;
if (bShowUI && !SHELL_WarnItemDelete(ASK_DELETE_FOLDER, pszDir))
return FALSE;
if(INVALID_HANDLE_VALUE != (hFind = FindFirstFileA(szTemp, &wfd)))
{
......@@ -72,6 +96,18 @@ BOOL SHELL_DeleteDirectoryA(LPCSTR pszDir, BOOL bShowUI)
return ret;
}
/**************************************************************************
* SHELL_DeleteFileA()
*/
BOOL SHELL_DeleteFileA(LPCSTR pszFile, BOOL bShowUI)
{
if (bShowUI && !SHELL_WarnItemDelete(ASK_DELETE_FILE, pszFile))
return FALSE;
return DeleteFileA(pszFile);
}
/*************************************************************************
* SHCreateDirectory [SHELL32.165]
*
......
......@@ -1489,9 +1489,20 @@ static HRESULT WINAPI ISFHelper_fnDeleteItems(
_ICOM_THIS_From_ISFHelper(IGenericSFImpl,iface)
int i;
char szPath[MAX_PATH];
BOOL bConfirm = TRUE;
TRACE("(%p)(%u %p)\n", This, cidl, apidl);
/* deleting multiple items so give a slightly different warning */
if(cidl != 1)
{
char tmp[8];
snprintf(tmp, sizeof(tmp), "%d", cidl);
if(!SHELL_WarnItemDelete(ASK_DELETE_MULTIPLE_ITEM, tmp))
return E_FAIL;
bConfirm = FALSE;
}
for(i=0; i< cidl; i++)
{
strcpy(szPath, This->sMyPath);
......@@ -1501,9 +1512,12 @@ static HRESULT WINAPI ISFHelper_fnDeleteItems(
if (_ILIsFolder(apidl[i]))
{
LPITEMIDLIST pidl;
MESSAGE("delete %s\n", szPath);
if (! SHELL_DeleteDirectoryA(szPath, TRUE)) return E_FAIL;
TRACE("delete %s\n", szPath);
if (! SHELL_DeleteDirectoryA(szPath, bConfirm))
{
TRACE("delete %s failed, bConfirm=%d", szPath, bConfirm);
return E_FAIL;
}
pidl = ILCombine(This->absPidl, apidl[i]);
SHChangeNotifyA(SHCNE_RMDIR, SHCNF_IDLIST, pidl, NULL);
SHFree(pidl);
......@@ -1512,8 +1526,12 @@ static HRESULT WINAPI ISFHelper_fnDeleteItems(
{
LPITEMIDLIST pidl;
MESSAGE("delete %s\n", szPath);
if (! DeleteFileA(szPath)) return E_FAIL;
TRACE("delete %s\n", szPath);
if (! SHELL_DeleteFileA(szPath, bConfirm))
{
TRACE("delete %s failed, bConfirm=%d", szPath, bConfirm);
return E_FAIL;
}
pidl = ILCombine(This->absPidl, apidl[i]);
SHChangeNotifyA(SHCNE_DELETE, SHCNF_IDLIST, pidl, NULL);
SHFree(pidl);
......
......@@ -133,8 +133,10 @@ STRINGTABLE DISCARDABLE
{
IDS_CREATEFOLDER_DENIED "Can not create new Folder: Permission denied."
IDS_CREATEFOLDER_CAPTION "Error during creating a new folder"
IDS_DELETEFOLDER_TEXT "Are you sure you want to delete %1 and all it's subfolders?"
IDS_DELETEFOLDER_CAPTION "Confirm file delete"
IDS_DELETEITEM_CAPTION "Confirm file delete"
IDS_DELETEFOLDER_CAPTION "Confirm folder delete"
IDS_DELETEITEM_TEXT "Are you sure you want to delete '%1'?"
IDS_DELETEMULTIPLE_TEXT "Are you sure you want to delete these %1 items?"
}
shv_accel ACCELERATORS
......
......@@ -24,8 +24,10 @@
#define IDS_CREATEFOLDER_DENIED 30
#define IDS_CREATEFOLDER_CAPTION 31
#define IDS_DELETEFOLDER_TEXT 32
#define IDS_DELETEITEM_CAPTION 32
#define IDS_DELETEFOLDER_CAPTION 33
#define IDS_DELETEITEM_TEXT 34
#define IDS_DELETEMULTIPLE_TEXT 35
/* browse for folder dialog box */
#define IDD_STATUS 97
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment