Nikolay Sivov : scrrun: Implement Count() property for drive collection.

Alexandre Julliard julliard at winehq.org
Tue Mar 11 14:45:39 CDT 2014


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

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Tue Mar 11 00:21:03 2014 +0400

scrrun: Implement Count() property for drive collection.

---

 dlls/scrrun/filesystem.c       |   16 +++++++++++++---
 dlls/scrrun/tests/filesystem.c |    7 ++++---
 2 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/dlls/scrrun/filesystem.c b/dlls/scrrun/filesystem.c
index c052906..5daa5ce 100644
--- a/dlls/scrrun/filesystem.c
+++ b/dlls/scrrun/filesystem.c
@@ -54,6 +54,7 @@ struct drivecollection {
     IDriveCollection IDriveCollection_iface;
     LONG ref;
     DWORD drives;
+    LONG count;
 };
 
 struct enumdata {
@@ -1675,8 +1676,13 @@ static HRESULT WINAPI drivecoll_get__NewEnum(IDriveCollection *iface, IUnknown *
 static HRESULT WINAPI drivecoll_get_Count(IDriveCollection *iface, LONG *count)
 {
     struct drivecollection *This = impl_from_IDriveCollection(iface);
-    FIXME("(%p)->(%p): stub\n", This, count);
-    return E_NOTIMPL;
+
+    TRACE("(%p)->(%p)\n", This, count);
+
+    if (!count) return E_POINTER;
+
+    *count = This->count;
+    return S_OK;
 }
 
 static const IDriveCollectionVtbl drivecollectionvtbl = {
@@ -1695,6 +1701,7 @@ static const IDriveCollectionVtbl drivecollectionvtbl = {
 static HRESULT create_drivecoll(IDriveCollection **drives)
 {
     struct drivecollection *This;
+    DWORD mask;
 
     *drives = NULL;
 
@@ -1703,7 +1710,10 @@ static HRESULT create_drivecoll(IDriveCollection **drives)
 
     This->IDriveCollection_iface.lpVtbl = &drivecollectionvtbl;
     This->ref = 1;
-    This->drives = GetLogicalDrives();
+    This->drives = mask = GetLogicalDrives();
+    /* count set bits */
+    for (This->count = 0; mask; This->count++)
+        mask &= mask - 1;
 
     *drives = &This->IDriveCollection_iface;
     return S_OK;
diff --git a/dlls/scrrun/tests/filesystem.c b/dlls/scrrun/tests/filesystem.c
index c14e846..8502934 100644
--- a/dlls/scrrun/tests/filesystem.c
+++ b/dlls/scrrun/tests/filesystem.c
@@ -1157,12 +1157,14 @@ static void test_DriveCollection(void)
     hr = IDriveCollection_get__NewEnum(drives, (IUnknown**)&enumvar);
     ok(hr == S_OK, "got 0x%08x\n", hr);
 
+    hr = IDriveCollection_get_Count(drives, NULL);
+    ok(hr == E_POINTER, "got 0x%08x\n", hr);
+
     count = 0;
     hr = IDriveCollection_get_Count(drives, &count);
-todo_wine {
     ok(hr == S_OK, "got 0x%08x\n", hr);
     ok(count > 0, "got %d\n", count);
-}
+
     V_VT(&var) = VT_EMPTY;
     fetched = -1;
     hr = IEnumVARIANT_Next(enumvar, 0, &var, &fetched);
@@ -1176,7 +1178,6 @@ todo_wine {
     ok(hr == S_OK, "got 0x%08x\n", hr);
 
     hr = IEnumVARIANT_Skip(enumvar, 1);
-todo_wine
     ok(hr == S_FALSE, "got 0x%08x\n", hr);
 
     IEnumVARIANT_Release(enumvar);




More information about the wine-cvs mailing list