mirror of
https://github.com/git/git.git
synced 2026-03-13 18:33:25 +01:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user