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
90103fa0
Commit
90103fa0
authored
Feb 13, 2024
by
Alex Henrie
Committed by
Alexandre Julliard
Feb 16, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
where: Implement search with default options.
Wine-Bug:
https://bugs.winehq.org/show_bug.cgi?id=55282
parent
7c6a50cc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
93 additions
and
3 deletions
+93
-3
Makefile.in
programs/where/Makefile.in
+1
-0
main.c
programs/where/main.c
+92
-3
No files found.
programs/where/Makefile.in
View file @
90103fa0
MODULE
=
where.exe
IMPORTS
=
shlwapi
EXTRADLLFLAGS
=
-mconsole
-municode
...
...
programs/where/main.c
View file @
90103fa0
/*
* Copyright 2020 Louis Lenders
* Copyright 2024 Alex Henrie
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
...
...
@@ -16,18 +17,106 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <windows.h>
#include <fileapi.h>
#include <shlwapi.h>
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL
(
where
);
static
BOOL
found
;
static
void
search
(
const
WCHAR
*
search_path
,
const
WCHAR
*
pattern
)
{
static
const
WCHAR
*
extensions
[]
=
{
L""
,
L".bat"
,
L".cmd"
,
L".com"
,
L".exe"
};
WCHAR
glob
[
MAX_PATH
];
WCHAR
match_path
[
MAX_PATH
];
WIN32_FIND_DATAW
match
;
HANDLE
handle
;
int
i
;
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
extensions
);
i
++
)
{
if
(
wcslen
(
search_path
)
+
1
+
wcslen
(
pattern
)
+
wcslen
(
extensions
[
i
])
+
1
>
ARRAY_SIZE
(
glob
))
{
ERR
(
"Path too long
\n
"
);
return
;
}
/* Treat the extension as part of the pattern */
wcscpy
(
glob
,
search_path
);
wcscat
(
glob
,
L"
\\
"
);
wcscat
(
glob
,
pattern
);
wcscat
(
glob
,
extensions
[
i
]);
handle
=
FindFirstFileExW
(
glob
,
FindExInfoBasic
,
&
match
,
0
,
NULL
,
0
);
if
(
handle
!=
INVALID_HANDLE_VALUE
)
{
do
{
if
(
PathCombineW
(
match_path
,
search_path
,
match
.
cFileName
))
{
printf
(
"%ls
\n
"
,
match_path
);
found
=
TRUE
;
}
}
while
(
FindNextFileW
(
handle
,
&
match
));
FindClose
(
handle
);
}
}
}
int
__cdecl
wmain
(
int
argc
,
WCHAR
*
argv
[])
{
WCHAR
*
pattern
,
*
colon
,
*
search_paths
,
*
search_path
,
*
next_search_path
;
int
i
;
WINE_FIXME
(
"stub:"
);
for
(
i
=
0
;
i
<
argc
;
i
++
)
WINE_FIXME
(
" %s"
,
wine_dbgstr_w
(
argv
[
i
]));
WINE_FIXME
(
"
\n
"
);
{
if
(
argv
[
i
][
0
]
==
'/'
)
{
FIXME
(
"Unsupported option %ls
\n
"
,
argv
[
i
]);
return
1
;
}
}
for
(
i
=
1
;
i
<
argc
;
i
++
)
{
pattern
=
argv
[
i
];
colon
=
wcsrchr
(
pattern
,
':'
);
/* Check for a set of search paths prepended to the pattern */
if
(
colon
)
{
*
colon
=
0
;
search_paths
=
pattern
;
pattern
=
colon
+
1
;
}
else
{
search_paths
=
_wgetenv
(
L"PATH"
);
}
if
(
wcspbrk
(
pattern
,
L"
\\
/
\r\n
"
))
continue
;
/* Silently ignore invalid patterns */
if
(
!
colon
)
{
/* If the search paths were not explicitly specified, search the current directory first */
WCHAR
current_dir
[
MAX_PATH
];
if
(
GetCurrentDirectoryW
(
ARRAY_SIZE
(
current_dir
),
current_dir
))
search
(
current_dir
,
pattern
);
}
next_search_path
=
wcsdup
(
search_paths
);
while
((
search_path
=
wcstok
(
NULL
,
L";"
,
&
next_search_path
)))
search
(
search_path
,
pattern
);
}
if
(
!
found
)
{
fputs
(
"File not found
\n
"
,
stderr
);
return
1
;
}
return
0
;
}
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