Skip to content
Snippets Groups Projects
Commit d1ffc6f1 authored by Rolf Kalbermatter's avatar Rolf Kalbermatter Committed by Alexandre Julliard
Browse files

Implemented SHSimpleIDListFromPath correctly.

parent c07808a0
No related branches found
No related tags found
No related merge requests found
...@@ -5,7 +5,7 @@ SRCDIR = @srcdir@ ...@@ -5,7 +5,7 @@ SRCDIR = @srcdir@
VPATH = @srcdir@ VPATH = @srcdir@
MODULE = shell32.dll MODULE = shell32.dll
# fixme: avoid ole32.dll import # fixme: avoid ole32.dll import
IMPORTS = ole32 shlwapi comctl32 user32 gdi32 advapi32 kernel32 IMPORTS = ole32 shlwapi comctl32 user32 gdi32 advapi32 kernel32 ntdll
ALTNAMES = shell.dll ALTNAMES = shell.dll
EXTRALIBS = $(LIBUUID) $(LIBUNICODE) EXTRALIBS = $(LIBUUID) $(LIBUNICODE)
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include "shlguid.h" #include "shlguid.h"
#include "winerror.h" #include "winerror.h"
#include "winnls.h" #include "winnls.h"
#include "winternl.h"
#include "undocshell.h" #include "undocshell.h"
#include "shell32_main.h" #include "shell32_main.h"
#include "shellapi.h" #include "shellapi.h"
...@@ -807,46 +808,121 @@ LPITEMIDLIST WINAPI ILCreateFromPathAW (LPCVOID path) ...@@ -807,46 +808,121 @@ LPITEMIDLIST WINAPI ILCreateFromPathAW (LPCVOID path)
return ILCreateFromPathA (path); return ILCreateFromPathA (path);
} }
/************************************************************************* /*************************************************************************
* SHSimpleIDListFromPath [SHELL32.162] * _ILParsePathW [internal]
*
* Creates an ItemIDList from a path and returns it.
*
* PARAMS
* path [I] path to parse and convert into an ItemIDList
* lpFindFile [I] pointer to buffer to initialize the FileSystem
* Bind Data object with
* bBindCtx [I] indicates to create a BindContext and assign a
* FileSystem Bind Data object
* ppidl [O] the newly create ItemIDList
* prgfInOut [I/O] requested attributes on input and actual
* attributes on return
*
* RETURNS
* NO_ERROR on success or an OLE error code
*
* NOTES
* If either lpFindFile is non-NULL or bBindCtx is TRUE, this function
* creates a BindContext object and assigns a FileSystem Bind Data object
* to it, passing the BindContext to IShellFolder_ParseDisplayName. Each
* IShellFolder uses that FileSystem Bind Data object of the BindContext
* to pass data about the current path element to the next object. This
* is used to avoid having to verify the current path element on disk, so
* that creating an ItemIDList from a non existing path still can work.
*/ */
LPITEMIDLIST WINAPI SHSimpleIDListFromPathA (LPCSTR lpszPath) static HRESULT WINAPI _ILParsePathW(LPCWSTR path, LPWIN32_FIND_DATAW lpFindFile,
BOOL bBindCtx, LPITEMIDLIST *ppidl, LPDWORD prgfInOut)
{ {
LPITEMIDLIST pidl=NULL; LPSHELLFOLDER pSF = NULL;
HANDLE hFile; LPBC pBC = NULL;
WIN32_FIND_DATAA stffile; HRESULT ret;
TRACE("path=%s\n", lpszPath); TRACE("%s %p %d (%p)->%p (%p)->0x%lx\n", debugstr_w(path), lpFindFile, bBindCtx,
ppidl, ppidl ? *ppidl : NULL,
prgfInOut, prgfInOut ? *prgfInOut : 0);
if (!lpszPath) return NULL; ret = SHGetDesktopFolder(&pSF);
if (FAILED(ret))
{
return ret;
}
hFile = FindFirstFileA(lpszPath, &stffile); if (lpFindFile || bBindCtx)
ret = IFileSystemBindData_Constructor(lpFindFile, &pBC);
if ( hFile != INVALID_HANDLE_VALUE ) if (SUCCEEDED(ret))
{ {
if (stffile.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ret = IShellFolder_ParseDisplayName(pSF, 0, pBC, (LPOLESTR)path, NULL, ppidl, prgfInOut);
{ }
pidl = _ILCreateFolder (&stffile);
} if (pBC)
else {
{ IBindCtx_Release(pBC);
pidl = _ILCreateValue (&stffile); pBC = NULL;
}
FindClose (hFile);
} }
IShellFolder_Release(pSF);
if (!SUCCEEDED(ret) && ppidl)
*ppidl = NULL;
TRACE("%s %p 0x%lx\n", debugstr_w(path), ppidl ? *ppidl : NULL, prgfInOut ? *prgfInOut : 0);
return ret;
}
/*************************************************************************
* SHSimpleIDListFromPath [SHELL32.162]
*
* Creates a simple ItemIDList from a path and returns it. This function
* does not fail on non-existing paths.
*
* PARAMS
* path [I] path to parse and convert into an ItemIDList
*
* RETURNS
* the newly created simple ItemIDList
*
* NOTES
* Simple in the name does not mean a relative ItemIDList but rather a
* fully qualified list, where only the file name is filled in and the
* directory flag for those ItemID elements this is known about, eg.
* it is not the last element in the ItemIDList or the actual directory
* exists on disk.
* exported by ordinal.
*/
LPITEMIDLIST WINAPI SHSimpleIDListFromPathA(LPCSTR lpszPath)
{
LPITEMIDLIST pidl = NULL;
UNICODE_STRING wPath;
TRACE("%s\n", debugstr_a(lpszPath));
RtlCreateUnicodeStringFromAsciiz(&wPath, lpszPath);
_ILParsePathW(wPath.Buffer, NULL, TRUE, &pidl, NULL);
RtlFreeUnicodeString(&wPath);
TRACE("%s %p\n", debugstr_a(lpszPath), pidl);
return pidl; return pidl;
} }
LPITEMIDLIST WINAPI SHSimpleIDListFromPathW (LPCWSTR lpszPath)
LPITEMIDLIST WINAPI SHSimpleIDListFromPathW(LPCWSTR lpszPath)
{ {
char lpszTemp[MAX_PATH]; LPITEMIDLIST pidl = NULL;
TRACE("path=%s\n",debugstr_w(lpszPath));
if (!WideCharToMultiByte( CP_ACP, 0, lpszPath, -1, lpszTemp, sizeof(lpszTemp), NULL, NULL )) TRACE("%s\n", debugstr_w(lpszPath));
lpszTemp[sizeof(lpszTemp)-1] = 0;
return SHSimpleIDListFromPathA (lpszTemp); _ILParsePathW(lpszPath, NULL, TRUE, &pidl, NULL);
TRACE("%s %p\n", debugstr_w(lpszPath), pidl);
return pidl;
} }
LPITEMIDLIST WINAPI SHSimpleIDListFromPathAW (LPCVOID lpszPath) LPITEMIDLIST WINAPI SHSimpleIDListFromPathAW(LPCVOID lpszPath)
{ {
if ( SHELL_OsIsUnicode()) if ( SHELL_OsIsUnicode())
return SHSimpleIDListFromPathW (lpszPath); return SHSimpleIDListFromPathW (lpszPath);
...@@ -958,7 +1034,7 @@ HRESULT WINAPI SHGetDataFromIDListA(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, int n ...@@ -958,7 +1034,7 @@ HRESULT WINAPI SHGetDataFromIDListA(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, int n
{ {
WIN32_FIND_DATAA * pfd = dest; WIN32_FIND_DATAA * pfd = dest;
if ( len < sizeof (WIN32_FIND_DATAA)) return E_INVALIDARG; if (len < (int)sizeof(WIN32_FIND_DATAA)) return E_INVALIDARG;
ZeroMemory(pfd, sizeof (WIN32_FIND_DATAA)); ZeroMemory(pfd, sizeof (WIN32_FIND_DATAA));
_ILGetFileDateTime( pidl, &(pfd->ftLastWriteTime)); _ILGetFileDateTime( pidl, &(pfd->ftLastWriteTime));
...@@ -998,7 +1074,7 @@ HRESULT WINAPI SHGetDataFromIDListW(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, int n ...@@ -998,7 +1074,7 @@ HRESULT WINAPI SHGetDataFromIDListW(LPSHELLFOLDER psf, LPCITEMIDLIST pidl, int n
{ {
WIN32_FIND_DATAW * pfd = dest; WIN32_FIND_DATAW * pfd = dest;
if ( len < sizeof (WIN32_FIND_DATAW)) return E_INVALIDARG; if (len < (int)sizeof(WIN32_FIND_DATAW)) return E_INVALIDARG;
ZeroMemory(pfd, sizeof (WIN32_FIND_DATAA)); ZeroMemory(pfd, sizeof (WIN32_FIND_DATAA));
_ILGetFileDateTime( pidl, &(pfd->ftLastWriteTime)); _ILGetFileDateTime( pidl, &(pfd->ftLastWriteTime));
...@@ -1089,6 +1165,18 @@ BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath) ...@@ -1089,6 +1165,18 @@ BOOL WINAPI SHGetPathFromIDListW(LPCITEMIDLIST pidl, LPWSTR pszPath)
return SUCCEEDED(hr); return SUCCEEDED(hr);
} }
/*************************************************************************
* SHGetPathFromIDList [SHELL32.@][NT 4.0: SHELL32.219]
*/
BOOL WINAPI SHGetPathFromIDListAW(LPCITEMIDLIST pidl,LPVOID pszPath)
{
TRACE_(shell)("(pidl=%p,%p)\n",pidl,pszPath);
if (SHELL_OsIsUnicode())
return SHGetPathFromIDListW(pidl,pszPath);
return SHGetPathFromIDListA(pidl,pszPath);
}
/************************************************************************* /*************************************************************************
* SHBindToParent [shell version 5.0] * SHBindToParent [shell version 5.0]
*/ */
...@@ -1136,18 +1224,6 @@ HRESULT WINAPI SHBindToParent(LPCITEMIDLIST pidl, REFIID riid, LPVOID *ppv, LPCI ...@@ -1136,18 +1224,6 @@ HRESULT WINAPI SHBindToParent(LPCITEMIDLIST pidl, REFIID riid, LPVOID *ppv, LPCI
return hr; return hr;
} }
/*************************************************************************
* SHGetPathFromIDList [SHELL32.@][NT 4.0: SHELL32.219]
*/
BOOL WINAPI SHGetPathFromIDListAW(LPCITEMIDLIST pidl,LPVOID pszPath)
{
TRACE_(shell)("(pidl=%p,%p)\n",pidl,pszPath);
if (SHELL_OsIsUnicode())
return SHGetPathFromIDListW(pidl,pszPath);
return SHGetPathFromIDListA(pidl,pszPath);
}
/************************************************************************** /**************************************************************************
* *
* internal functions * internal functions
......
...@@ -94,7 +94,7 @@ HRESULT WINAPI IShellLink_Constructor(IUnknown * pUnkOuter, REFIID riid, LPVOID ...@@ -94,7 +94,7 @@ HRESULT WINAPI IShellLink_Constructor(IUnknown * pUnkOuter, REFIID riid, LPVOID
HRESULT WINAPI ISF_Desktop_Constructor(IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv); HRESULT WINAPI ISF_Desktop_Constructor(IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv);
HRESULT WINAPI ISF_MyComputer_Constructor(IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv); HRESULT WINAPI ISF_MyComputer_Constructor(IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv);
HRESULT WINAPI IDropTargetHelper_Constructor (IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv); HRESULT WINAPI IDropTargetHelper_Constructor (IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv);
HRESULT WINAPI FileSystemBindData_Constructor(const WIN32_FIND_DATAW *pfd, LPBC *ppV); HRESULT WINAPI IFileSystemBindData_Constructor(const WIN32_FIND_DATAW *pfd, LPBC *ppV);
/* kind of enumidlist */ /* kind of enumidlist */
#define EIDL_DESK 0 #define EIDL_DESK 0
......
...@@ -298,7 +298,7 @@ static ULONG WINAPI IShellFolder_fnRelease (IShellFolder2 * iface) ...@@ -298,7 +298,7 @@ static ULONG WINAPI IShellFolder_fnRelease (IShellFolder2 * iface)
* *
* PARAMS * PARAMS
* hwndOwner [in] Parent window for any message's * hwndOwner [in] Parent window for any message's
* pbc [in] Reserved * pbc [in] optional FileSystemBindData context
* lpszDisplayName [in] Unicode displayname. * lpszDisplayName [in] Unicode displayname.
* pchEaten [out] (unicode) characters processed * pchEaten [out] (unicode) characters processed
* ppidl [out] complex pidl to item * ppidl [out] complex pidl to item
...@@ -402,16 +402,16 @@ IShellFolder_fnEnumObjects (IShellFolder2 * iface, HWND hwndOwner, DWORD dwFlags ...@@ -402,16 +402,16 @@ IShellFolder_fnEnumObjects (IShellFolder2 * iface, HWND hwndOwner, DWORD dwFlags
* IShellFolder_fnBindToObject * IShellFolder_fnBindToObject
* PARAMETERS * PARAMETERS
* LPCITEMIDLIST pidl, //[in ] relative pidl to open * LPCITEMIDLIST pidl, //[in ] relative pidl to open
* LPBC pbc, //[in ] reserved * LPBC pbc, //[in ] optional FileSystemBindData context
* REFIID riid, //[in ] Initial Interface * REFIID riid, //[in ] Initial Interface
* LPVOID* ppvObject //[out] Interface* * LPVOID* ppvObject //[out] Interface*
*/ */
static HRESULT WINAPI static HRESULT WINAPI
IShellFolder_fnBindToObject (IShellFolder2 * iface, LPCITEMIDLIST pidl, LPBC pbcReserved, REFIID riid, LPVOID * ppvOut) IShellFolder_fnBindToObject (IShellFolder2 * iface, LPCITEMIDLIST pidl, LPBC pbc, REFIID riid, LPVOID * ppvOut)
{ {
_ICOM_THIS_From_IShellFolder2 (IGenericSFImpl, iface) _ICOM_THIS_From_IShellFolder2 (IGenericSFImpl, iface)
TRACE ("(%p)->(pidl=%p,%p,%s,%p)\n", This, pidl, pbcReserved, shdebugstr_guid (riid), ppvOut); TRACE ("(%p)->(pidl=%p,%p,%s,%p)\n", This, pidl, pbc, shdebugstr_guid (riid), ppvOut);
return SHELL32_BindToChild (This->pidlRoot, This->sPathTarget, pidl, riid, ppvOut); return SHELL32_BindToChild (This->pidlRoot, This->sPathTarget, pidl, riid, ppvOut);
} }
......
...@@ -64,7 +64,7 @@ static struct ICOM_VTABLE(IFileSystemBindData) sbvt = ...@@ -64,7 +64,7 @@ static struct ICOM_VTABLE(IFileSystemBindData) sbvt =
static WCHAR wFileSystemBindData[] = {'F','i','l','e',' ','S','y','s','t','e','m',' ','B','i','n','d','D','a','t','a',0}; static WCHAR wFileSystemBindData[] = {'F','i','l','e',' ','S','y','s','t','e','m',' ','B','i','n','d','D','a','t','a',0};
HRESULT WINAPI FileSystemBindData_Constructor(const WIN32_FIND_DATAW *pfd, LPBC *ppV) HRESULT WINAPI IFileSystemBindData_Constructor(const WIN32_FIND_DATAW *pfd, LPBC *ppV)
{ {
IFileSystemBindDataImpl *sb; IFileSystemBindDataImpl *sb;
HRESULT ret = E_OUTOFMEMORY; HRESULT ret = E_OUTOFMEMORY;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment