SetPath("") should return S_OK.

SetPath("nonexistent_path") should return S_FALSE.
This commit is contained in:
Huw Davies 2005-02-16 16:27:42 +00:00 committed by Alexandre Julliard
parent e2f07fb444
commit 084e596a95
2 changed files with 23 additions and 5 deletions

View File

@ -1336,11 +1336,16 @@ static HRESULT WINAPI IShellLinkA_fnSetPath(IShellLinkA * iface, LPCSTR pszFile)
IShellLinkImpl *This = (IShellLinkImpl *)iface; IShellLinkImpl *This = (IShellLinkImpl *)iface;
char buffer[MAX_PATH]; char buffer[MAX_PATH];
LPSTR fname; LPSTR fname;
HRESULT hr = S_OK;
TRACE("(%p)->(path=%s)\n",This, pszFile); TRACE("(%p)->(path=%s)\n",This, pszFile);
if (!GetFullPathNameA(pszFile, MAX_PATH, buffer, &fname)) if(*pszFile == '\0')
*buffer = '\0';
else if (!GetFullPathNameA(pszFile, MAX_PATH, buffer, &fname))
return E_FAIL; return E_FAIL;
else if(!PathFileExistsA(buffer))
hr = S_FALSE;
HeapFree(GetProcessHeap(), 0, This->sPath); HeapFree(GetProcessHeap(), 0, This->sPath);
This->sPath = HEAP_strdupAtoW(GetProcessHeap(), 0, buffer); This->sPath = HEAP_strdupAtoW(GetProcessHeap(), 0, buffer);
@ -1349,7 +1354,7 @@ static HRESULT WINAPI IShellLinkA_fnSetPath(IShellLinkA * iface, LPCSTR pszFile)
This->bDirty = TRUE; This->bDirty = TRUE;
return S_OK; return hr;
} }
/************************************************************************** /**************************************************************************
@ -1756,11 +1761,16 @@ static HRESULT WINAPI IShellLinkW_fnSetPath(IShellLinkW * iface, LPCWSTR pszFile
_ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface); _ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
WCHAR buffer[MAX_PATH]; WCHAR buffer[MAX_PATH];
LPWSTR fname; LPWSTR fname;
HRESULT hr = S_OK;
TRACE("(%p)->(path=%s)\n",This, debugstr_w(pszFile)); TRACE("(%p)->(path=%s)\n",This, debugstr_w(pszFile));
if (!GetFullPathNameW(pszFile, MAX_PATH, buffer, &fname)) if (*pszFile == '\0')
*buffer = '\0';
else if (!GetFullPathNameW(pszFile, MAX_PATH, buffer, &fname))
return E_FAIL; return E_FAIL;
else if(!PathFileExistsW(buffer))
hr = S_FALSE;
HeapFree(GetProcessHeap(), 0, This->sPath); HeapFree(GetProcessHeap(), 0, This->sPath);
This->sPath = HeapAlloc( GetProcessHeap(), 0, This->sPath = HeapAlloc( GetProcessHeap(), 0,
@ -1771,7 +1781,7 @@ static HRESULT WINAPI IShellLinkW_fnSetPath(IShellLinkW * iface, LPCWSTR pszFile
lstrcpyW(This->sPath, buffer); lstrcpyW(This->sPath, buffer);
This->bDirty = TRUE; This->bDirty = TRUE;
return S_OK; return hr;
} }
/************************************************************************** /**************************************************************************

View File

@ -136,9 +136,17 @@ static void test_get_set()
ok(SUCCEEDED(r), "GetPath failed (0x%08lx)\n", r); ok(SUCCEEDED(r), "GetPath failed (0x%08lx)\n", r);
ok(*buffer=='\0', "GetPath returned '%s'\n", buffer); ok(*buffer=='\0', "GetPath returned '%s'\n", buffer);
r = IShellLinkA_SetPath(sl, "");
ok(r==S_OK, "SetPath failed (0x%08lx)\n", r);
strcpy(buffer,"garbage");
r = IShellLinkA_GetPath(sl, buffer, sizeof(buffer), NULL, SLGP_RAWPATH);
ok(SUCCEEDED(r), "GetPath failed (0x%08lx)\n", r);
ok(*buffer=='\0', "GetPath returned '%s'\n", buffer);
str="c:\\nonexistent\\file"; str="c:\\nonexistent\\file";
r = IShellLinkA_SetPath(sl, str); r = IShellLinkA_SetPath(sl, str);
ok(SUCCEEDED(r), "SetPath failed (0x%08lx)\n", r); ok(r==S_FALSE, "SetPath failed (0x%08lx)\n", r);
strcpy(buffer,"garbage"); strcpy(buffer,"garbage");
r = IShellLinkA_GetPath(sl, buffer, sizeof(buffer), NULL, SLGP_RAWPATH); r = IShellLinkA_GetPath(sl, buffer, sizeof(buffer), NULL, SLGP_RAWPATH);