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

Alexandre Julliard julliard at winehq.org
Mon May 19 15:09:59 CDT 2014


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

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Sat May 17 15:15:42 2014 +0400

scrrun: Implement Count() property for file collection.

---

 dlls/scrrun/filesystem.c       |   28 ++++++++++++++++++++++++++--
 dlls/scrrun/tests/filesystem.c |    4 ----
 2 files changed, 26 insertions(+), 6 deletions(-)

diff --git a/dlls/scrrun/filesystem.c b/dlls/scrrun/filesystem.c
index aead0d2..f5afb91 100644
--- a/dlls/scrrun/filesystem.c
+++ b/dlls/scrrun/filesystem.c
@@ -1831,8 +1831,32 @@ static HRESULT WINAPI filecoll_get__NewEnum(IFileCollection *iface, IUnknown **p
 static HRESULT WINAPI filecoll_get_Count(IFileCollection *iface, LONG *count)
 {
     struct filecollection *This = impl_from_IFileCollection(iface);
-    FIXME("(%p)->(%p)\n", This, count);
-    return E_NOTIMPL;
+    static const WCHAR allW[] = {'\\','*',0};
+    WIN32_FIND_DATAW data;
+    WCHAR pathW[MAX_PATH];
+    HANDLE handle;
+
+    TRACE("(%p)->(%p)\n", This, count);
+
+    if(!count)
+        return E_POINTER;
+
+    *count = 0;
+
+    strcpyW(pathW, This->path);
+    strcatW(pathW, allW);
+    handle = FindFirstFileW(pathW, &data);
+    if (handle == INVALID_HANDLE_VALUE)
+        return HRESULT_FROM_WIN32(GetLastError());
+
+    do
+    {
+        if (is_file_data(&data))
+            *count += 1;
+    } while (FindNextFileW(handle, &data));
+    FindClose(handle);
+
+    return S_OK;
 }
 
 static const IFileCollectionVtbl filecollectionvtbl = {
diff --git a/dlls/scrrun/tests/filesystem.c b/dlls/scrrun/tests/filesystem.c
index c004eaf..531b732 100644
--- a/dlls/scrrun/tests/filesystem.c
+++ b/dlls/scrrun/tests/filesystem.c
@@ -1084,9 +1084,7 @@ static void test_FileCollection(void)
 
     count = 0;
     hr = IFileCollection_get_Count(files, &count);
-todo_wine
     ok(hr == S_OK, "got 0x%08x\n", hr);
-todo_wine
     ok(count == 2, "got %d\n", count);
 
     lstrcpyW(pathW, buffW);
@@ -1097,9 +1095,7 @@ todo_wine
     /* every time property is requested it scans directory */
     count = 0;
     hr = IFileCollection_get_Count(files, &count);
-todo_wine
     ok(hr == S_OK, "got 0x%08x\n", hr);
-todo_wine
     ok(count == 3, "got %d\n", count);
 
     hr = IFileCollection_get__NewEnum(files, NULL);




More information about the wine-cvs mailing list