Commit 33c6a6cb authored by Roman Pišl's avatar Roman Pišl Committed by Alexandre Julliard

kernelbase: Convert DOS to NT path for FileRenameInfo in SetFileInformationByHandle.

parent 0f84d307
......@@ -5322,24 +5322,20 @@ static void test_SetFileRenameInfo(void)
fri->FileNameLength = wcslen(tempFileTo1) * sizeof(WCHAR);
memcpy(fri->FileName, tempFileTo1, fri->FileNameLength + sizeof(WCHAR));
ret = pSetFileInformationByHandle(file, FileRenameInfo, fri, size);
todo_wine
ok(!ret && GetLastError() == ERROR_ALREADY_EXISTS, "FileRenameInfo unexpected result %d\n", GetLastError());
fri->ReplaceIfExists = TRUE;
ret = pSetFileInformationByHandle(file, FileRenameInfo, fri, size);
todo_wine
ok(ret, "FileRenameInfo failed, error %d\n", GetLastError());
fri->ReplaceIfExists = FALSE;
fri->FileNameLength = wcslen(tempFileTo2) * sizeof(WCHAR);
memcpy(fri->FileName, tempFileTo2, fri->FileNameLength + sizeof(WCHAR));
ret = pSetFileInformationByHandle(file, FileRenameInfo, fri, size);
todo_wine
ok(ret, "FileRenameInfo failed, error %d\n", GetLastError());
CloseHandle(file);
file = CreateFileW(tempFileTo2, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0);
todo_wine
ok(file != INVALID_HANDLE_VALUE, "file not renamed, error %d\n", GetLastError());
fri->FileNameLength = wcslen(tempFileTo1) * sizeof(WCHAR);
......
......@@ -3556,8 +3556,27 @@ BOOL WINAPI DECLSPEC_HOTPATCH SetFileInformationByHandle( HANDLE file, FILE_INFO
status = NtSetInformationFile( file, &io, info, size, FileIoPriorityHintInformation );
break;
case FileRenameInfo:
status = NtSetInformationFile( file, &io, info, size, FileRenameInformation );
break;
{
FILE_RENAME_INFORMATION *rename_info;
UNICODE_STRING nt_name;
ULONG size;
if ((status = RtlDosPathNameToNtPathName_U_WithStatus( ((FILE_RENAME_INFORMATION *)info)->FileName,
&nt_name, NULL, NULL )))
break;
size = sizeof(*rename_info) + nt_name.Length;
if ((rename_info = HeapAlloc( GetProcessHeap(), 0, size )))
{
memcpy( rename_info, info, sizeof(*rename_info) );
memcpy( rename_info->FileName, nt_name.Buffer, nt_name.Length + sizeof(WCHAR) );
rename_info->FileNameLength = nt_name.Length;
status = NtSetInformationFile( file, &io, rename_info, size, FileRenameInformation );
HeapFree( GetProcessHeap(), 0, rename_info );
}
RtlFreeUnicodeString( &nt_name );
break;
}
case FileStandardInfo:
case FileCompressionInfo:
case FileAttributeTagInfo:
......
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