From 055d96b7210208b11cfec8bc58b14fdd99db84e6 Mon Sep 17 00:00:00 2001 From: Robert Shearman Date: Tue, 1 Nov 2005 09:34:03 +0000 Subject: [PATCH] Convert SHELL32_BindToChild to Unicode and fix up the callers. --- dlls/shell32/shfldr.h | 2 +- dlls/shell32/shfldr_desktop.c | 5 +--- dlls/shell32/shfldr_fs.c | 4 +++- dlls/shell32/shlfolder.c | 45 ++++++++++++++++------------------- 4 files changed, 26 insertions(+), 30 deletions(-) diff --git a/dlls/shell32/shfldr.h b/dlls/shell32/shfldr.h index 0cbdf91fd5e..e626255c52a 100644 --- a/dlls/shell32/shfldr.h +++ b/dlls/shell32/shfldr.h @@ -43,7 +43,7 @@ HRESULT SHELL32_GetDisplayNameOfChild (IShellFolder2 * psf, LPCITEMIDLIST pidl, DWORD dwOutLen); HRESULT SHELL32_BindToChild (LPCITEMIDLIST pidlRoot, - LPCSTR pathRoot, LPCITEMIDLIST pidlComplete, REFIID riid, LPVOID * ppvOut); + LPCWSTR 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); diff --git a/dlls/shell32/shfldr_desktop.c b/dlls/shell32/shfldr_desktop.c index aa86ef60625..c73ebbca140 100644 --- a/dlls/shell32/shfldr_desktop.c +++ b/dlls/shell32/shfldr_desktop.c @@ -341,14 +341,11 @@ static HRESULT WINAPI ISF_Desktop_fnBindToObject (IShellFolder2 * iface, LPCITEMIDLIST pidl, LPBC pbcReserved, REFIID riid, LPVOID * ppvOut) { IGenericSFImpl *This = (IGenericSFImpl *)iface; - char szPath[MAX_PATH]; TRACE ("(%p)->(pidl=%p,%p,%s,%p)\n", This, pidl, pbcReserved, shdebugstr_guid (riid), ppvOut); - WideCharToMultiByte( CP_ACP, 0, This->sPathTarget, -1, - szPath, MAX_PATH, NULL, NULL ); - return SHELL32_BindToChild( This->pidlRoot, szPath, pidl, riid, ppvOut ); + return SHELL32_BindToChild( This->pidlRoot, This->sPathTarget, pidl, riid, ppvOut ); } /************************************************************************** diff --git a/dlls/shell32/shfldr_fs.c b/dlls/shell32/shfldr_fs.c index cb92d73eceb..53d823147e9 100644 --- a/dlls/shell32/shfldr_fs.c +++ b/dlls/shell32/shfldr_fs.c @@ -481,11 +481,13 @@ IShellFolder_fnBindToObject (IShellFolder2 * iface, LPCITEMIDLIST pidl, LPBC pbc, REFIID riid, LPVOID * ppvOut) { IGenericSFImpl *This = impl_from_IShellFolder2(iface); + WCHAR szPath[MAX_PATH]; TRACE ("(%p)->(pidl=%p,%p,%s,%p)\n", This, pidl, pbc, shdebugstr_guid (riid), ppvOut); - return SHELL32_BindToChild (This->pidlRoot, This->sPathTarget, pidl, riid, + MultiByteToWideChar(CP_ACP, 0, This->sPathTarget, -1, szPath, MAX_PATH); + return SHELL32_BindToChild (This->pidlRoot, szPath, pidl, riid, ppvOut); } diff --git a/dlls/shell32/shlfolder.c b/dlls/shell32/shlfolder.c index bd1d81207ec..42b621079ae 100644 --- a/dlls/shell32/shlfolder.c +++ b/dlls/shell32/shlfolder.c @@ -192,12 +192,12 @@ HRESULT SHELL32_ParseNextElement (IShellFolder2 * psf, HWND hwndOwner, LPBC pbc, * pathRoot can be NULL for Folders beeing a drive. * In this case the absolute path is build from pidlChild (eg. C:) */ -HRESULT SHELL32_CoCreateInitSF (LPCITEMIDLIST pidlRoot, LPCSTR pathRoot, +static HRESULT SHELL32_CoCreateInitSF (LPCITEMIDLIST pidlRoot, LPCWSTR pathRoot, LPCITEMIDLIST pidlChild, REFCLSID clsid, REFIID riid, LPVOID * ppvOut) { HRESULT hr; - TRACE ("%p %s %p\n", pidlRoot, pathRoot, pidlChild); + TRACE ("%p %s %p\n", pidlRoot, debugstr_w(pathRoot), pidlChild); if (SUCCEEDED ((hr = SHCoCreateInstance (NULL, clsid, NULL, riid, ppvOut)))) { LPITEMIDLIST pidlAbsolute = ILCombine (pidlRoot, pidlChild); @@ -208,31 +208,28 @@ HRESULT SHELL32_CoCreateInitSF (LPCITEMIDLIST pidlRoot, LPCSTR pathRoot, SUCCEEDED (IUnknown_QueryInterface ((IUnknown *) * ppvOut, &IID_IPersistFolder3, (LPVOID *) & ppf))) { PERSIST_FOLDER_TARGET_INFO ppfti; - char szDestPath[MAX_PATH]; ZeroMemory (&ppfti, sizeof (ppfti)); - /* build path */ - if (pathRoot) { - lstrcpyA (szDestPath, pathRoot); - PathAddBackslashA(szDestPath); /* FIXME: why have drives a backslash here ? */ - } else { - szDestPath[0] = '\0'; - } - - if (pidlChild) { - LPSTR pszChild = _ILGetTextPointer(pidlChild); - - if (pszChild) - lstrcatA (szDestPath, pszChild); - else - hr = E_INVALIDARG; - } - /* fill the PERSIST_FOLDER_TARGET_INFO */ ppfti.dwAttributes = -1; ppfti.csidl = -1; - MultiByteToWideChar (CP_ACP, 0, szDestPath, -1, ppfti.szTargetParsingName, MAX_PATH); + + /* build path */ + if (pathRoot) { + lstrcpynW (ppfti.szTargetParsingName, pathRoot, MAX_PATH - 1); + PathAddBackslashW(ppfti.szTargetParsingName); /* FIXME: why have drives a backslash here ? */ + } + + if (pidlChild) { + LPCSTR pszChild = _ILGetTextPointer(pidlChild); + int len = lstrlenW(ppfti.szTargetParsingName); + + if (pszChild) + MultiByteToWideChar (CP_ACP, 0, pszChild, -1, ppfti.szTargetParsingName + len, MAX_PATH - len); + else + hr = E_INVALIDARG; + } IPersistFolder3_InitializeEx (ppf, NULL, pidlAbsolute, &ppfti); IPersistFolder3_Release (ppf); @@ -265,7 +262,7 @@ HRESULT SHELL32_CoCreateInitSF (LPCITEMIDLIST pidlRoot, LPCSTR pathRoot, * means you probably can't use it for your IShellFolder implementation. */ HRESULT SHELL32_BindToChild (LPCITEMIDLIST pidlRoot, - LPCSTR pathRoot, LPCITEMIDLIST pidlComplete, REFIID riid, LPVOID * ppvOut) + LPCWSTR pathRoot, LPCITEMIDLIST pidlComplete, REFIID riid, LPVOID * ppvOut) { GUID const *clsid; IShellFolder *pSF; @@ -290,10 +287,10 @@ HRESULT SHELL32_BindToChild (LPCITEMIDLIST pidlRoot, /* see if folder CLSID should be overridden by desktop.ini file */ if (pathRoot) { - MultiByteToWideChar(CP_ACP, 0, pathRoot, -1, wszFolderPath, MAX_PATH); + lstrcpynW(wszFolderPath, pathRoot, MAX_PATH); pwszPathTail = PathAddBackslashW(wszFolderPath); } - MultiByteToWideChar(CP_ACP, 0, _ILGetTextPointer(pidlChild), -1, pwszPathTail, MAX_PATH); + MultiByteToWideChar(CP_ACP, 0, _ILGetTextPointer(pidlChild), -1, pwszPathTail, MAX_PATH - (int)(pwszPathTail - wszFolderPath)); if (SHELL32_GetCustomFolderAttributeFromPath (wszFolderPath, wszDotShellClassInfo, wszCLSID, wszCLSIDValue, CHARS_IN_GUID)) CLSIDFromString (wszCLSIDValue, &clsidFolder);