Commit 6d59ddf6 authored by Jens Nestler's avatar Jens Nestler Committed by Alexandre Julliard

kernel32: Don't fail unconditionally in MoveFile for directories with flag…

kernel32: Don't fail unconditionally in MoveFile for directories with flag MOVEFILE_REPLACE_EXISTING.
parent 43083236
......@@ -1042,15 +1042,6 @@ BOOL WINAPI MoveFileWithProgressW( LPCWSTR source, LPCWSTR dest,
goto error;
}
if (info.FileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
if (flag & MOVEFILE_REPLACE_EXISTING) /* cannot replace directory */
{
SetLastError( ERROR_INVALID_PARAMETER );
goto error;
}
}
/* we must have write access to the destination, and it must */
/* not exist except if MOVEFILE_REPLACE_EXISTING is set */
......@@ -1061,7 +1052,7 @@ BOOL WINAPI MoveFileWithProgressW( LPCWSTR source, LPCWSTR dest,
}
status = NtOpenFile( &dest_handle, GENERIC_READ | GENERIC_WRITE, &attr, &io, 0,
FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT );
if (status == STATUS_SUCCESS)
if (status == STATUS_SUCCESS) /* destination exists */
{
NtClose( dest_handle );
if (!(flag & MOVEFILE_REPLACE_EXISTING))
......@@ -1070,6 +1061,11 @@ BOOL WINAPI MoveFileWithProgressW( LPCWSTR source, LPCWSTR dest,
RtlFreeUnicodeString( &nt_name );
goto error;
}
else if (info.FileAttributes & FILE_ATTRIBUTE_DIRECTORY) /* cannot replace directory */
{
SetLastError( ERROR_ACCESS_DENIED );
goto error;
}
}
else if (status != STATUS_OBJECT_NAME_NOT_FOUND)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment