ole32: Simplify IsEqual() for file monikers.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
7c518c3bd1
commit
fb31e6f3f3
|
@ -57,6 +57,15 @@ static inline FileMonikerImpl *impl_from_IROTData(IROTData *iface)
|
||||||
return CONTAINING_RECORD(iface, FileMonikerImpl, IROTData_iface);
|
return CONTAINING_RECORD(iface, FileMonikerImpl, IROTData_iface);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const IMonikerVtbl VT_FileMonikerImpl;
|
||||||
|
|
||||||
|
static FileMonikerImpl *unsafe_impl_from_IMoniker(IMoniker *iface)
|
||||||
|
{
|
||||||
|
if (iface->lpVtbl != &VT_FileMonikerImpl)
|
||||||
|
return NULL;
|
||||||
|
return CONTAINING_RECORD(iface, FileMonikerImpl, IMoniker_iface);
|
||||||
|
}
|
||||||
|
|
||||||
/* Local function used by filemoniker implementation */
|
/* Local function used by filemoniker implementation */
|
||||||
static HRESULT FileMonikerImpl_Construct(FileMonikerImpl* iface, LPCOLESTR lpszPathName);
|
static HRESULT FileMonikerImpl_Construct(FileMonikerImpl* iface, LPCOLESTR lpszPathName);
|
||||||
|
|
||||||
|
@ -735,40 +744,20 @@ FileMonikerImpl_Enum(IMoniker* iface,BOOL fForward, IEnumMoniker** ppenumMoniker
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
static HRESULT WINAPI FileMonikerImpl_IsEqual(IMoniker *iface, IMoniker *other)
|
||||||
* FileMoniker_IsEqual
|
|
||||||
*/
|
|
||||||
static HRESULT WINAPI
|
|
||||||
FileMonikerImpl_IsEqual(IMoniker* iface,IMoniker* pmkOtherMoniker)
|
|
||||||
{
|
{
|
||||||
FileMonikerImpl *This = impl_from_IMoniker(iface);
|
FileMonikerImpl *moniker = impl_from_IMoniker(iface), *other_moniker;
|
||||||
CLSID clsid;
|
|
||||||
LPOLESTR filePath;
|
|
||||||
IBindCtx* bind;
|
|
||||||
HRESULT res;
|
|
||||||
|
|
||||||
TRACE("(%p,%p)\n",iface,pmkOtherMoniker);
|
TRACE("%p, %p.\n", iface, other);
|
||||||
|
|
||||||
if (pmkOtherMoniker==NULL)
|
if (!other)
|
||||||
|
return E_INVALIDARG;
|
||||||
|
|
||||||
|
other_moniker = unsafe_impl_from_IMoniker(other);
|
||||||
|
if (!other_moniker)
|
||||||
return S_FALSE;
|
return S_FALSE;
|
||||||
|
|
||||||
IMoniker_GetClassID(pmkOtherMoniker,&clsid);
|
return !wcsicmp(moniker->filePathName, other_moniker->filePathName) ? S_OK : S_FALSE;
|
||||||
|
|
||||||
if (!IsEqualCLSID(&clsid,&CLSID_FileMoniker))
|
|
||||||
return S_FALSE;
|
|
||||||
|
|
||||||
res = CreateBindCtx(0,&bind);
|
|
||||||
if (FAILED(res)) return res;
|
|
||||||
|
|
||||||
res = S_FALSE;
|
|
||||||
if (SUCCEEDED(IMoniker_GetDisplayName(pmkOtherMoniker,bind,NULL,&filePath))) {
|
|
||||||
if (!lstrcmpiW(filePath, This->filePathName))
|
|
||||||
res = S_OK;
|
|
||||||
CoTaskMemFree(filePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
IBindCtx_Release(bind);
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
|
|
|
@ -1981,8 +1981,8 @@ static void test_file_monikers(void)
|
||||||
{0x20ac, 0x2020, 0x100, 0x101, 0x102, 0x103, 0x104, 0x105, 0x106, 0x107, 0x108, 0x109, 0x10a, 0x10b, 0x10c, 0},
|
{0x20ac, 0x2020, 0x100, 0x101, 0x102, 0x103, 0x104, 0x105, 0x106, 0x107, 0x108, 0x109, 0x10a, 0x10b, 0x10c, 0},
|
||||||
};
|
};
|
||||||
WCHAR filename[MAX_PATH], path[MAX_PATH];
|
WCHAR filename[MAX_PATH], path[MAX_PATH];
|
||||||
|
IMoniker *moniker, *moniker2;
|
||||||
BIND_OPTS bind_opts;
|
BIND_OPTS bind_opts;
|
||||||
IMoniker *moniker;
|
|
||||||
IStorage *storage;
|
IStorage *storage;
|
||||||
IBindCtx *bindctx;
|
IBindCtx *bindctx;
|
||||||
STATSTG statstg;
|
STATSTG statstg;
|
||||||
|
@ -2057,6 +2057,22 @@ static void test_file_monikers(void)
|
||||||
IMoniker_Release(moniker);
|
IMoniker_Release(moniker);
|
||||||
|
|
||||||
DeleteFileW(filename);
|
DeleteFileW(filename);
|
||||||
|
|
||||||
|
/* IsEqual() */
|
||||||
|
hr = CreateFileMoniker(L"test.bmp", &moniker);
|
||||||
|
ok(hr == S_OK, "Failed to create a moniker, hr %#x.\n", hr);
|
||||||
|
|
||||||
|
hr = CreateFileMoniker(L"TEST.bmp", &moniker2);
|
||||||
|
ok(hr == S_OK, "Failed to create a moniker, hr %#x.\n", hr);
|
||||||
|
|
||||||
|
hr = IMoniker_IsEqual(moniker, moniker2);
|
||||||
|
ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
|
||||||
|
|
||||||
|
hr = IMoniker_IsEqual(moniker, NULL);
|
||||||
|
ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr);
|
||||||
|
|
||||||
|
IMoniker_Release(moniker2);
|
||||||
|
IMoniker_Release(moniker);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void test_item_moniker(void)
|
static void test_item_moniker(void)
|
||||||
|
|
Loading…
Reference in New Issue