From a23a15abc656e26e9f75c7943f7be9d64f6c801f Mon Sep 17 00:00:00 2001 From: Johannes Sixt Date: Mon, 12 Nov 2007 12:41:53 +0100 Subject: [PATCH] Use Windows's native API instead of stat() in rename()'s error path. Since we are only interested whether the named entry is a directory, it is sufficient to use GetFileAttributes() instead of a full stat() call. --- compat/mingw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compat/mingw.c b/compat/mingw.c index 152915fd21..412cdd6f5a 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -577,8 +577,8 @@ int mingw_rename(const char *pold, const char *pnew) return 0; /* TODO: translate more errors */ if (GetLastError() == ERROR_ACCESS_DENIED) { - struct stat st; - if (!stat(pnew, &st) && S_ISDIR(st.st_mode)) { + DWORD attrs = GetFileAttributes(pnew); + if (attrs != INVALID_FILE_ATTRIBUTES && (attrs & FILE_ATTRIBUTE_DIRECTORY)) { errno = EISDIR; return -1; }