cmd: Fix 'IF EXIST DIRECTORY' test condition evaluation.

Signed-off-by: Eric Pouech <epouech@codeweavers.com>
This commit is contained in:
Eric Pouech 2024-11-11 16:30:17 +01:00 committed by Alexandre Julliard
parent f21744527e
commit d254d4ce12
Notes: Alexandre Julliard 2024-11-12 22:01:42 +01:00
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/wine/merge_requests/6803
2 changed files with 9 additions and 9 deletions

View file

@ -1088,9 +1088,9 @@ exist subdir with /. ok
exist subdir with / ok
exist subdir with / and quotes ok
exist empty string works
@todo_wine@ok
@todo_wine@ok
@todo_wine@ok
ok
ok
ok
------ for numbers
negative numbers handled
negative numbers handled

View file

@ -3196,14 +3196,14 @@ static BOOL if_condition_evaluate(CMD_IF_CONDITION *cond, int *test)
handleExpansion(expanded_left, TRUE);
if ((len = wcslen(expanded_left)))
{
/* FindFirstFile does not like a directory path ending in '\' or '/', so append a '.' */
if ((expanded_left[len - 1] == '\\' || expanded_left[len - 1] == '/') && len < MAXSTRING - 1)
if (!wcspbrk(expanded_left, L"*?"))
*test = GetFileAttributesW(expanded_left) != INVALID_FILE_ATTRIBUTES;
else
{
wcscat(expanded_left, L".");
hff = FindFirstFileW(expanded_left, &fd);
*test = (hff != INVALID_HANDLE_VALUE);
if (*test) FindClose(hff);
}
hff = FindFirstFileW(expanded_left, &fd);
*test = (hff != INVALID_HANDLE_VALUE);
if (*test) FindClose(hff);
}
}
break;