cmd: Add support for wildcards in if exist.

Signed-off-by: Jason Edmeades <us@edmeades.me.uk>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
oldstable
Jason Edmeades 2018-06-24 21:44:10 +01:00 committed by Alexandre Julliard
parent 46c5eb173f
commit f53d57c854
3 changed files with 56 additions and 2 deletions

View File

@ -2804,8 +2804,11 @@ void WCMD_if (WCHAR *p, CMD_LIST **cmdList)
WCMD_parameter(p, 2+negate, &command, FALSE, FALSE);
}
else if (!lstrcmpiW (condition, existW)) {
test = (GetFileAttributesW(WCMD_parameter(p, 1+negate, NULL, FALSE, FALSE))
!= INVALID_FILE_ATTRIBUTES);
WIN32_FIND_DATAW fd;
HANDLE hff = FindFirstFileW(WCMD_parameter(p, 1+negate, NULL, FALSE, FALSE), &fd);
test = (hff != INVALID_HANDLE_VALUE );
if (!test) FindClose(hff);
WCMD_parameter(p, 2+negate, &command, FALSE, FALSE);
}
else if (!lstrcmpiW (condition, defdW)) {

View File

@ -979,6 +979,49 @@ for %%i in (%WINE_STR_PARMS%) do (
for %%i in (%WINE_STR_PARMS%) do (
for %%j in (%WINE_STR_PARMS%) do (
call :GTRtest %%i %%j))
echo ------------ Testing if/exist ------------
mkdir subdir
echo something>subdir\bar
echo something else>foo
if exist foo (
echo exist explicit works
) else (
echo ERROR exist explicit broken
)
if exist bar (
echo ERROR exist explicit unknown file broken
) else (
echo exist explicit unknown file works
)
if exist subdir\bar (
echo exist explicit in subdir works
) else (
echo ERROR exist explicit in subdir broken
)
if exist fo* (
echo exist simple wildcard works
) else (
echo ERROR exist simple wildcard broken
)
if exist subdir\ba* (
echo exist wildcard works
) else (
echo ERROR exist wildcard broken
)
if not exist subdir\ba* (
echo ERROR negate exist wildcard broken
) else (
echo negate exist wildcard works
)
if exist idontexist\ba* (
echo ERROR exist wildcard bad subdir broken
) else (
echo exist wildcard bad subdir broken works
)
del foo subdir\bar
rd subdir
echo ------ for numbers
if -1 LSS 1 (echo negative numbers handled)
if not -1 LSS -10 (echo negative numbers handled)

View File

@ -768,6 +768,14 @@ BA GTR B
BA GTR AB
BA GTR AA
AA GTR A
------------ Testing if/exist ------------
exist explicit works
exist explicit unknown file works
exist explicit in subdir works
exist simple wildcard works
exist wildcard works
negate exist wildcard works
exist wildcard bad subdir broken works
------ for numbers
negative numbers handled
negative numbers handled