From 96d05d1559612a703f5ed8deef5145f8b0b0e8b4 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Tue, 27 Aug 2002 01:29:07 +0000 Subject: [PATCH] Fixed permission check when renaming a directory (based on a patch by Andriy Palamarchuk). --- files/file.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/files/file.c b/files/file.c index 214f3f68ba8..831a7c4e684 100644 --- a/files/file.c +++ b/files/file.c @@ -2627,8 +2627,16 @@ BOOL WINAPI MoveFileExW( LPCWSTR fn1, LPCWSTR fn2, DWORD flag ) hFile = FILE_CreateFile( full_name1.long_name, 0, 0, NULL, OPEN_EXISTING, 0, 0, TRUE, GetDriveTypeW( full_name1.short_name ) ); - if (!hFile) return FALSE; - CloseHandle(hFile); + if (!hFile) + { + DWORD attr; + + if (GetLastError() != ERROR_ACCESS_DENIED) return FALSE; + attr = GetFileAttributesA( full_name1.long_name ); + if (attr == (DWORD)-1 || !(attr & FILE_ATTRIBUTE_DIRECTORY)) return FALSE; + /* if it's a directory we can continue */ + } + else CloseHandle(hFile); /* check, if we are allowed to delete the destination, ** (but the file not being there is fine) */