shelllink: fix and test for "" paths
Huw D M Davies
h.davies1 at physics.ox.ac.uk
Wed Feb 16 06:50:03 CST 2005
Huw Davies <huw at codeweavers.com>
SetPath("") should return S_OK
SetPath("nonexistent_path") should return S_FALSE
--
Huw Davies
huw at codeweavers.com
Index: dlls/shell32/shelllink.c
===================================================================
RCS file: /home/wine/wine/dlls/shell32/shelllink.c,v
retrieving revision 1.81
diff -u -p -r1.81 shelllink.c
--- dlls/shell32/shelllink.c 14 Jan 2005 16:02:20 -0000 1.81
+++ dlls/shell32/shelllink.c 16 Feb 2005 12:47:53 -0000
@@ -1336,11 +1336,16 @@ static HRESULT WINAPI IShellLinkA_fnSetP
IShellLinkImpl *This = (IShellLinkImpl *)iface;
char buffer[MAX_PATH];
LPSTR fname;
+ HRESULT hr = S_OK;
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;
+ else if(!PathFileExistsA(buffer))
+ hr = S_FALSE;
HeapFree(GetProcessHeap(), 0, This->sPath);
This->sPath = HEAP_strdupAtoW(GetProcessHeap(), 0, buffer);
@@ -1349,7 +1354,7 @@ static HRESULT WINAPI IShellLinkA_fnSetP
This->bDirty = TRUE;
- return S_OK;
+ return hr;
}
/**************************************************************************
@@ -1756,11 +1761,16 @@ static HRESULT WINAPI IShellLinkW_fnSetP
_ICOM_THIS_From_IShellLinkW(IShellLinkImpl, iface);
WCHAR buffer[MAX_PATH];
LPWSTR fname;
+ HRESULT hr = S_OK;
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;
+ else if(!PathFileExistsW(buffer))
+ hr = S_FALSE;
HeapFree(GetProcessHeap(), 0, This->sPath);
This->sPath = HeapAlloc( GetProcessHeap(), 0,
@@ -1771,7 +1781,7 @@ static HRESULT WINAPI IShellLinkW_fnSetP
lstrcpyW(This->sPath, buffer);
This->bDirty = TRUE;
- return S_OK;
+ return hr;
}
/**************************************************************************
Index: dlls/shell32/tests/shelllink.c
===================================================================
RCS file: /home/wine/wine/dlls/shell32/tests/shelllink.c,v
retrieving revision 1.2
diff -u -p -r1.2 shelllink.c
--- dlls/shell32/tests/shelllink.c 14 Feb 2005 11:52:29 -0000 1.2
+++ dlls/shell32/tests/shelllink.c 16 Feb 2005 12:47:54 -0000
@@ -136,9 +136,17 @@ static void test_get_set()
ok(SUCCEEDED(r), "GetPath failed (0x%08lx)\n", r);
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";
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");
r = IShellLinkA_GetPath(sl, buffer, sizeof(buffer), NULL, SLGP_RAWPATH);
More information about the wine-patches
mailing list