scrrun: Implement Count() property for file collection.

This commit is contained in:
Nikolay Sivov 2014-05-17 15:15:42 +04:00 committed by Alexandre Julliard
parent 2b628405cd
commit 108c27313b
2 changed files with 26 additions and 6 deletions

View File

@ -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 = {

View File

@ -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);