Jacek Caban : urlmon: Use CoInternetParseIUri instead of IUri:: GetPath in file protocol handler implementation.

Alexandre Julliard julliard at winehq.org
Mon Jun 27 17:41:18 CDT 2011


Module: wine
Branch: master
Commit: 7ccbbd86ba5bf46615bf75a6149279e682f124d0
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=7ccbbd86ba5bf46615bf75a6149279e682f124d0

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Sat Jun 25 19:04:16 2011 +0200

urlmon: Use CoInternetParseIUri instead of IUri::GetPath in file protocol handler implementation.

---

 dlls/urlmon/file.c           |   11 ++++++-----
 dlls/urlmon/tests/protocol.c |   18 ++++++++++++++++++
 2 files changed, 24 insertions(+), 5 deletions(-)

diff --git a/dlls/urlmon/file.c b/dlls/urlmon/file.c
index 418b708..8dce0bf 100644
--- a/dlls/urlmon/file.c
+++ b/dlls/urlmon/file.c
@@ -245,12 +245,13 @@ static HRESULT WINAPI FileProtocol_StartEx(IInternetProtocolEx *iface, IUri *pUr
         DWORD grfPI, HANDLE *dwReserved)
 {
     FileProtocol *This = impl_from_IInternetProtocolEx(iface);
+    WCHAR path[MAX_PATH];
     BINDINFO bindinfo;
     DWORD grfBINDF = 0;
-    DWORD scheme;
+    DWORD scheme, size;
     LPWSTR mime = NULL;
     WCHAR null_char = 0;
-    BSTR path, url;
+    BSTR url;
     HRESULT hres;
 
     TRACE("(%p)->(%p %p %p %08x %p)\n", This, pUri, pOIProtSink,
@@ -288,14 +289,14 @@ static HRESULT WINAPI FileProtocol_StartEx(IInternetProtocolEx *iface, IUri *pUr
 
     IInternetProtocolSink_ReportProgress(pOIProtSink, BINDSTATUS_SENDINGREQUEST, &null_char);
 
-    hres = IUri_GetPath(pUri, &path);
+    size = 0;
+    hres = CoInternetParseIUri(pUri, PARSE_PATH_FROM_URL, 0, path, sizeof(path)/sizeof(WCHAR), &size, 0);
     if(FAILED(hres)) {
-        ERR("GetPath failed: %08x\n", hres);
+        WARN("CoInternetParseIUri failed: %08x\n", hres);
         return report_result(pOIProtSink, hres, 0);
     }
 
     hres = open_file(This, path, pOIProtSink);
-    SysFreeString(path);
     if(FAILED(hres))
         return hres;
 
diff --git a/dlls/urlmon/tests/protocol.c b/dlls/urlmon/tests/protocol.c
index b547ad8..0cc14f5 100644
--- a/dlls/urlmon/tests/protocol.c
+++ b/dlls/urlmon/tests/protocol.c
@@ -2447,6 +2447,24 @@ static void test_file_protocol_url(LPCWSTR url)
 
         IUri_Release(uri);
         IInternetProtocolEx_Release(protocolex);
+
+        hres = pCreateUri(url, 0, 0, &uri);
+        ok(hres == S_OK, "CreateUri failed: %08x\n", hres);
+
+        hres = IClassFactory_CreateInstance(factory, NULL, &IID_IInternetProtocolEx, (void**)&protocolex);
+        ok(hres == S_OK, "Could not get IInternetProtocolEx: %08x\n", hres);
+
+        if(file_protocol_start(NULL, NULL, protocolex, uri, TRUE)) {
+            hres = IInternetProtocolEx_Read(protocolex, buf, 2, &cb);
+            ok(hres == S_OK, "Read failed: %08x\n", hres);
+            hres = IInternetProtocolEx_LockRequest(protocolex, 0);
+            ok(hres == S_OK, "LockRequest failed: %08x\n", hres);
+            hres = IInternetProtocolEx_UnlockRequest(protocolex);
+            ok(hres == S_OK, "UnlockRequest failed: %08x\n", hres);
+        }
+
+        IUri_Release(uri);
+        IInternetProtocolEx_Release(protocolex);
     }else {
         win_skip("Skipping file protocol StartEx tests\n");
     }




More information about the wine-cvs mailing list