Commit 73f78472 authored by Alexandre Julliard's avatar Alexandre Julliard

Authors: Vitaliy Margolen <wine-patch@kievinfo.com>, Michael Jung <mjung@iss.tu-darmstadt.de>

Set all capability flags supported by the shellfolder, disregarding the flag mask given to GetAttributesOf. Unit tests to demonstrate this behaviour.
parent 1238fda6
...@@ -828,12 +828,12 @@ static HRESULT WINAPI UnixFolder_IShellFolder2_GetAttributesOf(IShellFolder2* if ...@@ -828,12 +828,12 @@ static HRESULT WINAPI UnixFolder_IShellFolder2_GetAttributesOf(IShellFolder2* if
char szAbsolutePath[FILENAME_MAX], *pszRelativePath; char szAbsolutePath[FILENAME_MAX], *pszRelativePath;
UINT i; UINT i;
*rgfInOut &= SFGAO_FOLDER|SFGAO_HASSUBFOLDER|SFGAO_FILESYSANCESTOR|SFGAO_CANRENAME| *rgfInOut = SFGAO_CANCOPY|SFGAO_CANMOVE|SFGAO_CANLINK|SFGAO_CANRENAME|SFGAO_CANDELETE|
SFGAO_FILESYSTEM; SFGAO_HASPROPSHEET|SFGAO_DROPTARGET|SFGAO_FILESYSTEM;
lstrcpyA(szAbsolutePath, This->m_pszPath); lstrcpyA(szAbsolutePath, This->m_pszPath);
pszRelativePath = szAbsolutePath + lstrlenA(szAbsolutePath); pszRelativePath = szAbsolutePath + lstrlenA(szAbsolutePath);
for (i=0; i<cidl; i++) { for (i=0; i<cidl; i++) {
if ((*rgfInOut & SFGAO_FILESYSTEM) && !(This->m_dwAttributes & SFGAO_FILESYSTEM)) { if (!(This->m_dwAttributes & SFGAO_FILESYSTEM)) {
struct stat fileStat; struct stat fileStat;
char *pszName = _ILGetTextPointer(apidl[i]); char *pszName = _ILGetTextPointer(apidl[i]);
if (!pszName) return E_INVALIDARG; if (!pszName) return E_INVALIDARG;
...@@ -841,8 +841,8 @@ static HRESULT WINAPI UnixFolder_IShellFolder2_GetAttributesOf(IShellFolder2* if ...@@ -841,8 +841,8 @@ static HRESULT WINAPI UnixFolder_IShellFolder2_GetAttributesOf(IShellFolder2* if
if (stat(szAbsolutePath, &fileStat) || !UNIXFS_is_dos_device(&fileStat)) if (stat(szAbsolutePath, &fileStat) || !UNIXFS_is_dos_device(&fileStat))
*rgfInOut &= ~SFGAO_FILESYSTEM; *rgfInOut &= ~SFGAO_FILESYSTEM;
} }
if (!_ILIsFolder(apidl[i])) if (_ILIsFolder(apidl[i]))
*rgfInOut &= ~(SFGAO_FOLDER|SFGAO_HASSUBFOLDER|SFGAO_FILESYSANCESTOR); *rgfInOut |= SFGAO_FOLDER|SFGAO_HASSUBFOLDER|SFGAO_FILESYSANCESTOR;
} }
} }
......
...@@ -419,16 +419,23 @@ HRESULT SHELL32_GetItemAttributes (IShellFolder * psf, LPCITEMIDLIST pidl, LPDWO ...@@ -419,16 +419,23 @@ HRESULT SHELL32_GetItemAttributes (IShellFolder * psf, LPCITEMIDLIST pidl, LPDWO
} else if (_ILGetDataPointer (pidl)) { } else if (_ILGetDataPointer (pidl)) {
dwAttributes = _ILGetFileAttributes (pidl, NULL, 0); dwAttributes = _ILGetFileAttributes (pidl, NULL, 0);
if ((SFGAO_FILESYSANCESTOR & *pdwAttributes) && !(dwAttributes & FILE_ATTRIBUTE_DIRECTORY)) /* Set common attributes */
*pdwAttributes &= ~SFGAO_FILESYSANCESTOR; *pdwAttributes |= SFGAO_FILESYSTEM | SFGAO_DROPTARGET | SFGAO_HASPROPSHEET | SFGAO_CANDELETE |
SFGAO_CANRENAME | SFGAO_CANLINK | SFGAO_CANMOVE | SFGAO_CANCOPY;
if ((SFGAO_FOLDER & *pdwAttributes) && !(dwAttributes & FILE_ATTRIBUTE_DIRECTORY))
*pdwAttributes &= ~(SFGAO_FOLDER | SFGAO_HASSUBFOLDER); if (dwAttributes & FILE_ATTRIBUTE_DIRECTORY)
*pdwAttributes |= (SFGAO_FOLDER | SFGAO_HASSUBFOLDER | SFGAO_FILESYSANCESTOR);
if ((SFGAO_HIDDEN & *pdwAttributes) && !(dwAttributes & FILE_ATTRIBUTE_HIDDEN)) else
*pdwAttributes &= ~(SFGAO_FOLDER | SFGAO_HASSUBFOLDER | SFGAO_FILESYSANCESTOR);
if (dwAttributes & FILE_ATTRIBUTE_HIDDEN)
*pdwAttributes |= SFGAO_HIDDEN;
else
*pdwAttributes &= ~SFGAO_HIDDEN; *pdwAttributes &= ~SFGAO_HIDDEN;
if ((SFGAO_READONLY & *pdwAttributes) && !(dwAttributes & FILE_ATTRIBUTE_READONLY)) if (dwAttributes & FILE_ATTRIBUTE_READONLY)
*pdwAttributes |= SFGAO_READONLY;
else
*pdwAttributes &= ~SFGAO_READONLY; *pdwAttributes &= ~SFGAO_READONLY;
if (SFGAO_LINK & *pdwAttributes) { if (SFGAO_LINK & *pdwAttributes) {
......
...@@ -163,14 +163,15 @@ static void test_EnumObjects(IShellFolder *iFolder) ...@@ -163,14 +163,15 @@ static void test_EnumObjects(IShellFolder *iFolder)
{ 1, 1, 1, 1, 0} { 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] = static const ULONG attrs[5] =
{ {
SFGAO_FILESYSTEM | SFGAO_FOLDER | SFGAO_FILESYSANCESTOR, SFGAO_CAPABILITYMASK | SFGAO_FILESYSTEM | SFGAO_FOLDER | SFGAO_FILESYSANCESTOR,
SFGAO_FILESYSTEM | SFGAO_FOLDER | SFGAO_FILESYSANCESTOR, SFGAO_CAPABILITYMASK | SFGAO_FILESYSTEM | SFGAO_FOLDER | SFGAO_FILESYSANCESTOR,
SFGAO_FILESYSTEM, SFGAO_CAPABILITYMASK | SFGAO_FILESYSTEM,
SFGAO_FILESYSTEM, SFGAO_CAPABILITYMASK | SFGAO_FILESYSTEM,
SFGAO_FILESYSTEM, SFGAO_CAPABILITYMASK | SFGAO_FILESYSTEM,
}; };
hr = IShellFolder_EnumObjects(iFolder, NULL, SHCONTF_FOLDERS | SHCONTF_NONFOLDERS | SHCONTF_INCLUDEHIDDEN, &iEnumList); hr = IShellFolder_EnumObjects(iFolder, NULL, SHCONTF_FOLDERS | SHCONTF_NONFOLDERS | SHCONTF_INCLUDEHIDDEN, &iEnumList);
...@@ -206,11 +207,18 @@ static void test_EnumObjects(IShellFolder *iFolder) ...@@ -206,11 +207,18 @@ static void test_EnumObjects(IShellFolder *iFolder)
for (i = 0; i < 5; i++) for (i = 0; i < 5; i++)
{ {
SFGAOF flags; 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); 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(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++) for (i=0;i<5;i++)
......
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