Commit 91b40640 authored by Aric Stewart's avatar Aric Stewart Committed by Alexandre Julliard

shell32: Refine UNIXFS_path_to_pidl to return more detailed failures.

parent e6b16cce
...@@ -557,13 +557,13 @@ static char* UNIXFS_build_shitemid(char *pszUnixPath, void *pIDL) { ...@@ -557,13 +557,13 @@ static char* UNIXFS_build_shitemid(char *pszUnixPath, void *pIDL) {
* ppidl [O] The corresponding ITEMIDLIST. Release with SHFree/ILFree * ppidl [O] The corresponding ITEMIDLIST. Release with SHFree/ILFree
* *
* RETURNS * RETURNS
* Success: TRUE * Success: S_OK
* Failure: FALSE, invalid params or out of memory * Failure: Error code, invalid params or out of memory
* *
* NOTES * NOTES
* pUnixFolder also carries the information if the path is expected to be unix or dos. * pUnixFolder also carries the information if the path is expected to be unix or dos.
*/ */
static BOOL UNIXFS_path_to_pidl(UnixFolder *pUnixFolder, const WCHAR *path, LPITEMIDLIST *ppidl) { static HRESULT UNIXFS_path_to_pidl(UnixFolder *pUnixFolder, const WCHAR *path, LPITEMIDLIST *ppidl) {
LPITEMIDLIST pidl; LPITEMIDLIST pidl;
int cPidlLen, cPathLen; int cPidlLen, cPathLen;
char *pSlash, *pNextSlash, szCompletePath[FILENAME_MAX], *pNextPathElement, *pszAPath; char *pSlash, *pNextSlash, szCompletePath[FILENAME_MAX], *pNextPathElement, *pszAPath;
...@@ -572,7 +572,7 @@ static BOOL UNIXFS_path_to_pidl(UnixFolder *pUnixFolder, const WCHAR *path, LPIT ...@@ -572,7 +572,7 @@ static BOOL UNIXFS_path_to_pidl(UnixFolder *pUnixFolder, const WCHAR *path, LPIT
TRACE("pUnixFolder=%p, path=%s, ppidl=%p\n", pUnixFolder, debugstr_w(path), ppidl); TRACE("pUnixFolder=%p, path=%s, ppidl=%p\n", pUnixFolder, debugstr_w(path), ppidl);
if (!ppidl || !path) if (!ppidl || !path)
return FALSE; return E_INVALIDARG;
/* Build an absolute path and let pNextPathElement point to the interesting /* Build an absolute path and let pNextPathElement point to the interesting
* relative sub-path. We need the absolute path to call 'stat', but the pidl * relative sub-path. We need the absolute path to call 'stat', but the pidl
...@@ -582,7 +582,7 @@ static BOOL UNIXFS_path_to_pidl(UnixFolder *pUnixFolder, const WCHAR *path, LPIT ...@@ -582,7 +582,7 @@ static BOOL UNIXFS_path_to_pidl(UnixFolder *pUnixFolder, const WCHAR *path, LPIT
{ {
/* Absolute dos path. Convert to unix */ /* Absolute dos path. Convert to unix */
if (!UNIXFS_get_unix_path(path, szCompletePath)) if (!UNIXFS_get_unix_path(path, szCompletePath))
return FALSE; return E_FAIL;
pNextPathElement = szCompletePath; pNextPathElement = szCompletePath;
} }
else if ((pUnixFolder->m_dwPathMode == PATHMODE_UNIX) && (path[0] == '/')) else if ((pUnixFolder->m_dwPathMode == PATHMODE_UNIX) && (path[0] == '/'))
...@@ -613,9 +613,9 @@ static BOOL UNIXFS_path_to_pidl(UnixFolder *pUnixFolder, const WCHAR *path, LPIT ...@@ -613,9 +613,9 @@ static BOOL UNIXFS_path_to_pidl(UnixFolder *pUnixFolder, const WCHAR *path, LPIT
/* Special case for the root folder. */ /* Special case for the root folder. */
if (!strcmp(szCompletePath, "/")) { if (!strcmp(szCompletePath, "/")) {
*ppidl = pidl = (LPITEMIDLIST)SHAlloc(sizeof(USHORT)); *ppidl = pidl = (LPITEMIDLIST)SHAlloc(sizeof(USHORT));
if (!pidl) return FALSE; if (!pidl) return E_FAIL;
pidl->mkid.cb = 0; /* Terminate the ITEMIDLIST */ pidl->mkid.cb = 0; /* Terminate the ITEMIDLIST */
return TRUE; return S_OK;
} }
/* Remove trailing slash, if present */ /* Remove trailing slash, if present */
...@@ -625,7 +625,7 @@ static BOOL UNIXFS_path_to_pidl(UnixFolder *pUnixFolder, const WCHAR *path, LPIT ...@@ -625,7 +625,7 @@ static BOOL UNIXFS_path_to_pidl(UnixFolder *pUnixFolder, const WCHAR *path, LPIT
if ((szCompletePath[0] != '/') || (pNextPathElement[0] != '/')) { if ((szCompletePath[0] != '/') || (pNextPathElement[0] != '/')) {
ERR("szCompletePath: %s, pNextPathElment: %s\n", szCompletePath, pNextPathElement); ERR("szCompletePath: %s, pNextPathElment: %s\n", szCompletePath, pNextPathElement);
return FALSE; return E_FAIL;
} }
/* At this point, we have an absolute unix path in szCompletePath /* At this point, we have an absolute unix path in szCompletePath
...@@ -635,7 +635,7 @@ static BOOL UNIXFS_path_to_pidl(UnixFolder *pUnixFolder, const WCHAR *path, LPIT ...@@ -635,7 +635,7 @@ static BOOL UNIXFS_path_to_pidl(UnixFolder *pUnixFolder, const WCHAR *path, LPIT
/* Convert to CP_ACP and WCHAR */ /* Convert to CP_ACP and WCHAR */
if (!UNIXFS_shitemid_len_from_filename(pNextPathElement, &pszAPath, &pwszPath)) if (!UNIXFS_shitemid_len_from_filename(pNextPathElement, &pszAPath, &pwszPath))
return 0; return E_FAIL;
/* Compute the length of the complete ITEMIDLIST */ /* Compute the length of the complete ITEMIDLIST */
cPidlLen = 0; cPidlLen = 0;
...@@ -656,7 +656,7 @@ static BOOL UNIXFS_path_to_pidl(UnixFolder *pUnixFolder, const WCHAR *path, LPIT ...@@ -656,7 +656,7 @@ static BOOL UNIXFS_path_to_pidl(UnixFolder *pUnixFolder, const WCHAR *path, LPIT
SHFree(pwszPath); SHFree(pwszPath);
*ppidl = pidl = (LPITEMIDLIST)SHAlloc(cPidlLen); *ppidl = pidl = (LPITEMIDLIST)SHAlloc(cPidlLen);
if (!pidl) return FALSE; if (!pidl) return E_FAIL;
/* Concatenate the SHITEMIDs of the sub-directories. */ /* Concatenate the SHITEMIDs of the sub-directories. */
while (*pNextPathElement) { while (*pNextPathElement) {
...@@ -668,7 +668,7 @@ static BOOL UNIXFS_path_to_pidl(UnixFolder *pUnixFolder, const WCHAR *path, LPIT ...@@ -668,7 +668,7 @@ static BOOL UNIXFS_path_to_pidl(UnixFolder *pUnixFolder, const WCHAR *path, LPIT
if (!pNextPathElement) { if (!pNextPathElement) {
SHFree(*ppidl); SHFree(*ppidl);
*ppidl = NULL; *ppidl = NULL;
return FALSE; return HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND);
} }
pidl = ILGetNext(pidl); pidl = ILGetNext(pidl);
} }
...@@ -677,7 +677,7 @@ static BOOL UNIXFS_path_to_pidl(UnixFolder *pUnixFolder, const WCHAR *path, LPIT ...@@ -677,7 +677,7 @@ static BOOL UNIXFS_path_to_pidl(UnixFolder *pUnixFolder, const WCHAR *path, LPIT
if ((char *)pidl-(char *)*ppidl+sizeof(USHORT) != cPidlLen) /* We've corrupted the heap :( */ if ((char *)pidl-(char *)*ppidl+sizeof(USHORT) != cPidlLen) /* We've corrupted the heap :( */
ERR("Computed length of pidl incorrect. Please report.\n"); ERR("Computed length of pidl incorrect. Please report.\n");
return TRUE; return S_OK;
} }
/****************************************************************************** /******************************************************************************
...@@ -871,14 +871,14 @@ static HRESULT WINAPI UnixFolder_IShellFolder2_ParseDisplayName(IShellFolder2* i ...@@ -871,14 +871,14 @@ static HRESULT WINAPI UnixFolder_IShellFolder2_ParseDisplayName(IShellFolder2* i
ULONG* pdwAttributes) ULONG* pdwAttributes)
{ {
UnixFolder *This = ADJUST_THIS(UnixFolder, IShellFolder2, iface); UnixFolder *This = ADJUST_THIS(UnixFolder, IShellFolder2, iface);
BOOL result; HRESULT result;
TRACE("(iface=%p, hwndOwner=%p, pbcReserved=%p, lpszDisplayName=%s, pchEaten=%p, ppidl=%p, " TRACE("(iface=%p, hwndOwner=%p, pbcReserved=%p, lpszDisplayName=%s, pchEaten=%p, ppidl=%p, "
"pdwAttributes=%p) stub\n", iface, hwndOwner, pbcReserved, debugstr_w(lpszDisplayName), "pdwAttributes=%p) stub\n", iface, hwndOwner, pbcReserved, debugstr_w(lpszDisplayName),
pchEaten, ppidl, pdwAttributes); pchEaten, ppidl, pdwAttributes);
result = UNIXFS_path_to_pidl(This, lpszDisplayName, ppidl); result = UNIXFS_path_to_pidl(This, lpszDisplayName, ppidl);
if (result && pdwAttributes && *pdwAttributes) if (SUCCEEDED(result) && pdwAttributes && *pdwAttributes)
{ {
IShellFolder *pParentSF; IShellFolder *pParentSF;
LPCITEMIDLIST pidlLast; LPCITEMIDLIST pidlLast;
...@@ -896,8 +896,8 @@ static HRESULT WINAPI UnixFolder_IShellFolder2_ParseDisplayName(IShellFolder2* i ...@@ -896,8 +896,8 @@ static HRESULT WINAPI UnixFolder_IShellFolder2_ParseDisplayName(IShellFolder2* i
ILFree(pidlComplete); ILFree(pidlComplete);
} }
if (!result) TRACE("FAILED!\n"); if (FAILED(result)) TRACE("FAILED!\n");
return result ? S_OK : E_FAIL; return result;
} }
static IUnknown *UnixSubFolderIterator_Constructor(UnixFolder *pUnixFolder, SHCONTF fFilter); static IUnknown *UnixSubFolderIterator_Constructor(UnixFolder *pUnixFolder, SHCONTF fFilter);
...@@ -1775,7 +1775,7 @@ static HRESULT WINAPI UnixFolder_ISFHelper_AddFolder(ISFHelper* iface, HWND hwnd ...@@ -1775,7 +1775,7 @@ static HRESULT WINAPI UnixFolder_ISFHelper_AddFolder(ISFHelper* iface, HWND hwnd
LPITEMIDLIST pidlRelative; LPITEMIDLIST pidlRelative;
/* Inform the shell */ /* Inform the shell */
if (UNIXFS_path_to_pidl(This, pwszName, &pidlRelative)) { if (SUCCEEDED(UNIXFS_path_to_pidl(This, pwszName, &pidlRelative))) {
LPITEMIDLIST pidlAbsolute = ILCombine(This->m_pidlLocation, pidlRelative); LPITEMIDLIST pidlAbsolute = ILCombine(This->m_pidlLocation, pidlRelative);
if (ppidlOut) if (ppidlOut)
*ppidlOut = pidlRelative; *ppidlOut = pidlRelative;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment