kernel32: Make CopyFile(Ex)() succeed even if the source file is delete-locked.
This commit is contained in:
parent
e21c805fbe
commit
5a3ff7ccc1
|
@ -957,7 +957,8 @@ BOOL WINAPI CopyFileExW(LPCWSTR source, LPCWSTR dest,
|
||||||
|
|
||||||
TRACE("%s -> %s, %x\n", debugstr_w(source), debugstr_w(dest), flags);
|
TRACE("%s -> %s, %x\n", debugstr_w(source), debugstr_w(dest), flags);
|
||||||
|
|
||||||
if ((h1 = CreateFileW(source, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE,
|
if ((h1 = CreateFileW(source, GENERIC_READ,
|
||||||
|
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
|
||||||
NULL, OPEN_EXISTING, 0, 0)) == INVALID_HANDLE_VALUE)
|
NULL, OPEN_EXISTING, 0, 0)) == INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
WARN("Unable to open source %s\n", debugstr_w(source));
|
WARN("Unable to open source %s\n", debugstr_w(source));
|
||||||
|
|
|
@ -652,11 +652,11 @@ static void test_CopyFileA(void)
|
||||||
"copying from an r+w opened and r shared file failed (ret=%d, err=%d)\n", retok, GetLastError());
|
"copying from an r+w opened and r shared file failed (ret=%d, err=%d)\n", retok, GetLastError());
|
||||||
CloseHandle(hfile);
|
CloseHandle(hfile);
|
||||||
|
|
||||||
/* copying from a delete-locked source is unreliable */
|
/* copying from a delete-locked source mostly succeeds */
|
||||||
hfile = CreateFileA(source, DELETE, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0);
|
hfile = CreateFileA(source, DELETE, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0);
|
||||||
ok(hfile != INVALID_HANDLE_VALUE, "failed to open source file, error %d\n", GetLastError());
|
ok(hfile != INVALID_HANDLE_VALUE, "failed to open source file, error %d\n", GetLastError());
|
||||||
retok = CopyFileA(source, dest, FALSE);
|
retok = CopyFileA(source, dest, FALSE);
|
||||||
ok((!retok && GetLastError() == ERROR_SHARING_VIOLATION) || broken(retok) /* 98, Vista, 2k8, 7 */,
|
ok(retok || broken(!retok && GetLastError() == ERROR_SHARING_VIOLATION) /* NT, 2000, XP */,
|
||||||
"copying from a delete-locked file failed (ret=%d, err=%d)\n", retok, GetLastError());
|
"copying from a delete-locked file failed (ret=%d, err=%d)\n", retok, GetLastError());
|
||||||
CloseHandle(hfile);
|
CloseHandle(hfile);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue