kernelbase: Copy the read-only attribute from the source.
Signed-off-by: Gabriel Ivăncescu <gabrielopcode@gmail.com>
This commit is contained in:
parent
267a5658fb
commit
e8f4909ac3
2 changed files with 52 additions and 2 deletions
|
@ -850,6 +850,56 @@ static void test_CopyFileA(void)
|
|||
CloseHandle(hmapfile);
|
||||
CloseHandle(hfile);
|
||||
|
||||
/* check read-only attribute */
|
||||
ret = GetFileAttributesA(source);
|
||||
ok(ret != INVALID_FILE_ATTRIBUTES, "GetFileAttributesA: error %ld\n", GetLastError());
|
||||
ok(!(ret & FILE_ATTRIBUTE_READONLY), "source is read-only\n");
|
||||
ret = GetFileAttributesA(dest);
|
||||
ok(ret != INVALID_FILE_ATTRIBUTES, "GetFileAttributesA: error %ld\n", GetLastError());
|
||||
ok(!(ret & FILE_ATTRIBUTE_READONLY), "dest is read-only\n");
|
||||
|
||||
/* make source read-only */
|
||||
ret = SetFileAttributesA(source, FILE_ATTRIBUTE_READONLY);
|
||||
ok(ret, "SetFileAttributesA: error %ld\n", GetLastError());
|
||||
ret = GetFileAttributesA(source);
|
||||
ok(ret != INVALID_FILE_ATTRIBUTES, "GetFileAttributesA: error %ld\n", GetLastError());
|
||||
ok(ret & FILE_ATTRIBUTE_READONLY, "source is not read-only\n");
|
||||
ret = GetFileAttributesA(dest);
|
||||
ok(ret != INVALID_FILE_ATTRIBUTES, "GetFileAttributesA: error %ld\n", GetLastError());
|
||||
ok(!(ret & FILE_ATTRIBUTE_READONLY), "dest is read-only\n");
|
||||
|
||||
/* dest becomes read-only after copied from read-only source */
|
||||
ret = SetFileAttributesA(source, FILE_ATTRIBUTE_READONLY);
|
||||
ok(ret, "SetFileAttributesA: error %ld\n", GetLastError());
|
||||
ret = GetFileAttributesA(source);
|
||||
ok(ret != INVALID_FILE_ATTRIBUTES, "GetFileAttributesA: error %ld\n", GetLastError());
|
||||
ok(ret & FILE_ATTRIBUTE_READONLY, "source is not read-only\n");
|
||||
ret = GetFileAttributesA(dest);
|
||||
ok(ret != INVALID_FILE_ATTRIBUTES, "GetFileAttributesA: error %ld\n", GetLastError());
|
||||
ok(!(ret & FILE_ATTRIBUTE_READONLY), "dest is read-only\n");
|
||||
|
||||
ret = CopyFileA(source, dest, FALSE);
|
||||
ok(ret, "CopyFileA: error %ld\n", GetLastError());
|
||||
ret = GetFileAttributesA(dest);
|
||||
ok(ret != INVALID_FILE_ATTRIBUTES, "GetFileAttributesA: error %ld\n", GetLastError());
|
||||
ok(ret & FILE_ATTRIBUTE_READONLY, "dest is not read-only\n");
|
||||
|
||||
/* same when dest does not exist */
|
||||
ret = SetFileAttributesA(dest, FILE_ATTRIBUTE_NORMAL);
|
||||
ok(ret, "SetFileAttributesA: error %ld\n", GetLastError());
|
||||
ret = DeleteFileA(dest);
|
||||
ok(ret, "DeleteFileA: error %ld\n", GetLastError());
|
||||
ret = CopyFileA(source, dest, TRUE);
|
||||
ok(ret, "CopyFileA: error %ld\n", GetLastError());
|
||||
ret = GetFileAttributesA(dest);
|
||||
ok(ret != INVALID_FILE_ATTRIBUTES, "GetFileAttributesA: error %ld\n", GetLastError());
|
||||
ok(ret & FILE_ATTRIBUTE_READONLY, "dest is not read-only\n");
|
||||
|
||||
ret = SetFileAttributesA(source, FILE_ATTRIBUTE_NORMAL);
|
||||
ok(ret, "SetFileAttributesA: error %ld\n", GetLastError());
|
||||
ret = SetFileAttributesA(dest, FILE_ATTRIBUTE_NORMAL);
|
||||
ok(ret, "SetFileAttributesA: error %ld\n", GetLastError());
|
||||
|
||||
ret = DeleteFileA(source);
|
||||
ok(ret, "DeleteFileA: error %ld\n", GetLastError());
|
||||
ret = DeleteFileA(dest);
|
||||
|
|
|
@ -579,8 +579,8 @@ BOOL WINAPI CopyFileExW( const WCHAR *source, const WCHAR *dest, LPPROGRESS_ROUT
|
|||
}
|
||||
ret = TRUE;
|
||||
done:
|
||||
/* Maintain the timestamp of source file to destination file */
|
||||
info.FileAttributes = 0;
|
||||
/* Maintain the timestamp of source file to destination file and read-only attribute */
|
||||
info.FileAttributes &= FILE_ATTRIBUTE_READONLY;
|
||||
NtSetInformationFile( h2, &io, &info, sizeof(info), FileBasicInformation );
|
||||
HeapFree( GetProcessHeap(), 0, buffer );
|
||||
CloseHandle( h1 );
|
||||
|
|
Loading…
Add table
Reference in a new issue