From 1c0bdb07e1c7bfb919d9dc3c9fda3f4336e5a15f Mon Sep 17 00:00:00 2001 From: Jeffrey Morlan Date: Mon, 13 Jul 2009 18:55:33 +0000 Subject: [PATCH] Make IF EXIST directory\ (with trailing backslash) work svn path=/trunk/; revision=41942 --- reactos/base/shell/cmd/if.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/reactos/base/shell/cmd/if.c b/reactos/base/shell/cmd/if.c index 2f2ae79e7e8..ee74c046632 100644 --- a/reactos/base/shell/cmd/if.c +++ b/reactos/base/shell/cmd/if.c @@ -115,16 +115,21 @@ INT ExecuteIf(PARSED_COMMAND *Cmd) else if (Cmd->If.Operator == IF_EXIST) { /* IF EXIST filename: check if file exists (wildcards allowed) */ - WIN32_FIND_DATA f; - HANDLE hFind; - StripQuotes(Right); - hFind = FindFirstFile(Right, &f); - if (hFind != INVALID_HANDLE_VALUE) + if (_tcschr(Right, _T('*')) || _tcschr(Right, _T('?'))) { - result = TRUE; - FindClose(hFind); + WIN32_FIND_DATA f; + HANDLE hFind = FindFirstFile(Right, &f); + if (hFind != INVALID_HANDLE_VALUE) + { + result = TRUE; + FindClose(hFind); + } + } + else + { + result = (GetFileAttributes(Right) != INVALID_FILE_ATTRIBUTES); } } else