[5/5] shell32: Add support for find data in IShellLink:GetPath.
Vincent Povirk
vincent at codeweavers.com
Mon Sep 25 15:35:23 CDT 2017
Signed-off-by: Vincent Povirk <vincent at codeweavers.com>
---
dlls/shell32/shelllink.c | 66 ++++++++++++++++++++++++++++++++++++++++--
dlls/shell32/tests/shelllink.c | 33 +++++++++++++++++++++
2 files changed, 97 insertions(+), 2 deletions(-)
diff --git a/dlls/shell32/shelllink.c b/dlls/shell32/shelllink.c
index ba33477..40fab4d 100644
--- a/dlls/shell32/shelllink.c
+++ b/dlls/shell32/shelllink.c
@@ -1270,7 +1270,39 @@ static HRESULT WINAPI IShellLinkA_fnGetPath(IShellLinkA *iface, LPSTR pszFile, I
else
res = S_FALSE;
- if (pfd) FIXME("(%p): WIN32_FIND_DATA is not yet filled.\n", This);
+ if (pfd)
+ {
+ memset(pfd, 0, sizeof(*pfd));
+
+ if (res == S_OK)
+ {
+ char path[MAX_PATH];
+ WIN32_FILE_ATTRIBUTE_DATA fad;
+
+ WideCharToMultiByte(CP_ACP, 0, This->sPath, -1, path, MAX_PATH, NULL, NULL);
+
+ if (GetFileAttributesExW(This->sPath, GetFileExInfoStandard, &fad))
+ {
+ pfd->dwFileAttributes = fad.dwFileAttributes;
+ pfd->ftCreationTime = fad.ftCreationTime;
+ pfd->ftLastAccessTime = fad.ftLastAccessTime;
+ pfd->ftLastWriteTime = fad.ftLastWriteTime;
+ pfd->nFileSizeHigh = fad.nFileSizeHigh;
+ pfd->nFileSizeLow = fad.nFileSizeLow;
+ }
+
+ lstrcpyA(pfd->cFileName, PathFindFileNameA(path));
+
+ if (GetShortPathNameA(path, path, MAX_PATH))
+ {
+ lstrcpyA(pfd->cAlternateFileName, PathFindFileNameA(path));
+ }
+ }
+
+ TRACE("attr 0x%08x size 0x%08x%08x name %s shortname %s\n", pfd->dwFileAttributes,
+ pfd->nFileSizeHigh, pfd->nFileSizeLow, wine_dbgstr_a(pfd->cFileName),
+ wine_dbgstr_a(pfd->cAlternateFileName));
+ }
return res;
}
@@ -1657,7 +1689,37 @@ static HRESULT WINAPI IShellLinkW_fnGetPath(IShellLinkW * iface, LPWSTR pszFile,
else
res = S_FALSE;
- if (pfd) FIXME("(%p): WIN32_FIND_DATA is not yet filled.\n", This);
+ if (pfd)
+ {
+ memset(pfd, 0, sizeof(*pfd));
+
+ if (res == S_OK)
+ {
+ WCHAR path[MAX_PATH];
+ WIN32_FILE_ATTRIBUTE_DATA fad;
+
+ if (GetFileAttributesExW(This->sPath, GetFileExInfoStandard, &fad))
+ {
+ pfd->dwFileAttributes = fad.dwFileAttributes;
+ pfd->ftCreationTime = fad.ftCreationTime;
+ pfd->ftLastAccessTime = fad.ftLastAccessTime;
+ pfd->ftLastWriteTime = fad.ftLastWriteTime;
+ pfd->nFileSizeHigh = fad.nFileSizeHigh;
+ pfd->nFileSizeLow = fad.nFileSizeLow;
+ }
+
+ lstrcpyW(pfd->cFileName, PathFindFileNameW(This->sPath));
+
+ if (GetShortPathNameW(This->sPath, path, MAX_PATH))
+ {
+ lstrcpyW(pfd->cAlternateFileName, PathFindFileNameW(path));
+ }
+ }
+
+ TRACE("attr 0x%08x size 0x%08x%08x name %s shortname %s\n", pfd->dwFileAttributes,
+ pfd->nFileSizeHigh, pfd->nFileSizeLow, wine_dbgstr_w(pfd->cFileName),
+ wine_dbgstr_w(pfd->cAlternateFileName));
+ }
return res;
}
diff --git a/dlls/shell32/tests/shelllink.c b/dlls/shell32/tests/shelllink.c
index 461d92b..6f12fb2 100644
--- a/dlls/shell32/tests/shelllink.c
+++ b/dlls/shell32/tests/shelllink.c
@@ -105,6 +105,7 @@ static void test_get_set(void)
IShellLinkW *slW = NULL;
char mypath[MAX_PATH];
char buffer[INFOTIPSIZE];
+ WIN32_FIND_DATAA finddata;
LPITEMIDLIST pidl, tmp_pidl;
const char * str;
int i;
@@ -160,6 +161,14 @@ static void test_get_set(void)
ok(r == S_FALSE || broken(r == S_OK) /* NT4/W2K */, "GetPath failed (0x%08x)\n", r);
ok(*buffer=='\0', "GetPath returned '%s'\n", buffer);
+ strcpy(buffer,"garbage");
+ memset(&finddata, 0xaa, sizeof(finddata));
+ r = IShellLinkA_GetPath(sl, buffer, sizeof(buffer), &finddata, SLGP_RAWPATH);
+ ok(r == S_FALSE || broken(r == S_OK) /* NT4/W2K */, "GetPath failed (0x%08x)\n", r);
+ ok(*buffer=='\0', "GetPath returned '%s'\n", buffer);
+ ok(finddata.dwFileAttributes == 0, "unexpected attributes %x\n", finddata.dwFileAttributes);
+ ok(finddata.cFileName[0] == 0, "unexpected filename '%s'\n", finddata.cFileName);
+
CoCreateInstance(&CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
&IID_IShellLinkW, (LPVOID*)&slW);
if (!slW /* Win9x */ || !pGetLongPathNameA /* NT4 */)
@@ -191,6 +200,14 @@ static void test_get_set(void)
ok(r == S_OK, "GetPath failed (0x%08x)\n", r);
ok(lstrcmpiA(buffer,str)==0, "GetPath returned '%s'\n", buffer);
+ strcpy(buffer,"garbage");
+ memset(&finddata, 0xaa, sizeof(finddata));
+ r = IShellLinkA_GetPath(sl, buffer, sizeof(buffer), &finddata, SLGP_RAWPATH);
+ ok(r == S_OK, "GetPath failed (0x%08x)\n", r);
+ ok(lstrcmpiA(buffer,str)==0, "GetPath returned '%s'\n", buffer);
+ ok(finddata.dwFileAttributes == 0, "unexpected attributes %x\n", finddata.dwFileAttributes);
+ ok(lstrcmpiA(finddata.cFileName, "file") == 0, "unexpected filename '%s'\n", finddata.cFileName);
+
/* Get some real path to play with */
GetWindowsDirectoryA( mypath, sizeof(mypath)-12 );
strcat(mypath, "\\regedit.exe");
@@ -241,6 +258,14 @@ static void test_get_set(void)
r = IShellLinkA_GetPath(sl, buffer, sizeof(buffer), NULL, SLGP_RAWPATH);
ok(r == S_OK, "GetPath failed (0x%08x)\n", r);
ok(lstrcmpiA(buffer, mypath)==0, "GetPath returned '%s'\n", buffer);
+
+ strcpy(buffer,"garbage");
+ memset(&finddata, 0xaa, sizeof(finddata));
+ r = IShellLinkA_GetPath(sl, buffer, sizeof(buffer), &finddata, SLGP_RAWPATH);
+ ok(r == S_OK, "GetPath failed (0x%08x)\n", r);
+ ok(lstrcmpiA(buffer, mypath)==0, "GetPath returned '%s'\n", buffer);
+ ok(finddata.dwFileAttributes != 0, "unexpected attributes %x\n", finddata.dwFileAttributes);
+ ok(lstrcmpiA(finddata.cFileName, "regedit.exe") == 0, "unexpected filename '%s'\n", finddata.cFileName);
}
if (pSHGetFolderLocation)
@@ -258,6 +283,14 @@ static void test_get_set(void)
ok(r == S_FALSE, "GetPath failed (0x%08x)\n", r);
ok(buffer[0] == 0, "GetPath returned '%s'\n", buffer);
+ strcpy(buffer,"garbage");
+ memset(&finddata, 0xaa, sizeof(finddata));
+ r = IShellLinkA_GetPath(sl, buffer, sizeof(buffer), &finddata, SLGP_RAWPATH);
+ ok(r == S_FALSE, "GetPath failed (0x%08x)\n", r);
+ ok(buffer[0] == 0, "GetPath returned '%s'\n", buffer);
+ ok(finddata.dwFileAttributes == 0, "unexpected attributes %x\n", finddata.dwFileAttributes);
+ ok(finddata.cFileName[0] == 0, "unexpected filename '%s'\n", finddata.cFileName);
+
pILFree(pidl_controls);
}
--
2.7.4
More information about the wine-patches
mailing list