From 45bcdd2be1f96c8a2e9eb51131d772f66aae038b Mon Sep 17 00:00:00 2001 From: Michael Jung Date: Thu, 5 May 2005 10:30:51 +0000 Subject: [PATCH] Fixed GetDisplayNameOf method to not depend on incorrect behaviour regarding the SHGDN_INFOLDER flag. --- dlls/shell32/shfldr_fs.c | 69 ++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 41 deletions(-) diff --git a/dlls/shell32/shfldr_fs.c b/dlls/shell32/shfldr_fs.c index 4d0a9b449ae..c1e5ee82114 100644 --- a/dlls/shell32/shfldr_fs.c +++ b/dlls/shell32/shfldr_fs.c @@ -749,56 +749,43 @@ IShellFolder_fnGetDisplayNameOf (IShellFolder2 * iface, LPCITEMIDLIST pidl, { _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl, iface) - CHAR szPath[MAX_PATH]; + HRESULT hr = S_OK; int len = 0; - BOOL bSimplePidl; - - *szPath = '\0'; TRACE ("(%p)->(pidl=%p,0x%08lx,%p)\n", This, pidl, dwFlags, strRet); pdump (pidl); if (!pidl || !strRet) return E_INVALIDARG; - - bSimplePidl = _ILIsPidlSimple (pidl); - - /* take names of special folders only if its only this folder */ - if (_ILIsSpecialFolder (pidl)) { - if (bSimplePidl) { - _ILSimpleGetText (pidl, szPath, MAX_PATH); /* append my own path */ - } else { - FIXME ("special pidl\n"); - } - } else { - if (!(dwFlags & SHGDN_INFOLDER) && (dwFlags & SHGDN_FORPARSING) && - This->sPathTarget) { - /* get path to root */ - lstrcpyA (szPath, This->sPathTarget); - PathAddBackslashA (szPath); - len = lstrlenA (szPath); - } - /* append my own path */ - _ILSimpleGetText (pidl, szPath + len, MAX_PATH - len); - - if (!_ILIsFolder(pidl)) - SHELL_FS_ProcessDisplayFilename(szPath, dwFlags); - } - - /* go deeper if needed */ - if ((dwFlags & SHGDN_FORPARSING) && !bSimplePidl) { - PathAddBackslashA (szPath); - len = lstrlenA (szPath); - - if (!SUCCEEDED(SHELL32_GetDisplayNameOfChild (iface, pidl, - dwFlags | SHGDN_INFOLDER, szPath + len, MAX_PATH - len))) - return E_OUTOFMEMORY; - } + strRet->uType = STRRET_CSTR; - lstrcpynA (strRet->u.cStr, szPath, MAX_PATH); + if (_ILIsDesktop(pidl)) { /* empty pidl */ + if ((GET_SHGDN_FOR(dwFlags) == SHGDN_FORPARSING) && + (GET_SHGDN_RELATION(dwFlags) != SHGDN_INFOLDER)) + { + if (This->sPathTarget) + lstrcpynA(strRet->u.cStr, This->sPathTarget, MAX_PATH); + } else { + /* pidl has to contain exactly one non null SHITEMID */ + hr = E_INVALIDARG; + } + } else if (_ILIsPidlSimple(pidl)) { + if ((GET_SHGDN_FOR(dwFlags) == SHGDN_FORPARSING) && + (GET_SHGDN_RELATION(dwFlags) != SHGDN_INFOLDER) && + This->sPathTarget) + { + lstrcpynA(strRet->u.cStr, This->sPathTarget, MAX_PATH); + PathAddBackslashA(strRet->u.cStr); + len = lstrlenA(strRet->u.cStr); + } + _ILSimpleGetText(pidl, strRet->u.cStr + len, MAX_PATH - len); + if (!_ILIsFolder(pidl)) SHELL_FS_ProcessDisplayFilename(strRet->u.cStr, dwFlags); + } else { + hr = SHELL32_GetDisplayNameOfChild(iface, pidl, dwFlags, strRet->u.cStr, MAX_PATH); + } - TRACE ("-- (%p)->(%s)\n", This, szPath); - return S_OK; + TRACE ("-- (%p)->(%s)\n", This, strRet->u.cStr); + return hr; } /**************************************************************************