SHELL32: reduce the number of goto labels in SHFileOperation by one
Mike McCormack
mike at codeweavers.com
Sun Aug 15 06:04:47 CDT 2004
ChangeLog:
* reduce the number of goto labels in SHFileOperation by one
-------------- next part --------------
--- dlls/shell32/shlfileop.c.old 2004-08-15 13:28:29.000000000 +0900
+++ dlls/shell32/shlfileop.c 2004-08-15 13:28:48.000000000 +0900
@@ -792,6 +792,9 @@
return wine_dbg_sprintf("%s", cFO_Name[ op ]);
}
+#define ERROR_SHELL_INTERNAL_FILE_NOT_FOUND 1026
+#define HIGH_ADR (LPWSTR)0xffffffff
+
/*************************************************************************
* SHFileOperationW [SHELL32.@]
*
@@ -839,7 +842,7 @@
nFileOp.fAnyOperationsAborted = FALSE;
if ((FuncSwitch < FO_MOVE) || (FuncSwitch > FO_RENAME))
- goto shfileop_normal; /* no valid FunctionCode */
+ goto shfileop_end; /* no valid FunctionCode */
if (level == 0)
TRACE("%s: flags (0x%04x) : %s\n",
@@ -896,7 +899,7 @@
TRACE("%s level=%ld lpFileOp->fFlags=0x%x not implemented, Aborted=TRUE, stub\n",
debug_shfileops_action(FuncSwitch), level, OFl);
retCode = 0x403; /* 1027, we need an extension to shlfileop */
- goto shfileop_error;
+ goto shfileop_end;
}
else
{
@@ -912,7 +915,7 @@
{
retCode = ERROR_OUTOFMEMORY;
SetLastError(retCode);
- goto shfileop_error;
+ goto shfileop_end;
}
if (b_MultiTo)
pTempTo = &pTempFrom[MAX_PATH + 4];
@@ -922,8 +925,8 @@
}
else
{
- retCode = 0x402; /* 1026 */
- goto shfileop_error;
+ retCode = ERROR_SHELL_INTERNAL_FILE_NOT_FOUND;
+ goto shfileop_end;
}
/* need break at error before change sourcepointer */
while(!nFileOp.fAnyOperationsAborted && (pNextFrom[0]))
@@ -956,8 +959,8 @@
}
if (!(b_MultiPaired) || !(pFromFile) || !(pFromFile[1]) || ((pTo) && !(pToFile)))
{
- retCode = 0x402; /* 1026 */
- goto shfileop_error;
+ retCode = ERROR_SHELL_INTERNAL_FILE_NOT_FOUND;
+ goto shfileop_end;
}
if (pTo)
{
@@ -983,7 +986,7 @@
#ifndef W98_FO_FUNCTION
retCode = ERROR_GEN_FAILURE; /* W2K ERROR_GEN_FAILURE, W98 returns no error */
#endif
- goto shfileop_error;
+ goto shfileop_end;
}
}
@@ -998,18 +1001,17 @@
if (IsAttribDir(FromPathAttr))
{
/* FO_DELETE with mask and without found is valid */
- goto shfileop_normal;
+ goto shfileop_end;
}
}
/* root (without mask) is also not allowed as source, tested in W98 */
- retCode = 0x402; /* 1026 */
- goto shfileop_error;
+ retCode = ERROR_SHELL_INTERNAL_FILE_NOT_FOUND;
+ goto shfileop_end;
}
-/* for all */
-#define HIGH_ADR (LPWSTR)0xffffffff
+ /* for all */
-/* ??? 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 */
{
do
@@ -1024,21 +1026,25 @@
/* TODO: Check the SHELL_DeleteFileOrDirectoryW() function in shell32.dll */
if (IsAttribFile(wfd.dwFileAttributes))
{
- nFileOp.fAnyOperationsAborted = (SHNotifyDeleteFileW(pTempFrom) != ERROR_SUCCESS);
- retCode = 0x78; /* value unknown */
+ if(SHNotifyDeleteFileW(pTempFrom) != ERROR_SUCCESS)
+ {
+ nFileOp.fAnyOperationsAborted = TRUE;
+ retCode = 0x78; /* value unknown */
+ }
}
else
{
- nFileOp.fAnyOperationsAborted = (!SHELL_DeleteDirectoryW(pTempFrom, (!(nFileOp.fFlags & FOF_NOCONFIRMATION))));
- retCode = 0x79; /* value unknown */
+ 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_error;
- }
+ goto shfileop_end;
continue;
} /* FO_DELETE ends, pTo must be always valid from here */
@@ -1060,31 +1066,31 @@
|| (SHFileStrICmpW(pTempFrom, pTempTo, pFromFile, HIGH_ADR) && !b_ToTailSlash))
{
retCode = 0x73;
- goto shfileop_error;
+ goto shfileop_end;
}
if (b_ToInvalidTail)
{
retCode=0x2;
- goto shfileop_error;
+ goto shfileop_end;
}
if (-1 == ToPathAttr)
{
retCode = 0x75;
- goto shfileop_error;
+ goto shfileop_end;
}
if (IsAttribDir(wfd.dwFileAttributes) && IsAttribDir(ToAttr))
{
retCode = (b_ToTailSlash) ? 0xb7 : 0x7b;
- goto shfileop_error;
+ goto shfileop_end;
}
/* we use SHNotifyMoveFile() instead MoveFileW */
if (SHNotifyMoveFileW(pTempFrom, pTempTo, nFileOp.fFlags & FOF_RENAMEONCOLLISION) != ERROR_SUCCESS)
{
/* we need still the value for the returncode, we use the mostly assumed */
retCode = 0xb7;
- goto shfileop_error;
+ goto shfileop_end;
}
- goto shfileop_normal;
+ goto shfileop_end;
}
/* W98 Bug with FO_MOVE different from FO_COPY, better the same as FO_COPY */
@@ -1098,7 +1104,7 @@
{
retCode = (b_ToInvalidTail &&/* b_SameTailName &&*/ (FO_MOVE == FuncSwitch)) \
? 0x2 : 0x75;
- goto shfileop_error;
+ goto shfileop_end;
}
pToFile = SHFileStrCpyCatW(pTempTo, NULL, wBackslash);
nFileOp.fFlags = (nFileOp.fFlags | FOF_MULTIDESTFILES);
@@ -1134,7 +1140,7 @@
if (SHCreateDirectoryExW(NULL, pTempTo, NULL))
{
retCode = 0x73;/* value unknown */
- goto shfileop_error;
+ goto shfileop_end;
}
ToPathAttr = GetFileAttributesW(pTempTo);
}
@@ -1142,7 +1148,7 @@
if (b_ToInvalidTail)
{
retCode = 0x10003;
- goto shfileop_error;
+ goto shfileop_end;
}
}
}
@@ -1155,7 +1161,7 @@
if (b_Multi)
{
retCode = 0x73; /* !b_Multi = 0x8 ?? */
- goto shfileop_error;
+ goto shfileop_end;
}
}
pToFile = SHFileStrCpyCatW(pTempTo, NULL, wfd.cFileName);
@@ -1167,7 +1173,7 @@
if (IsAttribFile(wfd.dwFileAttributes))
{
retCode = (FO_COPY == FuncSwitch) ? 0x75 : 0xb7;
- goto shfileop_error;
+ goto shfileop_end;
}
}
else
@@ -1179,7 +1185,7 @@
{
/* error, is this tested ? */
retCode = 0x777402;
- goto shfileop_error;
+ goto shfileop_end;
}
}
@@ -1188,7 +1194,7 @@
{
/* Target-dir does not exist, and cannot be created */
retCode=0x75;
- goto shfileop_error;
+ goto shfileop_end;
}
switch(FuncSwitch)
@@ -1225,20 +1231,20 @@
{ /* target is the same as source ? */
/* we still need the value for the returncode, we assume 0x71 */
retCode = 0x71;
- goto shfileop_error;
+ goto shfileop_end;
}
if (IsAttribDir((ToAttr & wfd.dwFileAttributes)))
{
if (IsAttribDir(ToAttr) || !SHCreateDirectoryExW(NULL,pTempTo, NULL))
{
-/* ??? nFileOp.fFlags = (nFileOp.fFlags | FOF_MULTIDESTFILES); */
+ /* ??? nFileOp.fFlags = (nFileOp.fFlags | FOF_MULTIDESTFILES); */
SHFileStrCpyCatW(pTempFrom, NULL, wWildcardFile);
retCode = SHFileOperationW(&nFileOp);
}
else
{
retCode = 0x750;/* value unknown */
- goto shfileop_error;
+ goto shfileop_end;
}
}
else
@@ -1248,30 +1254,25 @@
{
/* we still need the value for the returncode, we use the mostly assumed */
retCode = 0x73;
- goto shfileop_error;
+ goto shfileop_end;
}
if (SHNotifyCopyFileW(pTempFrom, pTempTo, nFileOp.fFlags & FOF_RENAMEONCOLLISION) != ERROR_SUCCESS)
{
retCode = 0x77; /* value unknown */
- goto shfileop_error;
+ goto shfileop_end;
}
}
}
}
-shfileop_normal:
- if (!(nFileOp.fAnyOperationsAborted))
- retCode = 0;
-shfileop_error:
+shfileop_end:
if (hFind != INVALID_HANDLE_VALUE)
- FindClose(hFind);
+ FindClose(hFind);
hFind = INVALID_HANDLE_VALUE;
if (pTempFrom)
- HeapFree(GetProcessHeap(), 0, pTempFrom);
+ HeapFree(GetProcessHeap(), 0, pTempFrom);
if (retCode)
- {
- nFileOp.fAnyOperationsAborted = TRUE;
- }
+ nFileOp.fAnyOperationsAborted = TRUE;
TRACE("%s level=%ld AnyOpsAborted=%s ret=0x%x, with %s %s%s\n",
debug_shfileops_action(FuncSwitch), level,
nFileOp.fAnyOperationsAborted ? "TRUE":"FALSE",
More information about the wine-patches
mailing list