shell32: return all attributes

Vitaliy Margolen wine-patch at kievinfo.com
Tue Jun 28 23:37:06 CDT 2005


Return full set of attributes for files and folder regardless of what we been
asked for. Tests to confirm it.

Depends on http://www.winehq.com/hypermail/wine-patches/2005/06/0659.html or
this will cause an infinite loop.

Vitaliy Margolen

changelog:
  dlls/shell32/shlfolder.c
    Return all attributes for files and folders
-------------- next part --------------
Index: dlls/shell32/shlfolder.c
===================================================================
RCS file: /home/wine/wine/dlls/shell32/shlfolder.c,v
retrieving revision 1.101
@@ -409,16 +421,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.19
diff -u -p -r1.19 shlfolder.c
--- dlls/shell32/tests/shlfolder.c	24 Jun 2005 11:33:35 -0000	1.19
+++ dlls/shell32/tests/shlfolder.c	29 Jun 2005 04:28:40 -0000
@@ -114,14 +118,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);
@@ -154,11 +159,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_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]);
+
+        flags = SFGAO_testfor;
         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]);
     }
 
     for (i=0;i<5;i++)


More information about the wine-patches mailing list