From e4f5d867700d6f9cdf1e7ee8301380f52d111635 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9=20van=20Geldorp?= Date: Mon, 20 Sep 2004 17:42:57 +0000 Subject: [PATCH] Martin Fuchs Return "file not found" error values instead of E_INVALIDARG if _ILCreateFromPathA() failed to find files. svn path=/trunk/; revision=10936 --- reactos/lib/shell32/pidl.c | 20 +++++++++-------- reactos/lib/shell32/pidl.h | 2 +- reactos/lib/shell32/shfldr_desktop.c | 12 ++++------- reactos/lib/shell32/shfldr_fs.c | 32 ++++++++++++---------------- 4 files changed, 30 insertions(+), 36 deletions(-) diff --git a/reactos/lib/shell32/pidl.c b/reactos/lib/shell32/pidl.c index 3fd02d9a5b7..2d4901bc409 100644 --- a/reactos/lib/shell32/pidl.c +++ b/reactos/lib/shell32/pidl.c @@ -1604,19 +1604,21 @@ LPITEMIDLIST _ILCreateFromFindDataA(WIN32_FIND_DATAA * stffile ) return pidl; } -LPITEMIDLIST _ILCreateFromPathA(LPCSTR szPath) +HRESULT _ILCreateFromPathA(LPCSTR szPath, LPITEMIDLIST* ppidl) { HANDLE hFile; WIN32_FIND_DATAA stffile; - LPITEMIDLIST pidl = NULL; - + hFile = FindFirstFileA(szPath, &stffile); - if (hFile != INVALID_HANDLE_VALUE) - { - pidl = _ILCreateFromFindDataA(&stffile); - FindClose(hFile); - } - return pidl; + + if (hFile == INVALID_HANDLE_VALUE) + return HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND); + + FindClose(hFile); + + *ppidl = _ILCreateFromFindDataA(&stffile); + + return S_OK; } LPITEMIDLIST _ILCreateDrive( LPCSTR lpszNew) diff --git a/reactos/lib/shell32/pidl.h b/reactos/lib/shell32/pidl.h index bbd8aa35845..557e646a8bd 100644 --- a/reactos/lib/shell32/pidl.h +++ b/reactos/lib/shell32/pidl.h @@ -199,7 +199,7 @@ LPITEMIDLIST _ILCreateGuidFromStrA(LPCSTR szGUID); /* Commonly used PIDLs representing file system objects. */ LPITEMIDLIST _ILCreateDesktop (void); LPITEMIDLIST _ILCreateFromFindDataA(WIN32_FIND_DATAA *stffile); -LPITEMIDLIST _ILCreateFromPathA (LPCSTR szPath); +HRESULT _ILCreateFromPathA (LPCSTR szPath, LPITEMIDLIST* ppidl); /* Other helpers */ LPITEMIDLIST _ILCreateMyComputer (void); diff --git a/reactos/lib/shell32/shfldr_desktop.c b/reactos/lib/shell32/shfldr_desktop.c index def48507664..b4b7f742c8e 100644 --- a/reactos/lib/shell32/shfldr_desktop.c +++ b/reactos/lib/shell32/shfldr_desktop.c @@ -197,7 +197,7 @@ static HRESULT WINAPI ISF_Desktop_fnParseDisplayName (IShellFolder2 * iface, WCHAR szElement[MAX_PATH]; LPCWSTR szNext = NULL; LPITEMIDLIST pidlTemp = NULL; - HRESULT hr = E_INVALIDARG; + HRESULT hr = S_OK; char szPath[MAX_PATH]; DWORD len; CLSID clsid; @@ -234,10 +234,7 @@ static HRESULT WINAPI ISF_Desktop_fnParseDisplayName (IShellFolder2 * iface, PathAddBackslashA(szPath); len = lstrlenA(szPath); WideCharToMultiByte(CP_ACP, 0, lpszDisplayName, -1, szPath + len, MAX_PATH - len, NULL, NULL); - pidlTemp = _ILCreateFromPathA(szPath); - - if (!pidlTemp) - hr = 0x80070002L; /* file not found */ + hr = _ILCreateFromPathA(szPath, &pidlTemp); } else { pidlTemp = _ILCreateMyComputer(); } @@ -245,13 +242,12 @@ static HRESULT WINAPI ISF_Desktop_fnParseDisplayName (IShellFolder2 * iface, szNext = NULL; } - if (pidlTemp) { + if (SUCCEEDED(hr) && pidlTemp) { if (szNext && *szNext) { hr = SHELL32_ParseNextElement (iface, hwndOwner, pbc, &pidlTemp, (LPOLESTR) szNext, pchEaten, pdwAttributes); } else { - hr = S_OK; if (pdwAttributes && *pdwAttributes) { - SHELL32_GetItemAttributes (_IShellFolder_ (This), pidlTemp, pdwAttributes); + hr = SHELL32_GetItemAttributes (_IShellFolder_ (This), pidlTemp, pdwAttributes); } } } diff --git a/reactos/lib/shell32/shfldr_fs.c b/reactos/lib/shell32/shfldr_fs.c index 237cf2875cd..e931ff6c569 100644 --- a/reactos/lib/shell32/shfldr_fs.c +++ b/reactos/lib/shell32/shfldr_fs.c @@ -353,24 +353,22 @@ IShellFolder_fnParseDisplayName (IShellFolder2 * iface, WideCharToMultiByte(CP_ACP, 0, szElement, -1, szPath + len, MAX_PATH - len, NULL, NULL); /* get the pidl */ - pidlTemp = _ILCreateFromPathA(szPath); - if (!pidlTemp) - hr = 0x80070002L; /* file not found */ - else { + hr = _ILCreateFromPathA(szPath, &pidlTemp); + + if (SUCCEEDED(hr)) { if (szNext && *szNext) { /* try to analyse the next element */ hr = SHELL32_ParseNextElement (iface, hwndOwner, pbc, &pidlTemp, (LPOLESTR) szNext, pchEaten, pdwAttributes); } else { /* it's the last element */ 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; else *ppidl = NULL; @@ -750,14 +748,16 @@ static HRESULT WINAPI IShellFolder_fnSetNameOf (IShellFolder2 * iface, HWND hwnd szDest[MAX_PATH - 1] = 0; TRACE ("src=%s dest=%s\n", szSrc, szDest); if (MoveFileA (szSrc, szDest)) { - if (pPidlOut) { - *pPidlOut = _ILCreateFromPathA(szDest); - if (!*pPidlOut) - return 0x80070002L; /* file not found */ - } + HRESULT hr = S_OK; + + if (pPidlOut) + hr = _ILCreateFromPathA(szDest, pPidlOut); + SHChangeNotify (bIsFolder ? SHCNE_RENAMEFOLDER : SHCNE_RENAMEITEM, SHCNF_PATHA, szSrc, szDest); + return S_OK; } + return E_FAIL; } @@ -984,12 +984,8 @@ static HRESULT WINAPI ISFHelper_fnAddFolder (ISFHelper * iface, HWND hwnd, LPCST hres = S_OK; - if (ppidlOut) { - *ppidlOut = _ILCreateFromPathA(lpstrNewDir); - - if (!*ppidlOut) - hres = 0x80070002L; /* file not found */ - } + if (ppidlOut) + hres = _ILCreateFromPathA(lpstrNewDir, ppidlOut); } else { char lpstrText[128 + MAX_PATH]; char lpstrTempText[128];