- handle IFileSystemBindData in ISF_Desktop_fnParseDisplayName

- more Unicode conversion
This commit is contained in:
Mike McCormack 2005-02-23 12:45:12 +00:00 committed by Alexandre Julliard
parent 14de57089e
commit f8a4f6b59b
6 changed files with 34 additions and 19 deletions

View File

@ -25,6 +25,7 @@
#define COBJMACROS
#include "wine/debug.h"
#include "wine/unicode.h"
#include "windef.h"
#include "winbase.h"
#include "winreg.h"
@ -103,24 +104,27 @@ BOOL AddToEnumList(
*/
BOOL CreateFolderEnumList(
IEnumIDList *list,
LPCSTR lpszPath,
LPCWSTR lpszPath,
DWORD dwFlags)
{
LPITEMIDLIST pidl=NULL;
WIN32_FIND_DATAA stffile;
WIN32_FIND_DATAW stffile;
HANDLE hFile;
CHAR szPath[MAX_PATH];
WCHAR szPath[MAX_PATH];
BOOL succeeded = TRUE;
const static WCHAR stars[] = { '*','.','*',0 };
const static WCHAR dot[] = { '.',0 };
const static WCHAR dotdot[] = { '.','.',0 };
TRACE("(%p)->(path=%s flags=0x%08lx) \n",list,debugstr_a(lpszPath),dwFlags);
TRACE("(%p)->(path=%s flags=0x%08lx) \n",list,debugstr_w(lpszPath),dwFlags);
if(!lpszPath || !lpszPath[0]) return FALSE;
strcpy(szPath, lpszPath);
PathAddBackslashA(szPath);
strcat(szPath,"*.*");
strcpyW(szPath, lpszPath);
PathAddBackslashW(szPath);
strcatW(szPath,stars);
hFile = FindFirstFileA(szPath,&stffile);
hFile = FindFirstFileW(szPath,&stffile);
if ( hFile != INVALID_HANDLE_VALUE )
{
BOOL findFinished = FALSE;
@ -132,21 +136,21 @@ BOOL CreateFolderEnumList(
{
if ( (stffile.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) &&
dwFlags & SHCONTF_FOLDERS &&
strcmp (stffile.cFileName, ".") && strcmp (stffile.cFileName, ".."))
strcmpW(stffile.cFileName, dot) && strcmpW(stffile.cFileName, dotdot))
{
pidl = _ILCreateFromFindDataA(&stffile);
pidl = _ILCreateFromFindDataW(&stffile);
succeeded = succeeded && AddToEnumList(list, pidl);
}
else if (!(stffile.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
&& dwFlags & SHCONTF_NONFOLDERS)
{
pidl = _ILCreateFromFindDataA(&stffile);
pidl = _ILCreateFromFindDataW(&stffile);
succeeded = succeeded && AddToEnumList(list, pidl);
}
}
if (succeeded)
{
if (!FindNextFileA(hFile, &stffile))
if (!FindNextFileW(hFile, &stffile))
{
if (GetLastError() == ERROR_NO_MORE_FILES)
findFinished = TRUE;

View File

@ -25,6 +25,6 @@ BOOL AddToEnumList(IEnumIDList *list, LPITEMIDLIST pidl);
/* Enumerates the folders and/or files (depending on dwFlags) in lpszPath and
* adds them to the already-created list.
*/
BOOL CreateFolderEnumList(IEnumIDList *list, LPCSTR lpszPath, DWORD dwFlags);
BOOL CreateFolderEnumList(IEnumIDList *list, LPCWSTR lpszPath, DWORD dwFlags);
#endif /* ndef __ENUMIDLIST_H__ */

View File

@ -208,6 +208,7 @@ LPITEMIDLIST _ILCreateGuid(PIDLTYPE type, REFIID guid);
/* Like _ILCreateGuid, but using the string szGUID. */
LPITEMIDLIST _ILCreateGuidFromStrA(LPCSTR szGUID);
LPITEMIDLIST _ILCreateGuidFromStrW(LPCWSTR szGUID);
/* Commonly used PIDLs representing file system objects. */
LPITEMIDLIST _ILCreateDesktop (void);

View File

@ -46,6 +46,7 @@ HRESULT SHELL32_BindToChild (LPCITEMIDLIST pidlRoot,
LPCSTR pathRoot, LPCITEMIDLIST pidlComplete, REFIID riid, LPVOID * ppvOut);
HRESULT SHELL32_CompareIDs (IShellFolder * iface, LPARAM lParam, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2);
LPITEMIDLIST SHELL32_CreatePidlFromBindCtx(IBindCtx *pbc, LPCWSTR path);
static inline int SHELL32_GUIDToStringA (REFGUID guid, LPSTR str)
{

View File

@ -240,6 +240,11 @@ static HRESULT WINAPI ISF_Desktop_fnParseDisplayName (IShellFolder2 * iface,
pidlTemp = _ILCreateNetwork();
szNext = lpszDisplayName;
}
else if( (pidlTemp = SHELL32_CreatePidlFromBindCtx(pbc, lpszDisplayName)) )
{
*ppidl = pidlTemp;
return S_OK;
}
else
{
/* it's a filesystem path on the desktop. Let a FSFolder parse it */
@ -288,7 +293,7 @@ static HRESULT WINAPI ISF_Desktop_fnParseDisplayName (IShellFolder2 * iface,
static BOOL CreateDesktopEnumList(IEnumIDList *list, DWORD dwFlags)
{
BOOL ret = TRUE;
char szPath[MAX_PATH];
WCHAR szPath[MAX_PATH];
TRACE("(%p)->(flags=0x%08lx) \n",list,dwFlags);
@ -307,7 +312,7 @@ static BOOL CreateDesktopEnumList(IEnumIDList *list, DWORD dwFlags)
0, KEY_READ, &hkey);
if (ret && ERROR_SUCCESS == r)
{
char iid[50];
WCHAR iid[50];
int i=0;
BOOL moreKeys = TRUE;
@ -316,10 +321,10 @@ static BOOL CreateDesktopEnumList(IEnumIDList *list, DWORD dwFlags)
DWORD size;
size = sizeof (iid);
r = RegEnumKeyExA(hkey, i, iid, &size, 0, NULL, NULL, NULL);
r = RegEnumKeyExW(hkey, i, iid, &size, 0, NULL, NULL, NULL);
if (ERROR_SUCCESS == r)
{
ret = AddToEnumList(list, _ILCreateGuidFromStrA(iid));
ret = AddToEnumList(list, _ILCreateGuidFromStrW(iid));
i++;
}
else if (ERROR_NO_MORE_ITEMS == r)
@ -332,7 +337,7 @@ static BOOL CreateDesktopEnumList(IEnumIDList *list, DWORD dwFlags)
}
/* enumerate the elements in %windir%\desktop */
SHGetSpecialFolderPathA(0, szPath, CSIDL_DESKTOPDIRECTORY, FALSE);
SHGetSpecialFolderPathW(0, szPath, CSIDL_DESKTOPDIRECTORY, FALSE);
ret = ret && CreateFolderEnumList(list, szPath, dwFlags);
return ret;

View File

@ -444,7 +444,11 @@ IShellFolder_fnEnumObjects (IShellFolder2 * iface, HWND hwndOwner, DWORD dwFlags
*ppEnumIDList = IEnumIDList_Constructor();
if (*ppEnumIDList)
CreateFolderEnumList(*ppEnumIDList, This->sPathTarget, dwFlags);
{
WCHAR path[MAX_PATH];
MultiByteToWideChar(CP_ACP, 0, This->sPathTarget, -1, path, MAX_PATH);
CreateFolderEnumList(*ppEnumIDList, path, dwFlags);
}
TRACE ("-- (%p)->(new ID List: %p)\n", This, *ppEnumIDList);