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
5c37020a
Commit
5c37020a
authored
Aug 31, 2017
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fusion/tests: Simplify directory recursion and avoid redundant buffers.
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
99f08cc7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
58 deletions
+57
-58
asmenum.c
dlls/fusion/tests/asmenum.c
+57
-58
No files found.
dlls/fusion/tests/asmenum.c
View file @
5c37020a
...
...
@@ -217,79 +217,80 @@ static void test_CreateAssemblyEnum(void)
typedef
struct
_tagASMNAME
{
struct
list
entry
;
LPSTR
data
;
char
data
[
1
]
;
}
ASMNAME
;
static
BOOL
enum_gac_assemblies
(
struct
list
*
assemblies
,
int
depth
,
LPSTR
path
)
static
void
enum_gac_assembly_dirs
(
struct
list
*
assemblies
,
const
char
*
parent
,
char
path
[
MAX_PATH
]
)
{
static
const
char
format
[]
=
"%s, Version=%s, Culture=%s, PublicKeyToken=%s"
;
WIN32_FIND_DATAA
ffd
;
CHAR
buf
[
MAX_PATH
];
CHAR
disp
[
MAX_PATH
];
ASMNAME
*
name
;
HANDLE
hfind
;
LPSTR
ptr
;
static
CHAR
parent
[
MAX_PATH
];
int
len
;
char
*
ptr
,
*
end
=
path
+
strlen
(
path
);
sprintf
(
buf
,
"%s
\\
*"
,
path
);
hfind
=
FindFirstFileA
(
buf
,
&
ffd
);
if
(
hfind
==
INVALID_HANDLE_VALUE
)
return
FALSE
;
lstrcpynA
(
end
,
"
\\
*"
,
path
+
MAX_PATH
-
end
);
hfind
=
FindFirstFileA
(
path
,
&
ffd
);
if
(
hfind
==
INVALID_HANDLE_VALUE
)
return
;
end
++
;
do
{
if
(
!
lstrcmpA
(
ffd
.
cFileName
,
"."
)
||
!
lstrcmpA
(
ffd
.
cFileName
,
".."
))
continue
;
char
culture
[
MAX_PATH
];
if
(
!
strcmp
(
ffd
.
cFileName
,
"."
)
||
!
strcmp
(
ffd
.
cFileName
,
".."
))
continue
;
if
(
depth
==
0
)
*
end
=
0
;
/* Directories with no dll or exe will not be enumerated */
snprintf
(
end
,
path
+
MAX_PATH
-
end
,
"%s
\\
%s.dll"
,
ffd
.
cFileName
,
parent
);
if
(
GetFileAttributesA
(
path
)
==
INVALID_FILE_ATTRIBUTES
)
{
lstrcpyA
(
parent
,
ffd
.
cFileName
);
snprintf
(
end
,
path
+
MAX_PATH
-
end
,
"%s
\\
%s.exe"
,
ffd
.
cFileName
,
parent
);
if
(
GetFileAttributesA
(
path
)
==
INVALID_FILE_ATTRIBUTES
)
continue
;
}
else
if
(
depth
==
1
)
if
(
!
(
ptr
=
strchr
(
ffd
.
cFileName
,
'_'
)))
continue
;
*
ptr
++
=
0
;
if
(
*
ptr
!=
'_'
)
{
char
culture
[
MAX_PATH
];
char
dll
[
MAX_PATH
],
exe
[
MAX_PATH
];
lstrcpyA
(
culture
,
ptr
);
*
strchr
(
culture
,
'_'
)
=
0
;
}
else
lstrcpyA
(
culture
,
"neutral"
);
/* Directories with no dll or exe will not be enumerated */
sprintf
(
dll
,
"%s
\\
%s
\\
%s.dll"
,
path
,
ffd
.
cFileName
,
parent
);
sprintf
(
exe
,
"%s
\\
%s
\\
%s.exe"
,
path
,
ffd
.
cFileName
,
parent
);
if
(
GetFileAttributesA
(
dll
)
==
INVALID_FILE_ATTRIBUTES
&&
GetFileAttributesA
(
exe
)
==
INVALID_FILE_ATTRIBUTES
)
continue
;
ptr
=
strchr
(
ptr
,
'_'
);
ptr
++
;
len
=
sizeof
(
format
)
+
strlen
(
parent
)
+
strlen
(
ffd
.
cFileName
)
+
strlen
(
culture
)
+
strlen
(
ptr
);
ptr
=
strstr
(
ffd
.
cFileName
,
"_"
);
*
ptr
=
'\0'
;
ptr
++
;
name
=
HeapAlloc
(
GetProcessHeap
(),
0
,
offsetof
(
ASMNAME
,
data
[
len
]
));
sprintf
(
name
->
data
,
format
,
parent
,
ffd
.
cFileName
,
culture
,
ptr
);
list_add_tail
(
assemblies
,
&
name
->
entry
);
}
while
(
FindNextFileA
(
hfind
,
&
ffd
)
!=
0
);
if
(
*
ptr
!=
'_'
)
{
lstrcpyA
(
culture
,
ptr
);
*
strstr
(
culture
,
"_"
)
=
'\0'
;
}
else
lstrcpyA
(
culture
,
"neutral"
);
ptr
=
strchr
(
ptr
,
'_'
);
ptr
++
;
sprintf
(
buf
,
", Version=%s, Culture=%s, PublicKeyToken=%s"
,
ffd
.
cFileName
,
culture
,
ptr
);
lstrcpyA
(
disp
,
parent
);
lstrcatA
(
disp
,
buf
);
name
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
ASMNAME
));
name
->
data
=
HeapAlloc
(
GetProcessHeap
(),
0
,
lstrlenA
(
disp
)
+
1
);
lstrcpyA
(
name
->
data
,
disp
);
list_add_tail
(
assemblies
,
&
name
->
entry
);
continue
;
}
FindClose
(
hfind
);
}
sprintf
(
buf
,
"%s
\\
%s"
,
path
,
ffd
.
cFileName
);
enum_gac_assemblies
(
assemblies
,
depth
+
1
,
buf
);
static
void
enum_gac_assemblies
(
struct
list
*
assemblies
,
char
path
[
MAX_PATH
])
{
WIN32_FIND_DATAA
ffd
;
HANDLE
hfind
;
char
*
end
=
path
+
strlen
(
path
);
lstrcpynA
(
end
,
"
\\
*"
,
path
+
MAX_PATH
-
end
);
hfind
=
FindFirstFileA
(
path
,
&
ffd
);
if
(
hfind
==
INVALID_HANDLE_VALUE
)
return
;
end
++
;
do
{
if
(
!
strcmp
(
ffd
.
cFileName
,
"."
)
||
!
strcmp
(
ffd
.
cFileName
,
".."
))
continue
;
lstrcpynA
(
end
,
ffd
.
cFileName
,
path
+
MAX_PATH
-
end
);
enum_gac_assembly_dirs
(
assemblies
,
ffd
.
cFileName
,
path
);
}
while
(
FindNextFileA
(
hfind
,
&
ffd
)
!=
0
);
FindClose
(
hfind
);
return
TRUE
;
}
static
void
test_enumerate
(
void
)
...
...
@@ -311,18 +312,18 @@ static void test_enumerate(void)
to_multibyte
(
path
,
buf
);
lstrcatA
(
path
,
"_32"
);
enum_gac_assemblies
(
&
assemblies
,
0
,
path
);
enum_gac_assemblies
(
&
assemblies
,
path
);
to_multibyte
(
path
,
buf
);
lstrcatA
(
path
,
"_64"
);
enum_gac_assemblies
(
&
assemblies
,
0
,
path
);
enum_gac_assemblies
(
&
assemblies
,
path
);
to_multibyte
(
path
,
buf
);
lstrcatA
(
path
,
"_MSIL"
);
enum_gac_assemblies
(
&
assemblies
,
0
,
path
);
enum_gac_assemblies
(
&
assemblies
,
path
);
to_multibyte
(
path
,
buf
);
enum_gac_assemblies
(
&
assemblies
,
0
,
path
);
enum_gac_assemblies
(
&
assemblies
,
path
);
asmenum
=
NULL
;
hr
=
pCreateAssemblyEnum
(
&
asmenum
,
NULL
,
NULL
,
ASM_CACHE_GAC
,
NULL
);
...
...
@@ -345,7 +346,6 @@ static void test_enumerate(void)
found
=
TRUE
;
list_remove
(
&
asmname
->
entry
);
HeapFree
(
GetProcessHeap
(),
0
,
asmname
->
data
);
HeapFree
(
GetProcessHeap
(),
0
,
asmname
);
break
;
}
...
...
@@ -369,7 +369,6 @@ static void test_enumerate(void)
ok
(
FALSE
,
"Assembly not enumerated: %s
\n
"
,
asmname
->
data
);
list_remove
(
&
asmname
->
entry
);
HeapFree
(
GetProcessHeap
(),
0
,
asmname
->
data
);
HeapFree
(
GetProcessHeap
(),
0
,
asmname
);
}
...
...
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