cleanup shlfileop.c
Joris Huizer
jorishuizer at planet.nl
Tue Jan 18 10:14:51 CST 2005
Changelog:
- use retCode smarter (undoing a few bits of myself)
- add file_operation_invalid_handle() instead of inline code
-------------- next part --------------
? .shlfile.diff.swp
? backup-010320051808-pre-wine.tgz
? backup-010920052053-pre-wine.tgz
? backup-011120051329-pre-wine.tgz
? backup-011120051339-pre-wine.tgz
? backup-011220050008-pre-wine.tgz
? backup-011720051611-pre-wine.tgz
? backup-011820051406-pre-wine.tgz
? backup-123120041614-pre-wine.tgz
? badrefs
? description-pak
? doc-pak
? getrefs
? patch.diff
? ref
? refs
? shlfile.diff
? strncpy.out
? thisref.sh
? versions
? wine-working.deb
? wine_cvs-041231-1_i386.deb
? wine_cvs-050103-1_i386.deb
? wine_cvs-050109-1_i386.deb
? wine_cvs-050111.noalsa-1_i386.deb
? wine_cvs-050112.release-1_i386.deb
? wine_cvs-050117-1_i386.deb
? wine_cvs-050118.with-opengl-1_i386.deb
? dlls/shell32/shlfileop.c.0
? dlls/shell32/shlfileop.c.1
? programs/notepad2
Index: dlls/shell32/shlfileop.c
===================================================================
RCS file: /home/wine/wine/dlls/shell32/shlfileop.c,v
retrieving revision 1.51
diff -u -r1.51 shlfileop.c
--- dlls/shell32/shlfileop.c 14 Jan 2005 16:51:14 -0000 1.51
+++ dlls/shell32/shlfileop.c 18 Jan 2005 16:13:37 -0000
@@ -945,6 +945,25 @@
return 0;
}
+static int file_operation_invalid_handle(long FuncSwitch, LPWSTR pFromFile, DWORD ToPathAttr, LPWSTR pTempFrom)
+{
+ BOOL b_Mask = (NULL != StrPBrkW(&pFromFile[1], wWildcardChars));
+ if ((FO_DELETE == FuncSwitch) && (b_Mask))
+ {
+ DWORD FromPathAttr;
+ pFromFile[0] = '\0';
+ FromPathAttr = GetFileAttributesW(pTempFrom);
+ pFromFile[0] = '\\';
+ if (IsAttribDir(FromPathAttr))
+ {
+ /* FO_DELETE with mask and without found is valid */
+ return 0;
+ }
+ }
+ /* root (without mask) is also not allowed as source, tested in W98 */
+ return ERROR_SHELL_INTERNAL_FILE_NOT_FOUND;
+}
+
/*************************************************************************
* SHFileOperationW [SHELL32.@]
*
@@ -964,7 +983,6 @@
LPWSTR pTempTo = NULL;
LPWSTR pFromFile;
LPWSTR pToFile = NULL;
- LPWSTR lpFileName;
int retCode = 0;
DWORD ToAttr;
DWORD ToPathAttr;
@@ -986,8 +1004,6 @@
long FuncSwitch = (nFileOp.wFunc & FO_MASK);
long level= nFileOp.wFunc>>4;
- int ret;
-
/* default no error */
nFileOp.fAnyOperationsAborted = FALSE;
@@ -1016,10 +1032,9 @@
* create dir 0 0 0 0 0 0 1 0
*/
- ret = file_operation_checkFlags(nFileOp);
- if (ret != 0)
+ retCode = file_operation_checkFlags(nFileOp);
+ if (retCode)
{
- retCode = ret;
goto shfileop_end;
}
@@ -1108,20 +1123,7 @@
hFind = FindFirstFileW(pFrom, &wfd);
if (INVALID_HANDLE_VALUE == hFind)
{
- if ((FO_DELETE == FuncSwitch) && (b_Mask))
- {
- DWORD FromPathAttr;
- pFromFile[0] = '\0';
- FromPathAttr = GetFileAttributesW(pTempFrom);
- pFromFile[0] = '\\';
- if (IsAttribDir(FromPathAttr))
- {
- /* FO_DELETE with mask and without found is valid */
- goto shfileop_end;
- }
- }
- /* root (without mask) is also not allowed as source, tested in W98 */
- retCode = ERROR_SHELL_INTERNAL_FILE_NOT_FOUND;
+ retCode = file_operation_invalid_handle(FuncSwitch,pFromFile,ToPathAttr,pTempFrom);
goto shfileop_end;
}
@@ -1130,11 +1132,10 @@
/* ??? b_Mask = (!SHFileStrICmpA(&pFromFile[1], &wfd.cFileName[0], HIGH_ADR, HIGH_ADR)); */
if (!pTo) /* FO_DELETE */
{
- ret = file_operation_delete(&wfd,nFileOp,pFromFile,pTempFrom,&hFind);
- /* if ret is not 0, nFileOp.fAnyOperationsAborted is TRUE */
- if (ret != 0)
+ retCode = file_operation_delete(&wfd,nFileOp,pFromFile,pTempFrom,&hFind);
+ /* if retCode is not 0, nFileOp.fAnyOperationsAborted is TRUE */
+ if (retCode)
{
- retCode = ret;
goto shfileop_end;
}
continue;
@@ -1202,7 +1203,7 @@
nFileOp.fFlags = (nFileOp.fFlags | FOF_MULTIDESTFILES);
do
{
- lpFileName = wfd.cAlternateFileName;
+ LPWSTR lpFileName = wfd.cAlternateFileName;
if (!lpFileName[0])
lpFileName = wfd.cFileName;
if (IsDotDir(lpFileName) ||
@@ -1369,7 +1370,6 @@
nFileOp.fAnyOperationsAborted ? "TRUE":"FALSE",
retCode, debugstr_w(pFrom), pTo ? "-> ":"", debugstr_w(pTo));
- lpFileOp->fAnyOperationsAborted = nFileOp.fAnyOperationsAborted;
return retCode;
}
Index: dlls/wined3d/basetexture.c
===================================================================
RCS file: /home/wine/wine/dlls/wined3d/basetexture.c,v
retrieving revision 1.3
diff -u -r1.3 basetexture.c
--- dlls/wined3d/basetexture.c 17 Jan 2005 13:44:57 -0000 1.3
+++ dlls/wined3d/basetexture.c 18 Jan 2005 16:13:37 -0000
@@ -37,16 +37,17 @@
ULONG WINAPI IWineD3DBaseTextureImpl_AddRef(IWineD3DBaseTexture *iface) {
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
- TRACE("(%p) : AddRef increasing from %ld\n", This, This->resource.ref);
+ ULONG ref = InterlockedIncrement(&This->resource.ref);
+
+ TRACE("(%p) : AddRef increasing from %ld\n", This,ref - 1);
IUnknown_AddRef(This->resource.parent);
- return InterlockedIncrement(&This->resource.ref);
+ return ref;
}
ULONG WINAPI IWineD3DBaseTextureImpl_Release(IWineD3DBaseTexture *iface) {
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
- ULONG ref;
- TRACE("(%p) : Releasing from %ld\n", This, This->resource.ref);
- ref = InterlockedDecrement(&This->resource.ref);
+ ULONG ref = InterlockedDecrement(&This->resource.ref);
+ TRACE("(%p) : Releasing from %ld\n", This, ref + 1);
if (ref == 0) {
IWineD3DDevice_Release((IWineD3DDevice *)This->resource.wineD3DDevice);
HeapFree(GetProcessHeap(), 0, This);
Index: dlls/wined3d/indexbuffer.c
===================================================================
RCS file: /home/wine/wine/dlls/wined3d/indexbuffer.c,v
retrieving revision 1.5
diff -u -r1.5 indexbuffer.c
--- dlls/wined3d/indexbuffer.c 17 Jan 2005 13:44:57 -0000 1.5
+++ dlls/wined3d/indexbuffer.c 18 Jan 2005 16:13:37 -0000
@@ -38,16 +38,16 @@
ULONG WINAPI IWineD3DIndexBufferImpl_AddRef(IWineD3DIndexBuffer *iface) {
IWineD3DIndexBufferImpl *This = (IWineD3DIndexBufferImpl *)iface;
- TRACE("(%p) : AddRef increasing from %ld\n", This, This->resource.ref);
+ ULONG ref = InterlockedIncrement(&This->resource.ref);
+ TRACE("(%p) : AddRef increasing from %ld\n", This, ref - 1);
IUnknown_AddRef(This->resource.parent);
- return InterlockedIncrement(&This->resource.ref);
+ return ref;
}
ULONG WINAPI IWineD3DIndexBufferImpl_Release(IWineD3DIndexBuffer *iface) {
IWineD3DIndexBufferImpl *This = (IWineD3DIndexBufferImpl *)iface;
- ULONG ref;
- TRACE("(%p) : Releasing from %ld\n", This, This->resource.ref);
- ref = InterlockedDecrement(&This->resource.ref);
+ ULONG ref = InterlockedDecrement(&This->resource.ref);
+ TRACE("(%p) : Releasing from %ld\n", This, ref + 1);
if (ref == 0) {
HeapFree(GetProcessHeap(), 0, This->allocatedMemory);
IWineD3DDevice_Release((IWineD3DDevice *)This->resource.wineD3DDevice);
Index: dlls/wined3d/resource.c
===================================================================
RCS file: /home/wine/wine/dlls/wined3d/resource.c,v
retrieving revision 1.4
diff -u -r1.4 resource.c
--- dlls/wined3d/resource.c 9 Jan 2005 17:37:02 -0000 1.4
+++ dlls/wined3d/resource.c 18 Jan 2005 16:13:37 -0000
@@ -36,15 +36,15 @@
ULONG WINAPI IWineD3DResourceImpl_AddRef(IWineD3DResource *iface) {
IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
- TRACE("(%p) : AddRef increasing from %ld\n", This, This->resource.ref);
- return InterlockedIncrement(&This->resource.ref);
+ ULONG ref = InterlockedIncrement(&This->resource.ref);
+ TRACE("(%p) : AddRef increasing from %ld\n", This, ref - 1);
+ return ref;
}
ULONG WINAPI IWineD3DResourceImpl_Release(IWineD3DResource *iface) {
IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
- ULONG ref;
- TRACE("(%p) : Releasing from %ld\n", This, This->resource.ref);
- ref = InterlockedDecrement(&This->resource.ref);
+ ULONG ref = InterlockedDecrement(&This->resource.ref);
+ TRACE("(%p) : Releasing from %ld\n", This, ref + 1);
if (ref == 0) {
IWineD3DDevice_Release((IWineD3DDevice *)This->resource.wineD3DDevice);
HeapFree(GetProcessHeap(), 0, This);
Index: dlls/wined3d/surface.c
===================================================================
RCS file: /home/wine/wine/dlls/wined3d/surface.c,v
retrieving revision 1.3
diff -u -r1.3 surface.c
--- dlls/wined3d/surface.c 18 Jan 2005 11:42:29 -0000 1.3
+++ dlls/wined3d/surface.c 18 Jan 2005 16:13:38 -0000
@@ -38,16 +38,16 @@
ULONG WINAPI IWineD3DSurfaceImpl_AddRef(IWineD3DSurface *iface) {
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
- TRACE("(%p) : AddRef increasing from %ld\n", This, This->resource.ref);
+ ULONG ref = InterlockedIncrement(&This->resource.ref);
+ TRACE("(%p) : AddRef increasing from %ld\n", This,ref - 1);
IUnknown_AddRef(This->resource.parent);
- return InterlockedIncrement(&This->resource.ref);
+ return ref;
}
ULONG WINAPI IWineD3DSurfaceImpl_Release(IWineD3DSurface *iface) {
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
- ULONG ref;
- TRACE("(%p) : Releasing from %ld\n", This, This->resource.ref);
- ref = InterlockedDecrement(&This->resource.ref);
+ ULONG ref = InterlockedDecrement(&This->resource.ref);
+ TRACE("(%p) : Releasing from %ld\n", This, ref + 1);
if (ref == 0) {
HeapFree(GetProcessHeap(), 0, This->allocatedMemory);
IWineD3DDevice_Release((IWineD3DDevice *)This->resource.wineD3DDevice);
Index: dlls/wined3d/vertexbuffer.c
===================================================================
RCS file: /home/wine/wine/dlls/wined3d/vertexbuffer.c,v
retrieving revision 1.7
diff -u -r1.7 vertexbuffer.c
--- dlls/wined3d/vertexbuffer.c 17 Jan 2005 13:44:57 -0000 1.7
+++ dlls/wined3d/vertexbuffer.c 18 Jan 2005 16:13:38 -0000
@@ -38,16 +38,16 @@
ULONG WINAPI IWineD3DVertexBufferImpl_AddRef(IWineD3DVertexBuffer *iface) {
IWineD3DVertexBufferImpl *This = (IWineD3DVertexBufferImpl *)iface;
- TRACE("(%p) : AddRef increasing from %ld\n", This, This->resource.ref);
+ ULONG ref = InterlockedIncrement(&This->resource.ref);
+ TRACE("(%p) : AddRef increasing from %ld\n", This, ref - 1);
IUnknown_AddRef(This->resource.parent);
- return InterlockedIncrement(&This->resource.ref);
+ return ref;
}
ULONG WINAPI IWineD3DVertexBufferImpl_Release(IWineD3DVertexBuffer *iface) {
IWineD3DVertexBufferImpl *This = (IWineD3DVertexBufferImpl *)iface;
- ULONG ref;
- TRACE("(%p) : Releasing from %ld\n", This, This->resource.ref);
- ref = InterlockedDecrement(&This->resource.ref);
+ ULONG ref = InterlockedDecrement(&This->resource.ref);
+ TRACE("(%p) : Releasing from %ld\n", This, ref + 1);
if (ref == 0) {
HeapFree(GetProcessHeap(), 0, This->allocatedMemory);
IWineD3DDevice_Release((IWineD3DDevice *)This->resource.wineD3DDevice);
More information about the wine-patches
mailing list