Commit 5a3ff7cc authored by Charles Davis's avatar Charles Davis Committed by Alexandre Julliard

kernel32: Make CopyFile(Ex)() succeed even if the source file is delete-locked.

parent e21c805f
...@@ -957,7 +957,8 @@ BOOL WINAPI CopyFileExW(LPCWSTR source, LPCWSTR dest, ...@@ -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) ...@@ -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);
......
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