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
f3b88212
Commit
f3b88212
authored
Apr 28, 2020
by
Fabian Maurer
Committed by
Alexandre Julliard
Apr 29, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
find.exe: Implement file searching.
Signed-off-by:
Fabian Maurer
<
dark.shadow4@web.de
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
83933c59
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
55 additions
and
25 deletions
+55
-25
find.c
programs/find/find.c
+53
-6
find.rc
programs/find/find.rc
+1
-0
resources.h
programs/find/resources.h
+1
-0
find.c
programs/find/tests/find.c
+0
-19
No files found.
programs/find/find.c
View file @
f3b88212
...
...
@@ -147,7 +147,9 @@ int __cdecl wmain(int argc, WCHAR *argv[])
WCHAR
*
tofind
=
NULL
;
int
i
;
int
exitcode
;
HANDLE
input
;
int
file_paths_len
=
0
;
int
file_paths_max
=
0
;
WCHAR
**
file_paths
=
NULL
;
TRACE
(
"running find:"
);
for
(
i
=
0
;
i
<
argc
;
i
++
)
...
...
@@ -156,8 +158,6 @@ int __cdecl wmain(int argc, WCHAR *argv[])
}
TRACE
(
"
\n
"
);
input
=
GetStdHandle
(
STD_INPUT_HANDLE
);
for
(
i
=
1
;
i
<
argc
;
i
++
)
{
if
(
argv
[
i
][
0
]
==
'/'
)
...
...
@@ -165,14 +165,18 @@ int __cdecl wmain(int argc, WCHAR *argv[])
output_resource_message
(
IDS_INVALID_SWITCH
);
return
2
;
}
else
if
(
tofind
==
NULL
)
else
if
(
tofind
==
NULL
)
{
tofind
=
argv
[
i
];
}
else
{
FIXME
(
"Searching files not supported yet
\n
"
);
return
1000
;
if
(
file_paths_len
>=
file_paths_max
)
{
file_paths_max
=
file_paths_max
?
file_paths_max
*
2
:
2
;
file_paths
=
heap_realloc
(
file_paths
,
sizeof
(
WCHAR
*
)
*
file_paths_max
);
}
file_paths
[
file_paths_len
++
]
=
argv
[
i
];
}
}
...
...
@@ -183,6 +187,47 @@ int __cdecl wmain(int argc, WCHAR *argv[])
}
exitcode
=
1
;
if
(
file_paths_len
>
0
)
{
for
(
i
=
0
;
i
<
file_paths_len
;
i
++
)
{
HANDLE
input
;
WCHAR
file_path_upper
[
MAX_PATH
];
wcscpy
(
file_path_upper
,
file_paths
[
i
]);
wcsupr
(
file_path_upper
);
input
=
CreateFileW
(
file_paths
[
i
],
GENERIC_READ
,
0
,
NULL
,
OPEN_EXISTING
,
0
,
NULL
);
if
(
input
==
INVALID_HANDLE_VALUE
)
{
WCHAR
buffer_message
[
64
];
WCHAR
message
[
300
];
LoadStringW
(
GetModuleHandleW
(
NULL
),
IDS_FILE_NOT_FOUND
,
buffer_message
,
ARRAY_SIZE
(
buffer_message
));
wsprintfW
(
message
,
buffer_message
,
file_path_upper
);
write_to_stdout
(
message
);
continue
;
}
write_to_stdout
(
L"
\r\n
---------- "
);
write_to_stdout
(
file_path_upper
);
write_to_stdout
(
L"
\r\n
"
);
while
((
line
=
read_line_from_handle
(
input
))
!=
NULL
)
{
if
(
run_find_for_line
(
line
,
tofind
))
exitcode
=
0
;
heap_free
(
line
);
}
CloseHandle
(
input
);
}
}
else
{
HANDLE
input
=
GetStdHandle
(
STD_INPUT_HANDLE
);
while
((
line
=
read_line_from_handle
(
input
))
!=
NULL
)
{
if
(
run_find_for_line
(
line
,
tofind
))
...
...
@@ -190,6 +235,8 @@ int __cdecl wmain(int argc, WCHAR *argv[])
heap_free
(
line
);
}
}
heap_free
(
file_paths
);
return
exitcode
;
}
programs/find/find.rc
View file @
f3b88212
...
...
@@ -22,4 +22,5 @@ STRINGTABLE
{
IDS_INVALID_PARAMETER "FIND: Parameter format not correct\r\n"
IDS_INVALID_SWITCH "FIND: Invalid switch\r\n"
IDS_FILE_NOT_FOUND "File not found - %s\r\n"
}
programs/find/resources.h
View file @
f3b88212
...
...
@@ -23,5 +23,6 @@
#define IDS_INVALID_PARAMETER 1000
#define IDS_INVALID_SWITCH 1001
#define IDS_FILE_NOT_FOUND 1002
#endif
/* __WINE_FIND_RESOURCES_H */
programs/find/tests/find.c
View file @
f3b88212
...
...
@@ -305,7 +305,6 @@ static void run_find_file_multi(void)
"File not found - %s
\r\n
"
,
path_temp_file1
,
path_temp_file2
,
path_temp_file3
);
todo_wine
run_find_stdin_
(
commandline_new
,
(
BYTE
*
)
""
,
0
,
(
BYTE
*
)
out_expected
,
strlen
(
out_expected
),
0
,
__FILE__
,
__LINE__
);
CloseHandle
(
handle_file
);
...
...
@@ -322,7 +321,6 @@ static void test_errors(void)
todo_wine
/* Quotes are not properly passed into wine yet */
run_find_stdin_str
(
"
\"
test"
,
""
,
"FIND: Parameter format not correct
\r\n
"
,
2
);
run_find_stdin_str
(
"
\"
test
\"
/XYZ"
,
""
,
"FIND: Invalid switch
\r\n
"
,
2
);
todo_wine
run_find_stdin_str
(
"
\"
test
\"
C:
\\
doesnotexist.dat"
,
""
,
"File not found - C:
\\
DOESNOTEXIST.DAT
\r\n
"
,
1
);
}
...
...
@@ -398,19 +396,12 @@ static void test_unicode_support_stdin(void)
static
void
test_file_search
(
void
)
{
todo_wine
run_find_file_str
(
"
\"\"
"
,
"test"
,
""
,
1
);
todo_wine
run_find_file_str
(
"
\"
test
\"
"
,
""
,
""
,
1
);
todo_wine
run_find_file_str
(
"
\"
test
\"
"
,
"test"
,
"test
\r\n
"
,
0
);
todo_wine
run_find_file_str
(
"
\"
test
\"
"
,
"test2"
,
"test2
\r\n
"
,
0
);
todo_wine
run_find_file_str
(
"
\"
test
\"
"
,
"test
\r
2"
,
"test
\r
2
\r\n
"
,
0
);
todo_wine
run_find_file_str
(
"
\"
test2
\"
"
,
"test"
,
""
,
1
);
todo_wine
run_find_file_str
(
"
\"
test
\"
"
,
"test
\n
other
\n
test2
\n
test3"
,
"test
\r\n
test2
\r\n
test3
\r\n
"
,
0
);
}
...
...
@@ -419,31 +410,21 @@ static void test_unicode_support_file(void)
/* Test unicode support on files */
/* Test UTF-8 BOM */
todo_wine
run_find_file_unicode
(
str_en_utf8_nobom
,
str_en_utf8_nobom
,
0
);
todo_wine
run_find_file_unicode
(
str_en_utf8_bom
,
str_en_utf8_bom
,
0
);
/* Test russian characters */
todo_wine
run_find_file_unicode
(
str_rus_utf8_bom
,
str_rus_utf8_bom
,
0
);
todo_wine
run_find_file_unicode
(
str_rus_utf8_nobom
,
str_rus_utf8_nobom
,
0
);
/* Test japanese characters */
todo_wine
run_find_file_unicode
(
str_jap_utf8_nobom
,
str_jap_utf8_nobom
,
0
);
todo_wine
run_find_file_unicode
(
str_jap_utf8_bom
,
str_jap_utf8_bom
,
0
);
todo_wine
run_find_file_unicode
(
str_jap_shiftjis
,
str_jap_shiftjis
,
0
);
/* Test unsupported encodings */
todo_wine
run_find_file_unicode
(
str_jap_utf16le_nobom
,
str_empty
,
1
);
todo_wine
run_find_file_unicode
(
str_jap_utf16be_bom
,
str_empty
,
1
);
todo_wine
run_find_file_unicode
(
str_jap_utf16be_nobom
,
str_empty
,
1
);
/* Test utf16le */
...
...
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