2000-02-20 18:39:11 +00:00
|
|
|
/*
|
|
|
|
* SHFileOperation
|
|
|
|
*/
|
|
|
|
#include <string.h>
|
|
|
|
#include "debugtools.h"
|
|
|
|
#include "shellapi.h"
|
2001-02-26 22:31:38 +00:00
|
|
|
#include "shlwapi.h"
|
2000-02-20 18:39:11 +00:00
|
|
|
|
2000-02-26 18:48:16 +00:00
|
|
|
#include "shlobj.h"
|
Complete cleanup, bugfixes.
New: PathStripPath, PathMakeUniqueName, PathStripToRoot,
PathGetShortPath, PathParseIconLocation, PathRemoveExtension,
PathRemoveArgs, PathAppend, PathBuildRoot, PathCanonicalize,
PathFindNextComponent, PathRemoveFileSpec.
2000-04-28 20:23:46 +00:00
|
|
|
#include "shresdef.h"
|
2000-09-26 00:00:55 +00:00
|
|
|
#include "shell32_main.h"
|
2001-08-16 18:49:56 +00:00
|
|
|
#include "undocshell.h"
|
2001-01-07 21:50:52 +00:00
|
|
|
#include "shlwapi.h"
|
2000-02-26 18:48:16 +00:00
|
|
|
|
2000-02-20 18:39:11 +00:00
|
|
|
DEFAULT_DEBUG_CHANNEL(shell);
|
|
|
|
|
2001-02-21 04:01:20 +00:00
|
|
|
BOOL SHELL_WarnItemDelete (int nKindOfDialog, LPCSTR szDir)
|
Complete cleanup, bugfixes.
New: PathStripPath, PathMakeUniqueName, PathStripToRoot,
PathGetShortPath, PathParseIconLocation, PathRemoveExtension,
PathRemoveArgs, PathAppend, PathBuildRoot, PathCanonicalize,
PathFindNextComponent, PathRemoveFileSpec.
2000-04-28 20:23:46 +00:00
|
|
|
{
|
2000-08-11 00:38:44 +00:00
|
|
|
char szCaption[255], szText[255], szBuffer[MAX_PATH + 256];
|
Complete cleanup, bugfixes.
New: PathStripPath, PathMakeUniqueName, PathStripToRoot,
PathGetShortPath, PathParseIconLocation, PathRemoveExtension,
PathRemoveArgs, PathAppend, PathBuildRoot, PathCanonicalize,
PathFindNextComponent, PathRemoveFileSpec.
2000-04-28 20:23:46 +00:00
|
|
|
|
2001-02-21 04:01:20 +00:00
|
|
|
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 {
|
2001-05-09 17:31:31 +00:00
|
|
|
FIXME("Called without a valid nKindOfDialog specified!\n");
|
2001-02-21 04:01:20 +00:00
|
|
|
LoadStringA(shell32_hInstance, IDS_DELETEITEM_TEXT, szText,
|
|
|
|
sizeof(szText));
|
|
|
|
LoadStringA(shell32_hInstance, IDS_DELETEITEM_CAPTION,
|
|
|
|
szCaption, sizeof(szCaption));
|
|
|
|
}
|
|
|
|
|
2000-08-11 00:38:44 +00:00
|
|
|
FormatMessageA(FORMAT_MESSAGE_FROM_STRING|FORMAT_MESSAGE_ARGUMENT_ARRAY,
|
2000-10-15 00:31:23 +00:00
|
|
|
szText, 0, 0, szBuffer, sizeof(szBuffer), (va_list*)&szDir);
|
Complete cleanup, bugfixes.
New: PathStripPath, PathMakeUniqueName, PathStripToRoot,
PathGetShortPath, PathParseIconLocation, PathRemoveExtension,
PathRemoveArgs, PathAppend, PathBuildRoot, PathCanonicalize,
PathFindNextComponent, PathRemoveFileSpec.
2000-04-28 20:23:46 +00:00
|
|
|
|
2000-08-11 00:38:44 +00:00
|
|
|
return (IDOK == MessageBoxA(GetActiveWindow(), szBuffer, szCaption, MB_OKCANCEL | MB_ICONEXCLAMATION));
|
Complete cleanup, bugfixes.
New: PathStripPath, PathMakeUniqueName, PathStripToRoot,
PathGetShortPath, PathParseIconLocation, PathRemoveExtension,
PathRemoveArgs, PathAppend, PathBuildRoot, PathCanonicalize,
PathFindNextComponent, PathRemoveFileSpec.
2000-04-28 20:23:46 +00:00
|
|
|
}
|
|
|
|
|
2000-02-26 18:48:16 +00:00
|
|
|
/**************************************************************************
|
|
|
|
* SHELL_DeleteDirectoryA()
|
|
|
|
*
|
|
|
|
* like rm -r
|
|
|
|
*/
|
|
|
|
|
Complete cleanup, bugfixes.
New: PathStripPath, PathMakeUniqueName, PathStripToRoot,
PathGetShortPath, PathParseIconLocation, PathRemoveExtension,
PathRemoveArgs, PathAppend, PathBuildRoot, PathCanonicalize,
PathFindNextComponent, PathRemoveFileSpec.
2000-04-28 20:23:46 +00:00
|
|
|
BOOL SHELL_DeleteDirectoryA(LPCSTR pszDir, BOOL bShowUI)
|
2000-02-26 18:48:16 +00:00
|
|
|
{
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
HANDLE hFind;
|
|
|
|
WIN32_FIND_DATAA wfd;
|
|
|
|
char szTemp[MAX_PATH];
|
|
|
|
|
|
|
|
strcpy(szTemp, pszDir);
|
|
|
|
PathAddBackslashA(szTemp);
|
|
|
|
strcat(szTemp, "*.*");
|
|
|
|
|
2001-02-21 04:01:20 +00:00
|
|
|
if (bShowUI && !SHELL_WarnItemDelete(ASK_DELETE_FOLDER, pszDir))
|
|
|
|
return FALSE;
|
Complete cleanup, bugfixes.
New: PathStripPath, PathMakeUniqueName, PathStripToRoot,
PathGetShortPath, PathParseIconLocation, PathRemoveExtension,
PathRemoveArgs, PathAppend, PathBuildRoot, PathCanonicalize,
PathFindNextComponent, PathRemoveFileSpec.
2000-04-28 20:23:46 +00:00
|
|
|
|
2000-02-26 18:48:16 +00:00
|
|
|
if(INVALID_HANDLE_VALUE != (hFind = FindFirstFileA(szTemp, &wfd)))
|
|
|
|
{
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if(strcasecmp(wfd.cFileName, ".") && strcasecmp(wfd.cFileName, ".."))
|
|
|
|
{
|
|
|
|
strcpy(szTemp, pszDir);
|
|
|
|
PathAddBackslashA(szTemp);
|
|
|
|
strcat(szTemp, wfd.cFileName);
|
|
|
|
|
|
|
|
if(FILE_ATTRIBUTE_DIRECTORY & wfd.dwFileAttributes)
|
Complete cleanup, bugfixes.
New: PathStripPath, PathMakeUniqueName, PathStripToRoot,
PathGetShortPath, PathParseIconLocation, PathRemoveExtension,
PathRemoveArgs, PathAppend, PathBuildRoot, PathCanonicalize,
PathFindNextComponent, PathRemoveFileSpec.
2000-04-28 20:23:46 +00:00
|
|
|
SHELL_DeleteDirectoryA(szTemp, FALSE);
|
2000-02-26 18:48:16 +00:00
|
|
|
else
|
|
|
|
DeleteFileA(szTemp);
|
|
|
|
}
|
|
|
|
} while(FindNextFileA(hFind, &wfd));
|
|
|
|
|
|
|
|
FindClose(hFind);
|
|
|
|
ret = RemoveDirectoryA(pszDir);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2001-02-21 04:01:20 +00:00
|
|
|
/**************************************************************************
|
|
|
|
* SHELL_DeleteFileA()
|
|
|
|
*/
|
|
|
|
|
|
|
|
BOOL SHELL_DeleteFileA(LPCSTR pszFile, BOOL bShowUI)
|
|
|
|
{
|
|
|
|
if (bShowUI && !SHELL_WarnItemDelete(ASK_DELETE_FILE, pszFile))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return DeleteFileA(pszFile);
|
|
|
|
}
|
|
|
|
|
2000-02-26 18:48:16 +00:00
|
|
|
/*************************************************************************
|
|
|
|
* SHCreateDirectory [SHELL32.165]
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* exported by ordinal
|
|
|
|
* not sure about LPSECURITY_ATTRIBUTES
|
|
|
|
*/
|
|
|
|
DWORD WINAPI SHCreateDirectory(LPSECURITY_ATTRIBUTES sec,LPCSTR path)
|
|
|
|
{
|
|
|
|
DWORD ret;
|
|
|
|
TRACE("(%p,%s)\n",sec,path);
|
|
|
|
if ((ret = CreateDirectoryA(path,sec)))
|
|
|
|
{
|
|
|
|
SHChangeNotifyA(SHCNE_MKDIR, SHCNF_PATHA, path, NULL);
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/************************************************************************
|
|
|
|
* Win32DeleteFile [SHELL32.164]
|
|
|
|
*
|
|
|
|
* Deletes a file. Also triggers a change notify if one exists.
|
|
|
|
*
|
|
|
|
* FIXME:
|
|
|
|
* Verified on Win98 / IE 5 (SHELL32 4.72, March 1999 build) to be
|
|
|
|
* ANSI. Is this Unicode on NT?
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
BOOL WINAPI Win32DeleteFile(LPSTR fName)
|
|
|
|
{
|
|
|
|
TRACE("%p(%s)\n", fName, fName);
|
|
|
|
|
|
|
|
DeleteFileA(fName);
|
|
|
|
SHChangeNotifyA(SHCNE_DELETE, SHCNF_PATHA, fName, NULL);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2000-02-20 18:39:11 +00:00
|
|
|
/*************************************************************************
|
2001-06-19 18:20:47 +00:00
|
|
|
* SHFileOperationA [SHELL32.@]
|
2000-02-20 18:39:11 +00:00
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* exported by name
|
|
|
|
*/
|
|
|
|
DWORD WINAPI SHFileOperationA (LPSHFILEOPSTRUCTA lpFileOp)
|
|
|
|
{
|
2001-02-26 22:31:38 +00:00
|
|
|
LPSTR pFrom = (LPSTR)lpFileOp->pFrom;
|
|
|
|
LPSTR pTo = (LPSTR)lpFileOp->pTo;
|
|
|
|
LPSTR pTempTo;
|
|
|
|
|
|
|
|
switch(lpFileOp->wFunc) {
|
|
|
|
case FO_COPY:
|
|
|
|
TRACE("File Copy:\n");
|
|
|
|
while(1) {
|
|
|
|
if(!pFrom[0]) break;
|
|
|
|
if(!pTo[0]) break;
|
|
|
|
TRACE(" From='%s' To='%s'\n", pFrom, pTo);
|
|
|
|
|
|
|
|
pTempTo = HeapAlloc(GetProcessHeap(), 0, strlen(pTo)+1);
|
|
|
|
if (pTempTo)
|
|
|
|
{
|
|
|
|
strcpy( pTempTo, pTo );
|
|
|
|
PathRemoveFileSpecA(pTempTo);
|
|
|
|
TRACE(" Creating Directory '%s'\n", pTempTo);
|
|
|
|
SHCreateDirectory(NULL,pTempTo);
|
|
|
|
HeapFree(GetProcessHeap(), 0, pTempTo);
|
|
|
|
}
|
|
|
|
CopyFileA(pFrom, pTo, FALSE);
|
|
|
|
|
|
|
|
pFrom += strlen(pFrom) + 1;
|
|
|
|
pTo += strlen(pTo) + 1;
|
|
|
|
}
|
|
|
|
TRACE("Setting AnyOpsAborted=FALSE\n");
|
|
|
|
lpFileOp->fAnyOperationsAborted=FALSE;
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
case FO_DELETE:
|
|
|
|
TRACE("File Delete:\n");
|
|
|
|
while(1) {
|
|
|
|
if(!pFrom[0]) break;
|
|
|
|
TRACE(" File='%s'\n", pFrom);
|
|
|
|
DeleteFileA(pFrom);
|
|
|
|
pFrom += strlen(pFrom) + 1;
|
|
|
|
}
|
|
|
|
TRACE("Setting AnyOpsAborted=FALSE\n");
|
|
|
|
lpFileOp->fAnyOperationsAborted=FALSE;
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
default:
|
|
|
|
FIXME("Unhandled shell file operation %d\n", lpFileOp->wFunc);
|
|
|
|
}
|
|
|
|
|
2000-02-20 18:39:11 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
2001-06-19 18:20:47 +00:00
|
|
|
* SHFileOperationW [SHELL32.@]
|
2000-02-20 18:39:11 +00:00
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* exported by name
|
|
|
|
*/
|
|
|
|
DWORD WINAPI SHFileOperationW (LPSHFILEOPSTRUCTW lpFileOp)
|
|
|
|
{
|
|
|
|
FIXME("(%p):stub.\n", lpFileOp);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
2001-06-19 18:20:47 +00:00
|
|
|
* SHFileOperation [SHELL32.@]
|
2000-02-20 18:39:11 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
DWORD WINAPI SHFileOperationAW(LPVOID lpFileOp)
|
|
|
|
{
|
2000-08-14 14:35:01 +00:00
|
|
|
if (SHELL_OsIsUnicode())
|
2000-02-20 18:39:11 +00:00
|
|
|
return SHFileOperationW(lpFileOp);
|
|
|
|
return SHFileOperationA(lpFileOp);
|
|
|
|
}
|
Complete cleanup, bugfixes.
New: PathStripPath, PathMakeUniqueName, PathStripToRoot,
PathGetShortPath, PathParseIconLocation, PathRemoveExtension,
PathRemoveArgs, PathAppend, PathBuildRoot, PathCanonicalize,
PathFindNextComponent, PathRemoveFileSpec.
2000-04-28 20:23:46 +00:00
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* SheGetDirW [SHELL32.281]
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI SheGetDirW(LPWSTR u, LPWSTR v)
|
|
|
|
{ FIXME("%p %p stub\n",u,v);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* SheChangeDirW [SHELL32.274]
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI SheChangeDirW(LPWSTR u)
|
|
|
|
{ FIXME("(%s),stub\n",debugstr_w(u));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2001-01-18 23:04:19 +00:00
|
|
|
/*************************************************************************
|
|
|
|
* IsNetDrive [SHELL32.66]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI IsNetDrive(DWORD drive)
|
|
|
|
{
|
|
|
|
char root[4];
|
|
|
|
strcpy(root, "A:\\");
|
|
|
|
root[0] += drive;
|
|
|
|
return (GetDriveTypeA(root) == DRIVE_REMOTE);
|
|
|
|
}
|