Commit 108c2731 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

scrrun: Implement Count() property for file collection.

parent 2b628405
......@@ -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 = {
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment