Nikolay Sivov : shell32: Implement ParseName().
Alexandre Julliard
julliard at wine.codeweavers.com
Mon May 11 07:49:04 CDT 2015
Module: wine
Branch: master
Commit: e013a7e584863abb3d9bc5ce1339830b6560aba8
URL: http://source.winehq.org/git/wine.git/?a=commit;h=e013a7e584863abb3d9bc5ce1339830b6560aba8
Author: Nikolay Sivov <nsivov at codeweavers.com>
Date: Sun May 10 20:00:55 2015 +0300
shell32: Implement ParseName().
---
dlls/shell32/shelldispatch.c | 38 +++++++++++++++++++---
dlls/shell32/tests/shelldispatch.c | 65 ++++++++++++++++++++++++++++++++++++++
2 files changed, 98 insertions(+), 5 deletions(-)
diff --git a/dlls/shell32/shelldispatch.c b/dlls/shell32/shelldispatch.c
index f168477..6e13123 100644
--- a/dlls/shell32/shelldispatch.c
+++ b/dlls/shell32/shelldispatch.c
@@ -460,6 +460,8 @@ static HRESULT FolderItem_Constructor(VARIANT *dir, FolderItem **ppfi)
FolderItemImpl *This;
HRESULT ret;
+ TRACE("%s\n", debugstr_variant(dir));
+
*ppfi = NULL;
This = HeapAlloc(GetProcessHeap(), 0, sizeof(FolderItemImpl));
@@ -637,13 +639,39 @@ static HRESULT WINAPI FolderImpl_Items(Folder3 *iface, FolderItems **ppid)
return E_NOTIMPL;
}
-static HRESULT WINAPI FolderImpl_ParseName(Folder3 *iface, BSTR bName,
- FolderItem **ppid)
+static HRESULT WINAPI FolderImpl_ParseName(Folder3 *iface, BSTR name, FolderItem **item)
{
- FIXME("(%p,%s,%p)\n", iface, debugstr_w(bName), ppid);
+ FolderItem *self;
+ BSTR str;
+ WCHAR pathW[MAX_PATH];
+ VARIANT v;
+ HRESULT hr;
- *ppid = NULL;
- return E_NOTIMPL;
+ TRACE("(%p,%s,%p)\n", iface, debugstr_w(name), item);
+
+ *item = NULL;
+
+ if (!name || !name[0])
+ return S_FALSE;
+
+ hr = Folder3_get_Self(iface, &self);
+ if (FAILED(hr))
+ return hr;
+
+ hr = FolderItem_get_Path(self, &str);
+ FolderItem_Release(self);
+
+ PathCombineW(pathW, str, name);
+ SysFreeString(str);
+
+ if (!PathFileExistsW(pathW))
+ return S_FALSE;
+
+ V_VT(&v) = VT_BSTR;
+ V_BSTR(&v) = SysAllocString(pathW);
+ hr = FolderItem_Constructor(&v, item);
+ VariantClear(&v);
+ return hr;
}
static HRESULT WINAPI FolderImpl_NewFolder(Folder3 *iface, BSTR bName,
diff --git a/dlls/shell32/tests/shelldispatch.c b/dlls/shell32/tests/shelldispatch.c
index fe25eb4..851d775 100644
--- a/dlls/shell32/tests/shelldispatch.c
+++ b/dlls/shell32/tests/shelldispatch.c
@@ -679,6 +679,70 @@ todo_wine
IShellWindows_Release(shellwindows);
}
+static void test_ParseName(void)
+{
+ static const WCHAR cadabraW[] = {'c','a','d','a','b','r','a',0};
+ WCHAR pathW[MAX_PATH];
+ IShellDispatch *sd;
+ FolderItem *item;
+ Folder *folder;
+ HRESULT hr;
+ VARIANT v;
+ BSTR str;
+
+ hr = CoCreateInstance(&CLSID_Shell, NULL, CLSCTX_INPROC_SERVER,
+ &IID_IShellDispatch, (void**)&sd);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+
+ GetTempPathW(sizeof(pathW)/sizeof(pathW[0]), pathW);
+ V_VT(&v) = VT_BSTR;
+ V_BSTR(&v) = SysAllocString(pathW);
+ hr = IShellDispatch_NameSpace(sd, v, &folder);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+ VariantClear(&v);
+
+ item = (void*)0xdeadbeef;
+ hr = Folder_ParseName(folder, NULL, &item);
+ ok(hr == S_FALSE, "got 0x%08x\n", hr);
+ ok(item == NULL, "got %p\n", item);
+
+ /* empty name */
+ str = SysAllocStringLen(NULL, 0);
+ item = (void*)0xdeadbeef;
+ hr = Folder_ParseName(folder, str, &item);
+ ok(hr == S_FALSE, "got 0x%08x\n", hr);
+ ok(item == NULL, "got %p\n", item);
+ SysFreeString(str);
+
+ /* path doesn't exist */
+ str = SysAllocString(cadabraW);
+ item = (void*)0xdeadbeef;
+ hr = Folder_ParseName(folder, str, &item);
+ ok(hr == S_FALSE, "got 0x%08x\n", hr);
+ ok(item == NULL, "got %p\n", item);
+ SysFreeString(str);
+
+ lstrcatW(pathW, cadabraW);
+ CreateDirectoryW(pathW, NULL);
+
+ str = SysAllocString(cadabraW);
+ item = NULL;
+ hr = Folder_ParseName(folder, str, &item);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+ ok(item != NULL, "got %p\n", item);
+ SysFreeString(str);
+
+ hr = FolderItem_get_Path(item, &str);
+ ok(hr == S_OK, "got 0x%08x\n", hr);
+ ok(str[0] != 0, "path %s\n", wine_dbgstr_w(str));
+ SysFreeString(str);
+
+ RemoveDirectoryW(pathW);
+ FolderItem_Release(item);
+ Folder_Release(folder);
+ IShellDispatch_Release(sd);
+}
+
START_TEST(shelldispatch)
{
HRESULT r;
@@ -693,6 +757,7 @@ START_TEST(shelldispatch)
test_service();
test_ShellFolderViewDual();
test_ShellWindows();
+ test_ParseName();
CoUninitialize();
}
More information about the wine-cvs
mailing list