Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
51f5ab19
Commit
51f5ab19
authored
Jan 03, 2014
by
Nikolay Sivov
Committed by
Alexandre Julliard
Jan 03, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
scrrun: Implement Count() property for folder collection.
parent
0802e301
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
6 deletions
+66
-6
filesystem.c
dlls/scrrun/filesystem.c
+38
-4
filesystem.c
dlls/scrrun/tests/filesystem.c
+28
-2
No files found.
dlls/scrrun/filesystem.c
View file @
51f5ab19
...
...
@@ -39,6 +39,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(scrrun);
struct
foldercollection
{
IFolderCollection
IFolderCollection_iface
;
LONG
ref
;
BSTR
path
;
};
struct
folder
{
...
...
@@ -383,7 +384,10 @@ static ULONG WINAPI foldercoll_Release(IFolderCollection *iface)
TRACE
(
"(%p)->(%d)
\n
"
,
This
,
ref
);
if
(
!
ref
)
{
SysFreeString
(
This
->
path
);
heap_free
(
This
);
}
return
ref
;
}
...
...
@@ -471,8 +475,32 @@ static HRESULT WINAPI foldercoll_get__NewEnum(IFolderCollection *iface, IUnknown
static
HRESULT
WINAPI
foldercoll_get_Count
(
IFolderCollection
*
iface
,
LONG
*
count
)
{
struct
foldercollection
*
This
=
impl_from_IFolderCollection
(
iface
);
FIXME
(
"(%p)->(%p): stub
\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
(
data
.
dwFileAttributes
&
FILE_ATTRIBUTE_DIRECTORY
)
*
count
+=
1
;
}
while
(
FindNextFileW
(
handle
,
&
data
));
FindClose
(
handle
);
return
S_OK
;
}
static
const
IFolderCollectionVtbl
foldercollvtbl
=
{
...
...
@@ -489,7 +517,7 @@ static const IFolderCollectionVtbl foldercollvtbl = {
foldercoll_get_Count
};
static
HRESULT
create_foldercoll
(
IFolderCollection
**
folders
)
static
HRESULT
create_foldercoll
(
BSTR
path
,
IFolderCollection
**
folders
)
{
struct
foldercollection
*
This
;
...
...
@@ -500,6 +528,12 @@ static HRESULT create_foldercoll(IFolderCollection **folders)
This
->
IFolderCollection_iface
.
lpVtbl
=
&
foldercollvtbl
;
This
->
ref
=
1
;
This
->
path
=
SysAllocString
(
path
);
if
(
!
This
->
path
)
{
heap_free
(
This
);
return
E_OUTOFMEMORY
;
}
*
folders
=
&
This
->
IFolderCollection_iface
;
...
...
@@ -744,7 +778,7 @@ static HRESULT WINAPI folder_get_SubFolders(IFolder *iface, IFolderCollection **
if
(
!
folders
)
return
E_POINTER
;
return
create_foldercoll
(
folders
);
return
create_foldercoll
(
This
->
path
,
folders
);
}
static
HRESULT
WINAPI
folder_get_Files
(
IFolder
*
iface
,
IFileCollection
**
files
)
...
...
dlls/scrrun/tests/filesystem.c
View file @
51f5ab19
...
...
@@ -777,13 +777,17 @@ static void test_GetFolder(void)
static
void
test_FolderCollection
(
void
)
{
static
const
WCHAR
aW
[]
=
{
'\\'
,
'a'
,
0
};
static
const
WCHAR
bW
[]
=
{
'\\'
,
'b'
,
0
};
IFolderCollection
*
folders
;
WCHAR
buffW
[
MAX_PATH
];
WCHAR
buffW
[
MAX_PATH
],
pathW
[
MAX_PATH
],
path2W
[
MAX_PATH
];
LONG
count
,
count2
;
IFolder
*
folder
;
HRESULT
hr
;
BSTR
str
;
GetWindowsDirectoryW
(
buffW
,
MAX_PATH
);
GetTempPathW
(
MAX_PATH
,
buffW
);
str
=
SysAllocString
(
buffW
);
hr
=
IFileSystem3_GetFolder
(
fs3
,
str
,
&
folder
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
...
...
@@ -792,9 +796,31 @@ static void test_FolderCollection(void)
hr
=
IFolder_get_SubFolders
(
folder
,
NULL
);
ok
(
hr
==
E_POINTER
,
"got 0x%08x
\n
"
,
hr
);
lstrcpyW
(
pathW
,
buffW
);
lstrcatW
(
pathW
,
aW
);
CreateDirectoryW
(
pathW
,
NULL
);
hr
=
IFolder_get_SubFolders
(
folder
,
&
folders
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
count
=
0
;
hr
=
IFolderCollection_get_Count
(
folders
,
&
count
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
ok
(
count
>
0
,
"got %d
\n
"
,
count
);
lstrcpyW
(
path2W
,
buffW
);
lstrcatW
(
path2W
,
bW
);
CreateDirectoryW
(
path2W
,
NULL
);
/* every time property is requested it scans directory */
count2
=
0
;
hr
=
IFolderCollection_get_Count
(
folders
,
&
count2
);
ok
(
hr
==
S_OK
,
"got 0x%08x
\n
"
,
hr
);
ok
(
count2
>
count
,
"got %d, %d
\n
"
,
count
,
count2
);
RemoveDirectoryW
(
pathW
);
RemoveDirectoryW
(
path2W
);
IFolderCollection_Release
(
folders
);
IFolder_Release
(
folder
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment