Nikolay Sivov : scrrun: Implement GetDriveName().

Alexandre Julliard julliard at wine.codeweavers.com
Mon Jun 23 12:57:40 CDT 2014


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

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Sat Jun 21 20:30:11 2014 +0400

scrrun: Implement GetDriveName().

---

 dlls/scrrun/filesystem.c       | 15 ++++++++++----
 dlls/scrrun/tests/filesystem.c | 46 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 57 insertions(+), 4 deletions(-)

diff --git a/dlls/scrrun/filesystem.c b/dlls/scrrun/filesystem.c
index 54deb97..c85fe63 100644
--- a/dlls/scrrun/filesystem.c
+++ b/dlls/scrrun/filesystem.c
@@ -2937,12 +2937,19 @@ static HRESULT WINAPI filesys_BuildPath(IFileSystem3 *iface, BSTR Path,
     return S_OK;
 }
 
-static HRESULT WINAPI filesys_GetDriveName(IFileSystem3 *iface, BSTR Path,
-                                            BSTR *pbstrResult)
+static HRESULT WINAPI filesys_GetDriveName(IFileSystem3 *iface, BSTR path, BSTR *drive)
 {
-    FIXME("%p %s %p\n", iface, debugstr_w(Path), pbstrResult);
+    TRACE("(%p)->(%s %p)\n", iface, debugstr_w(path), drive);
 
-    return E_NOTIMPL;
+    if (!drive)
+        return E_POINTER;
+
+    *drive = NULL;
+
+    if (path && strlenW(path) > 1 && path[1] == ':')
+        *drive = SysAllocStringLen(path, 2);
+
+    return S_OK;
 }
 
 static inline DWORD get_parent_folder_name(const WCHAR *path, DWORD len)
diff --git a/dlls/scrrun/tests/filesystem.c b/dlls/scrrun/tests/filesystem.c
index c06b43d..c9b41c0 100644
--- a/dlls/scrrun/tests/filesystem.c
+++ b/dlls/scrrun/tests/filesystem.c
@@ -1745,6 +1745,51 @@ todo_wine
     SysFreeString(nameW);
 }
 
+struct getdrivename_test {
+    const WCHAR path[10];
+    const WCHAR drive[5];
+};
+
+static const struct getdrivename_test getdrivenametestdata[] = {
+    { {'C',':','\\','1','.','t','s','t',0}, {'C',':',0} },
+    { {'O',':','\\','1','.','t','s','t',0}, {'O',':',0} },
+    { {'O',':',0}, {'O',':',0} },
+    { {'o',':',0}, {'o',':',0} },
+    { {'O','O',':',0} },
+    { {':',0} },
+    { {'O',0} },
+    { { 0 } }
+};
+
+static void test_GetDriveName(void)
+{
+    const struct getdrivename_test *ptr = getdrivenametestdata;
+    HRESULT hr;
+    BSTR name;
+
+    hr = IFileSystem3_GetDriveName(fs3, NULL, NULL);
+    ok(hr == E_POINTER, "got 0x%08x\n", hr);
+
+    name = (void*)0xdeadbeef;
+    hr = IFileSystem3_GetDriveName(fs3, NULL, &name);
+    ok(hr == S_OK, "got 0x%08x\n", hr);
+    ok(name == NULL, "got %p\n", name);
+
+    while (*ptr->path) {
+        BSTR path = SysAllocString(ptr->path);
+        name = (void*)0xdeadbeef;
+        hr = IFileSystem3_GetDriveName(fs3, path, &name);
+        ok(hr == S_OK, "got 0x%08x\n", hr);
+        if (name)
+            ok(!lstrcmpW(ptr->drive, name), "got %s, expected %s\n", wine_dbgstr_w(name), wine_dbgstr_w(ptr->drive));
+        else
+            ok(!*ptr->drive, "got %s, expected %s\n", wine_dbgstr_w(name), wine_dbgstr_w(ptr->drive));
+        SysFreeString(path);
+        SysFreeString(name);
+        ptr++;
+    }
+}
+
 START_TEST(filesystem)
 {
     HRESULT hr;
@@ -1777,6 +1822,7 @@ START_TEST(filesystem)
     test_WriteLine();
     test_ReadAll();
     test_Read();
+    test_GetDriveName();
 
     IFileSystem3_Release(fs3);
 




More information about the wine-cvs mailing list