Martin Fuchs <martin-fuchs@gmx.net>

Return "file not found" error values instead of E_INVALIDARG if
_ILCreateFromPathA() failed to find files.

svn path=/trunk/; revision=10936
This commit is contained in:
Gé van Geldorp 2004-09-20 17:42:57 +00:00
parent cd1222eced
commit e4f5d86770
4 changed files with 30 additions and 36 deletions

View file

@ -1604,19 +1604,21 @@ LPITEMIDLIST _ILCreateFromFindDataA(WIN32_FIND_DATAA * stffile )
return pidl; return pidl;
} }
LPITEMIDLIST _ILCreateFromPathA(LPCSTR szPath) HRESULT _ILCreateFromPathA(LPCSTR szPath, LPITEMIDLIST* ppidl)
{ {
HANDLE hFile; HANDLE hFile;
WIN32_FIND_DATAA stffile; WIN32_FIND_DATAA stffile;
LPITEMIDLIST pidl = NULL;
hFile = FindFirstFileA(szPath, &stffile); hFile = FindFirstFileA(szPath, &stffile);
if (hFile != INVALID_HANDLE_VALUE)
{ if (hFile == INVALID_HANDLE_VALUE)
pidl = _ILCreateFromFindDataA(&stffile); return HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND);
FindClose(hFile); FindClose(hFile);
}
return pidl; *ppidl = _ILCreateFromFindDataA(&stffile);
return S_OK;
} }
LPITEMIDLIST _ILCreateDrive( LPCSTR lpszNew) LPITEMIDLIST _ILCreateDrive( LPCSTR lpszNew)

View file

@ -199,7 +199,7 @@ LPITEMIDLIST _ILCreateGuidFromStrA(LPCSTR szGUID);
/* Commonly used PIDLs representing file system objects. */ /* Commonly used PIDLs representing file system objects. */
LPITEMIDLIST _ILCreateDesktop (void); LPITEMIDLIST _ILCreateDesktop (void);
LPITEMIDLIST _ILCreateFromFindDataA(WIN32_FIND_DATAA *stffile); LPITEMIDLIST _ILCreateFromFindDataA(WIN32_FIND_DATAA *stffile);
LPITEMIDLIST _ILCreateFromPathA (LPCSTR szPath); HRESULT _ILCreateFromPathA (LPCSTR szPath, LPITEMIDLIST* ppidl);
/* Other helpers */ /* Other helpers */
LPITEMIDLIST _ILCreateMyComputer (void); LPITEMIDLIST _ILCreateMyComputer (void);

View file

@ -197,7 +197,7 @@ static HRESULT WINAPI ISF_Desktop_fnParseDisplayName (IShellFolder2 * iface,
WCHAR szElement[MAX_PATH]; WCHAR szElement[MAX_PATH];
LPCWSTR szNext = NULL; LPCWSTR szNext = NULL;
LPITEMIDLIST pidlTemp = NULL; LPITEMIDLIST pidlTemp = NULL;
HRESULT hr = E_INVALIDARG; HRESULT hr = S_OK;
char szPath[MAX_PATH]; char szPath[MAX_PATH];
DWORD len; DWORD len;
CLSID clsid; CLSID clsid;
@ -234,10 +234,7 @@ static HRESULT WINAPI ISF_Desktop_fnParseDisplayName (IShellFolder2 * iface,
PathAddBackslashA(szPath); PathAddBackslashA(szPath);
len = lstrlenA(szPath); len = lstrlenA(szPath);
WideCharToMultiByte(CP_ACP, 0, lpszDisplayName, -1, szPath + len, MAX_PATH - len, NULL, NULL); WideCharToMultiByte(CP_ACP, 0, lpszDisplayName, -1, szPath + len, MAX_PATH - len, NULL, NULL);
pidlTemp = _ILCreateFromPathA(szPath); hr = _ILCreateFromPathA(szPath, &pidlTemp);
if (!pidlTemp)
hr = 0x80070002L; /* file not found */
} else { } else {
pidlTemp = _ILCreateMyComputer(); pidlTemp = _ILCreateMyComputer();
} }
@ -245,13 +242,12 @@ static HRESULT WINAPI ISF_Desktop_fnParseDisplayName (IShellFolder2 * iface,
szNext = NULL; szNext = NULL;
} }
if (pidlTemp) { if (SUCCEEDED(hr) && pidlTemp) {
if (szNext && *szNext) { if (szNext && *szNext) {
hr = SHELL32_ParseNextElement (iface, hwndOwner, pbc, &pidlTemp, (LPOLESTR) szNext, pchEaten, pdwAttributes); hr = SHELL32_ParseNextElement (iface, hwndOwner, pbc, &pidlTemp, (LPOLESTR) szNext, pchEaten, pdwAttributes);
} else { } else {
hr = S_OK;
if (pdwAttributes && *pdwAttributes) { if (pdwAttributes && *pdwAttributes) {
SHELL32_GetItemAttributes (_IShellFolder_ (This), pidlTemp, pdwAttributes); hr = SHELL32_GetItemAttributes (_IShellFolder_ (This), pidlTemp, pdwAttributes);
} }
} }
} }

View file

@ -353,24 +353,22 @@ IShellFolder_fnParseDisplayName (IShellFolder2 * iface,
WideCharToMultiByte(CP_ACP, 0, szElement, -1, szPath + len, MAX_PATH - len, NULL, NULL); WideCharToMultiByte(CP_ACP, 0, szElement, -1, szPath + len, MAX_PATH - len, NULL, NULL);
/* get the pidl */ /* get the pidl */
pidlTemp = _ILCreateFromPathA(szPath); hr = _ILCreateFromPathA(szPath, &pidlTemp);
if (!pidlTemp)
hr = 0x80070002L; /* file not found */ if (SUCCEEDED(hr)) {
else {
if (szNext && *szNext) { if (szNext && *szNext) {
/* try to analyse the next element */ /* try to analyse the next element */
hr = SHELL32_ParseNextElement (iface, hwndOwner, pbc, &pidlTemp, (LPOLESTR) szNext, pchEaten, pdwAttributes); hr = SHELL32_ParseNextElement (iface, hwndOwner, pbc, &pidlTemp, (LPOLESTR) szNext, pchEaten, pdwAttributes);
} else { } else {
/* it's the last element */ /* it's the last element */
if (pdwAttributes && *pdwAttributes) { if (pdwAttributes && *pdwAttributes) {
SHELL32_GetItemAttributes (_IShellFolder_ (This), pidlTemp, pdwAttributes); hr = SHELL32_GetItemAttributes (_IShellFolder_ (This), pidlTemp, pdwAttributes);
} }
hr = S_OK;
} }
} }
} }
if (!hr) if (SUCCEEDED(hr))
*ppidl = pidlTemp; *ppidl = pidlTemp;
else else
*ppidl = NULL; *ppidl = NULL;
@ -750,14 +748,16 @@ static HRESULT WINAPI IShellFolder_fnSetNameOf (IShellFolder2 * iface, HWND hwnd
szDest[MAX_PATH - 1] = 0; szDest[MAX_PATH - 1] = 0;
TRACE ("src=%s dest=%s\n", szSrc, szDest); TRACE ("src=%s dest=%s\n", szSrc, szDest);
if (MoveFileA (szSrc, szDest)) { if (MoveFileA (szSrc, szDest)) {
if (pPidlOut) { HRESULT hr = S_OK;
*pPidlOut = _ILCreateFromPathA(szDest);
if (!*pPidlOut) if (pPidlOut)
return 0x80070002L; /* file not found */ hr = _ILCreateFromPathA(szDest, pPidlOut);
}
SHChangeNotify (bIsFolder ? SHCNE_RENAMEFOLDER : SHCNE_RENAMEITEM, SHCNF_PATHA, szSrc, szDest); SHChangeNotify (bIsFolder ? SHCNE_RENAMEFOLDER : SHCNE_RENAMEITEM, SHCNF_PATHA, szSrc, szDest);
return S_OK; return S_OK;
} }
return E_FAIL; return E_FAIL;
} }
@ -984,12 +984,8 @@ static HRESULT WINAPI ISFHelper_fnAddFolder (ISFHelper * iface, HWND hwnd, LPCST
hres = S_OK; hres = S_OK;
if (ppidlOut) { if (ppidlOut)
*ppidlOut = _ILCreateFromPathA(lpstrNewDir); hres = _ILCreateFromPathA(lpstrNewDir, ppidlOut);
if (!*ppidlOut)
hres = 0x80070002L; /* file not found */
}
} else { } else {
char lpstrText[128 + MAX_PATH]; char lpstrText[128 + MAX_PATH];
char lpstrTempText[128]; char lpstrTempText[128];