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.
This commit is contained in:
Alexandre Julliard 2005-11-03 09:56:07 +00:00
parent 1238fda624
commit 73f7847297
3 changed files with 35 additions and 20 deletions

View File

@ -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
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;
} }
} }

View File

@ -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)) if (dwAttributes & FILE_ATTRIBUTE_DIRECTORY)
*pdwAttributes &= ~(SFGAO_FOLDER | SFGAO_HASSUBFOLDER); *pdwAttributes |= (SFGAO_FOLDER | SFGAO_HASSUBFOLDER | SFGAO_FILESYSANCESTOR);
else
*pdwAttributes &= ~(SFGAO_FOLDER | SFGAO_HASSUBFOLDER | SFGAO_FILESYSANCESTOR);
if ((SFGAO_HIDDEN & *pdwAttributes) && !(dwAttributes & FILE_ATTRIBUTE_HIDDEN)) 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) {

View File

@ -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)
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++)