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.
This commit is contained in:
Johannes Sixt
2007-11-12 12:41:53 +01:00
parent 50d1c4c745
commit a23a15abc6

View File

@@ -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;
}