From c79342a11ae2b251e4b2d198211450a7320dd342 Mon Sep 17 00:00:00 2001 From: Jason Edmeades Date: Mon, 14 Feb 2005 11:01:35 +0000 Subject: [PATCH] Make 'exist' in wcmd handle both file and directories. --- programs/wcmd/builtins.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/programs/wcmd/builtins.c b/programs/wcmd/builtins.c index 11570e974f8..90a55f4c639 100644 --- a/programs/wcmd/builtins.c +++ b/programs/wcmd/builtins.c @@ -384,7 +384,6 @@ char string[MAX_PATH]; void WCMD_if (char *p) { -HANDLE h; int negate = 0, test = 0; char condition[MAX_PATH], *command, *s; @@ -401,11 +400,8 @@ char condition[MAX_PATH], *command, *s; WCMD_parameter (p, 2+negate, &command); } else if (!lstrcmpi (condition, "exist")) { - if ((h = CreateFile (WCMD_parameter (p, 1+negate, NULL), GENERIC_READ, - FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, - OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) != INVALID_HANDLE_VALUE) { - CloseHandle (h); - test = 1; + if (GetFileAttributesA(WCMD_parameter (p, 1+negate, NULL)) != INVALID_FILE_ATTRIBUTES) { + test = 1; } WCMD_parameter (p, 2+negate, &command); }