Commit 2d58a624 authored by Joris Huizer's avatar Joris Huizer Committed by Alexandre Julliard

- add file_operation_delete

- add file_operation_checkFlags - use these in SHFileOperationW replacing inline code
parent 939179d6
...@@ -861,6 +861,90 @@ static const char * debug_shfileops_action( DWORD op ) ...@@ -861,6 +861,90 @@ static const char * debug_shfileops_action( DWORD op )
#define ERROR_SHELL_INTERNAL_FILE_NOT_FOUND 1026 #define ERROR_SHELL_INTERNAL_FILE_NOT_FOUND 1026
#define HIGH_ADR (LPWSTR)0xffffffff #define HIGH_ADR (LPWSTR)0xffffffff
static int file_operation_delete( WIN32_FIND_DATAW *wfd,SHFILEOPSTRUCTW nFileOp, LPWSTR pFromFile,LPWSTR pTempFrom,HANDLE *hFind)
{
LPWSTR lpFileName;
BOOL b_Mask = (NULL != StrPBrkW(&pFromFile[1], wWildcardChars));
int retCode = 0;
do
{
lpFileName = wfd->cAlternateFileName;
if (!lpFileName[0])
lpFileName = wfd->cFileName;
if (IsDotDir(lpFileName) ||
((b_Mask) && IsAttribDir(wfd->dwFileAttributes) && (nFileOp.fFlags & FOF_FILESONLY)))
continue;
SHFileStrCpyCatW(&pFromFile[1], lpFileName, NULL);
/* TODO: Check the SHELL_DeleteFileOrDirectoryW() function in shell32.dll */
if (IsAttribFile(wfd->dwFileAttributes))
{
if(SHNotifyDeleteFileW(pTempFrom) != ERROR_SUCCESS)
{
nFileOp.fAnyOperationsAborted = TRUE;
retCode = 0x78; /* value unknown */
}
}
else if(!SHELL_DeleteDirectoryW(pTempFrom, (!(nFileOp.fFlags & FOF_NOCONFIRMATION))))
{
nFileOp.fAnyOperationsAborted = TRUE;
retCode = 0x79; /* value unknown */
}
}
while (!nFileOp.fAnyOperationsAborted && FindNextFileW(*hFind,wfd));
FindClose(*hFind);
*hFind = INVALID_HANDLE_VALUE;
return retCode;
}
/*
* Summary of flags:
*
* implemented flags:
* FOF_MULTIDESTFILES, FOF_NOCONFIRMATION, FOF_FILESONLY
*
* unimplememented and ignored flags:
* FOF_CONFIRMMOUSE, FOF_SILENT, FOF_NOCONFIRMMKDIR,
* FOF_SIMPLEPROGRESS, FOF_NOCOPYSECURITYATTRIBS
*
* partially implemented, breaks if file exists:
* FOF_RENAMEONCOLLISION
*
* unimplemented and break if any other flag set:
* FOF_ALLOWUNDO, FOF_WANTMAPPINGHANDLE
*/
static int file_operation_checkFlags(SHFILEOPSTRUCTW nFileOp)
{
FILEOP_FLAGS OFl = ((FILEOP_FLAGS)nFileOp.fFlags & 0xfff);
long FuncSwitch = (nFileOp.wFunc & FO_MASK);
long level= nFileOp.wFunc >> 4;
TRACE("%s level=%ld nFileOp.fFlags=0x%x\n",
debug_shfileops_action(FuncSwitch), level, nFileOp.fFlags);
/* OFl &= (-1 - (FOF_MULTIDESTFILES | FOF_FILESONLY)); */
/* OFl ^= (FOF_SILENT | FOF_NOCONFIRMATION | FOF_SIMPLEPROGRESS | FOF_NOCONFIRMMKDIR); */
OFl &= (~(FOF_MULTIDESTFILES | FOF_NOCONFIRMATION | FOF_FILESONLY)); /* implemented */
OFl ^= (FOF_SILENT | FOF_NOCONFIRMMKDIR | FOF_NOERRORUI | FOF_NOCOPYSECURITYATTRIBS); /* ignored, if one */
OFl &= (~FOF_SIMPLEPROGRESS); /* ignored, only with FOF_SILENT */
if (OFl)
{
if (OFl & (~(FOF_CONFIRMMOUSE | FOF_SILENT | FOF_RENAMEONCOLLISION |
FOF_NOCONFIRMMKDIR | FOF_NOERRORUI | FOF_NOCOPYSECURITYATTRIBS)))
{
TRACE("%s level=%ld lpFileOp->fFlags=0x%x not implemented, Aborted=TRUE, stub\n",
debug_shfileops_action(FuncSwitch), level, OFl);
return 0x403; /* 1027, we need an extension to shlfileop */
}
else
{
TRACE("%s level=%ld lpFileOp->fFlags=0x%x not fully implemented, stub\n",
debug_shfileops_action(FuncSwitch), level, OFl);
}
}
return 0;
}
/************************************************************************* /*************************************************************************
* SHFileOperationW [SHELL32.@] * SHFileOperationW [SHELL32.@]
* *
...@@ -884,8 +968,6 @@ int WINAPI SHFileOperationW(LPSHFILEOPSTRUCTW lpFileOp) ...@@ -884,8 +968,6 @@ int WINAPI SHFileOperationW(LPSHFILEOPSTRUCTW lpFileOp)
int retCode = 0; int retCode = 0;
DWORD ToAttr; DWORD ToAttr;
DWORD ToPathAttr; DWORD ToPathAttr;
DWORD FromPathAttr;
FILEOP_FLAGS OFl = ((FILEOP_FLAGS)lpFileOp->fFlags & 0xfff);
BOOL b_Multi = (nFileOp.fFlags & FOF_MULTIDESTFILES); BOOL b_Multi = (nFileOp.fFlags & FOF_MULTIDESTFILES);
...@@ -904,6 +986,8 @@ int WINAPI SHFileOperationW(LPSHFILEOPSTRUCTW lpFileOp) ...@@ -904,6 +986,8 @@ int WINAPI SHFileOperationW(LPSHFILEOPSTRUCTW lpFileOp)
long FuncSwitch = (nFileOp.wFunc & FO_MASK); long FuncSwitch = (nFileOp.wFunc & FO_MASK);
long level= nFileOp.wFunc>>4; long level= nFileOp.wFunc>>4;
int ret;
/* default no error */ /* default no error */
nFileOp.fAnyOperationsAborted = FALSE; nFileOp.fAnyOperationsAborted = FALSE;
...@@ -932,47 +1016,12 @@ int WINAPI SHFileOperationW(LPSHFILEOPSTRUCTW lpFileOp) ...@@ -932,47 +1016,12 @@ int WINAPI SHFileOperationW(LPSHFILEOPSTRUCTW lpFileOp)
* create dir 0 0 0 0 0 0 1 0 * create dir 0 0 0 0 0 0 1 0
*/ */
/* ret = file_operation_checkFlags(nFileOp);
* Summary of flags: if (ret != 0)
*
* implemented flags:
* FOF_MULTIDESTFILES, FOF_NOCONFIRMATION, FOF_FILESONLY
*
* unimplememented and ignored flags:
* FOF_CONFIRMMOUSE, FOF_SILENT, FOF_NOCONFIRMMKDIR,
* FOF_SIMPLEPROGRESS, FOF_NOCOPYSECURITYATTRIBS
*
* partially implemented, breaks if file exists:
* FOF_RENAMEONCOLLISION
*
* unimplemented and break if any other flag set:
* FOF_ALLOWUNDO, FOF_WANTMAPPINGHANDLE
*/
TRACE("%s level=%ld nFileOp.fFlags=0x%x\n",
debug_shfileops_action(FuncSwitch), level, lpFileOp->fFlags);
/* OFl &= (-1 - (FOF_MULTIDESTFILES | FOF_FILESONLY)); */
/* OFl ^= (FOF_SILENT | FOF_NOCONFIRMATION | FOF_SIMPLEPROGRESS | FOF_NOCONFIRMMKDIR); */
OFl &= (~(FOF_MULTIDESTFILES | FOF_NOCONFIRMATION | FOF_FILESONLY)); /* implemented */
OFl ^= (FOF_SILENT | FOF_NOCONFIRMMKDIR | FOF_NOERRORUI | FOF_NOCOPYSECURITYATTRIBS); /* ignored, if one */
OFl &= (~FOF_SIMPLEPROGRESS); /* ignored, only with FOF_SILENT */
if (OFl)
{
if (OFl & (~(FOF_CONFIRMMOUSE | FOF_SILENT | FOF_RENAMEONCOLLISION |
FOF_NOCONFIRMMKDIR | FOF_NOERRORUI | FOF_NOCOPYSECURITYATTRIBS)))
{ {
TRACE("%s level=%ld lpFileOp->fFlags=0x%x not implemented, Aborted=TRUE, stub\n", retCode = ret;
debug_shfileops_action(FuncSwitch), level, OFl);
retCode = 0x403; /* 1027, we need an extension to shlfileop */
goto shfileop_end; goto shfileop_end;
} }
else
{
TRACE("%s level=%ld lpFileOp->fFlags=0x%x not fully implemented, stub\n",
debug_shfileops_action(FuncSwitch), level, OFl);
}
}
if ((pNextFrom) && (!(b_MultiTo) || (pNextTo))) if ((pNextFrom) && (!(b_MultiTo) || (pNextTo)))
{ {
...@@ -1061,6 +1110,7 @@ int WINAPI SHFileOperationW(LPSHFILEOPSTRUCTW lpFileOp) ...@@ -1061,6 +1110,7 @@ int WINAPI SHFileOperationW(LPSHFILEOPSTRUCTW lpFileOp)
{ {
if ((FO_DELETE == FuncSwitch) && (b_Mask)) if ((FO_DELETE == FuncSwitch) && (b_Mask))
{ {
DWORD FromPathAttr;
pFromFile[0] = '\0'; pFromFile[0] = '\0';
FromPathAttr = GetFileAttributesW(pTempFrom); FromPathAttr = GetFileAttributesW(pTempFrom);
pFromFile[0] = '\\'; pFromFile[0] = '\\';
...@@ -1080,37 +1130,13 @@ int WINAPI SHFileOperationW(LPSHFILEOPSTRUCTW lpFileOp) ...@@ -1080,37 +1130,13 @@ int WINAPI SHFileOperationW(LPSHFILEOPSTRUCTW lpFileOp)
/* ??? b_Mask = (!SHFileStrICmpA(&pFromFile[1], &wfd.cFileName[0], HIGH_ADR, HIGH_ADR)); */ /* ??? b_Mask = (!SHFileStrICmpA(&pFromFile[1], &wfd.cFileName[0], HIGH_ADR, HIGH_ADR)); */
if (!pTo) /* FO_DELETE */ if (!pTo) /* FO_DELETE */
{ {
do ret = file_operation_delete(&wfd,nFileOp,pFromFile,pTempFrom,&hFind);
{ /* if ret is not 0, nFileOp.fAnyOperationsAborted is TRUE */
lpFileName = wfd.cAlternateFileName; if (ret != 0)
if (!lpFileName[0])
lpFileName = wfd.cFileName;
if (IsDotDir(lpFileName) ||
((b_Mask) && IsAttribDir(wfd.dwFileAttributes) && (nFileOp.fFlags & FOF_FILESONLY)))
continue;
SHFileStrCpyCatW(&pFromFile[1], lpFileName, NULL);
/* TODO: Check the SHELL_DeleteFileOrDirectoryW() function in shell32.dll */
if (IsAttribFile(wfd.dwFileAttributes))
{ {
if(SHNotifyDeleteFileW(pTempFrom) != ERROR_SUCCESS) retCode = ret;
{
nFileOp.fAnyOperationsAborted = TRUE;
retCode = 0x78; /* value unknown */
}
}
else
{
if(!SHELL_DeleteDirectoryW(pTempFrom, (!(nFileOp.fFlags & FOF_NOCONFIRMATION))))
{
nFileOp.fAnyOperationsAborted = TRUE;
retCode = 0x79; /* value unknown */
}
}
} while (!nFileOp.fAnyOperationsAborted && FindNextFileW(hFind, &wfd));
FindClose(hFind);
hFind = INVALID_HANDLE_VALUE;
if (nFileOp.fAnyOperationsAborted)
goto shfileop_end; goto shfileop_end;
}
continue; continue;
} /* FO_DELETE ends, pTo must be always valid from here */ } /* FO_DELETE ends, pTo must be always valid from here */
......
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