shell32: Return all attributes of regardless of what being asked for. With tests.

Vitaliy Margolen wine-patch at kievinfo.com
Tue Nov 1 17:05:53 CST 2005



Vitaliy Margolen

changelog:
  shell32
  - Return all attributes of regardless of what being asked for. With tests.
-------------- next part --------------
Index: dlls/shell32/shlfolder.c
===================================================================
RCS file: /home/wine/wine/dlls/shell32/shlfolder.c,v
retrieving revision 1.105
diff -u -p -r1.105 shlfolder.c
--- dlls/shell32/shlfolder.c	1 Nov 2005 09:34:03 -0000	1.105
+++ dlls/shell32/shlfolder.c	1 Nov 2005 23:03:25 -0000
@@ -419,16 +419,23 @@ HRESULT SHELL32_GetItemAttributes (IShel
     } else if (_ILGetDataPointer (pidl)) {
 	dwAttributes = _ILGetFileAttributes (pidl, NULL, 0);
 
-        if ((SFGAO_FILESYSANCESTOR & *pdwAttributes) && !(dwAttributes & FILE_ATTRIBUTE_DIRECTORY))
-            *pdwAttributes &= ~SFGAO_FILESYSANCESTOR;
-
-	if ((SFGAO_FOLDER & *pdwAttributes) && !(dwAttributes & FILE_ATTRIBUTE_DIRECTORY))
-	    *pdwAttributes &= ~(SFGAO_FOLDER | SFGAO_HASSUBFOLDER);
-
-	if ((SFGAO_HIDDEN & *pdwAttributes) && !(dwAttributes & FILE_ATTRIBUTE_HIDDEN))
+        /* Set common attributes */
+        *pdwAttributes |= SFGAO_FILESYSTEM | SFGAO_DROPTARGET | SFGAO_HASPROPSHEET | SFGAO_CANDELETE | 
+                          SFGAO_CANRENAME | SFGAO_CANLINK | SFGAO_CANMOVE | SFGAO_CANCOPY;
+
+	if (dwAttributes & FILE_ATTRIBUTE_DIRECTORY)
+	    *pdwAttributes |=  (SFGAO_FOLDER | SFGAO_HASSUBFOLDER | SFGAO_FILESYSANCESTOR);
+	else
+	    *pdwAttributes &= ~(SFGAO_FOLDER | SFGAO_HASSUBFOLDER | SFGAO_FILESYSANCESTOR);
+
+	if (dwAttributes & FILE_ATTRIBUTE_HIDDEN)
+	    *pdwAttributes |=  SFGAO_HIDDEN;
+	else
 	    *pdwAttributes &= ~SFGAO_HIDDEN;
 
-	if ((SFGAO_READONLY & *pdwAttributes) && !(dwAttributes & FILE_ATTRIBUTE_READONLY))
+	if (dwAttributes & FILE_ATTRIBUTE_READONLY)
+	    *pdwAttributes |=  SFGAO_READONLY;
+	else
 	    *pdwAttributes &= ~SFGAO_READONLY;
 
 	if (SFGAO_LINK & *pdwAttributes) {
Index: dlls/shell32/tests/shlfolder.c
===================================================================
RCS file: /home/wine/wine/dlls/shell32/tests/shlfolder.c,v
retrieving revision 1.39
diff -u -p -r1.39 shlfolder.c
--- dlls/shell32/tests/shlfolder.c	27 Oct 2005 12:09:59 -0000	1.39
+++ dlls/shell32/tests/shlfolder.c	1 Nov 2005 23:03:26 -0000
@@ -163,14 +163,15 @@ static void test_EnumObjects(IShellFolde
 	{ 1, 1, 1, 1, 0}
     };
 
-    /* Just test SFGAO_FILESYSTEM | SFGAO_FOLDER | SFGAO_FILESYSANCESTOR for now */
+#define SFGAO_testfor SFGAO_FILESYSTEM | SFGAO_FOLDER | SFGAO_FILESYSANCESTOR | SFGAO_CAPABILITYMASK
+    /* Don't test for SFGAO_HASSUBFOLDER since we return real state and native cached */
     static const ULONG attrs[5] =
     {
-        SFGAO_FILESYSTEM | SFGAO_FOLDER | SFGAO_FILESYSANCESTOR,
-        SFGAO_FILESYSTEM | SFGAO_FOLDER | SFGAO_FILESYSANCESTOR,
-        SFGAO_FILESYSTEM,
-        SFGAO_FILESYSTEM,
-        SFGAO_FILESYSTEM,
+        SFGAO_CAPABILITYMASK | SFGAO_FILESYSTEM | SFGAO_FOLDER | SFGAO_FILESYSANCESTOR,
+        SFGAO_CAPABILITYMASK | SFGAO_FILESYSTEM | SFGAO_FOLDER | SFGAO_FILESYSANCESTOR,
+        SFGAO_CAPABILITYMASK | SFGAO_FILESYSTEM,
+        SFGAO_CAPABILITYMASK | SFGAO_FILESYSTEM,
+        SFGAO_CAPABILITYMASK | SFGAO_FILESYSTEM,
     };
 
     hr = IShellFolder_EnumObjects(iFolder, NULL, SHCONTF_FOLDERS | SHCONTF_NONFOLDERS | SHCONTF_INCLUDEHIDDEN, &iEnumList);
@@ -206,11 +207,18 @@ static void test_EnumObjects(IShellFolde
     for (i = 0; i < 5; i++)
     {
         SFGAOF flags;
-        flags = SFGAO_FILESYSTEM | SFGAO_FOLDER | SFGAO_FILESYSANCESTOR;
+        /* Native returns all flags no matter what we ask for */
+        flags = SFGAO_CANCOPY;
         hr = IShellFolder_GetAttributesOf(iFolder, 1, (LPCITEMIDLIST*)(idlArr + i), &flags);
-        flags &= SFGAO_FILESYSTEM | SFGAO_FOLDER | SFGAO_FILESYSANCESTOR;
+        flags &= SFGAO_testfor;
         ok(hr == S_OK, "GetAttributesOf returns %08lx\n", hr);
-        ok(flags == attrs[i], "GetAttributesOf gets attrs %08lx, expects %08lx\n", flags, attrs[i]);
+        ok(flags == (attrs[i]), "GetAttributesOf[%i] got %08lx, expected %08lx\n", i, flags, attrs[i]);
+
+        flags = SFGAO_testfor;
+        hr = IShellFolder_GetAttributesOf(iFolder, 1, (LPCITEMIDLIST*)(idlArr + i), &flags);
+        flags &= SFGAO_testfor;
+        ok(hr == S_OK, "GetAttributesOf returns %08lx\n", hr);
+        ok(flags == attrs[i], "GetAttributesOf[%i] got %08lx, expected %08lx\n", i, flags, attrs[i]);
     }
 
     for (i=0;i<5;i++)


More information about the wine-patches mailing list