You've already forked wine-staging
mirror of
https://gitlab.winehq.org/wine/wine-staging.git
synced 2025-04-13 14:42:51 -07:00
Rebase against 2828d0820a1661e46f606f28db090d710cef11f4.
This commit is contained in:
@ -1,18 +1,18 @@
|
||||
From 34b3bcb23bf0a4b81b1cddca90f8a248f478fee5 Mon Sep 17 00:00:00 2001
|
||||
From b2a5efcef525f887c7fe40ce3ed0a8a47c42d5fc Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
|
||||
Date: Thu, 26 Feb 2015 06:41:26 +0100
|
||||
Subject: [PATCH] kernelbase: Add support for progress callback in CopyFileEx.
|
||||
|
||||
---
|
||||
dlls/kernel32/tests/file.c | 6 ----
|
||||
dlls/kernelbase/file.c | 65 ++++++++++++++++++++++++++++++++++++--
|
||||
2 files changed, 63 insertions(+), 8 deletions(-)
|
||||
dlls/kernel32/tests/file.c | 6 ---
|
||||
dlls/kernelbase/file.c | 77 +++++++++++++++++++++++++++++++++++---
|
||||
2 files changed, 71 insertions(+), 12 deletions(-)
|
||||
|
||||
diff --git a/dlls/kernel32/tests/file.c b/dlls/kernel32/tests/file.c
|
||||
index 2e26e2ace86..1cccb105448 100644
|
||||
index 6ea9dffde5c..b12d0477e04 100644
|
||||
--- a/dlls/kernel32/tests/file.c
|
||||
+++ b/dlls/kernel32/tests/file.c
|
||||
@@ -1173,23 +1173,17 @@ static void test_CopyFileEx(void)
|
||||
@@ -1169,23 +1169,17 @@ static void test_CopyFileEx(void)
|
||||
ok(hfile != INVALID_HANDLE_VALUE, "failed to open destination file, error %d\n", GetLastError());
|
||||
SetLastError(0xdeadbeef);
|
||||
retok = CopyFileExA(source, dest, copy_progress_cb, hfile, NULL, 0);
|
||||
@ -37,10 +37,17 @@ index 2e26e2ace86..1cccb105448 100644
|
||||
|
||||
retok = CopyFileExA(source, NULL, copy_progress_cb, hfile, NULL, 0);
|
||||
diff --git a/dlls/kernelbase/file.c b/dlls/kernelbase/file.c
|
||||
index 3b00321eb1a..ab95c8babf1 100644
|
||||
index 23a36b0a765..98cf7e58368 100644
|
||||
--- a/dlls/kernelbase/file.c
|
||||
+++ b/dlls/kernelbase/file.c
|
||||
@@ -503,6 +503,10 @@ BOOL WINAPI CopyFileExW( const WCHAR *source, const WCHAR *dest, LPPROGRESS_ROUT
|
||||
@@ -499,11 +499,16 @@ BOOL WINAPI CopyFileExW( const WCHAR *source, const WCHAR *dest, LPPROGRESS_ROUT
|
||||
{
|
||||
static const int buffer_size = 65536;
|
||||
HANDLE h1, h2;
|
||||
- FILE_BASIC_INFORMATION info;
|
||||
+ FILE_NETWORK_OPEN_INFORMATION info;
|
||||
+ FILE_BASIC_INFORMATION basic_info;
|
||||
IO_STATUS_BLOCK io;
|
||||
DWORD count;
|
||||
BOOL ret = FALSE;
|
||||
char *buffer;
|
||||
@ -51,7 +58,7 @@ index 3b00321eb1a..ab95c8babf1 100644
|
||||
|
||||
if (!source || !dest)
|
||||
{
|
||||
@@ -517,7 +521,15 @@ BOOL WINAPI CopyFileExW( const WCHAR *source, const WCHAR *dest, LPPROGRESS_ROUT
|
||||
@@ -518,7 +523,15 @@ BOOL WINAPI CopyFileExW( const WCHAR *source, const WCHAR *dest, LPPROGRESS_ROUT
|
||||
|
||||
TRACE("%s -> %s, %x\n", debugstr_w(source), debugstr_w(dest), flags);
|
||||
|
||||
@ -68,25 +75,33 @@ index 3b00321eb1a..ab95c8babf1 100644
|
||||
NULL, OPEN_EXISTING, 0, 0 )) == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
WARN("Unable to open source %s\n", debugstr_w(source));
|
||||
@@ -551,7 +563,11 @@ BOOL WINAPI CopyFileExW( const WCHAR *source, const WCHAR *dest, LPPROGRESS_ROUT
|
||||
@@ -526,7 +539,7 @@ BOOL WINAPI CopyFileExW( const WCHAR *source, const WCHAR *dest, LPPROGRESS_ROUT
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
- if (!set_ntstatus( NtQueryInformationFile( h1, &io, &info, sizeof(info), FileBasicInformation )))
|
||||
+ if (!set_ntstatus( NtQueryInformationFile( h1, &io, &info, sizeof(info), FileNetworkOpenInformation )))
|
||||
{
|
||||
WARN("GetFileInformationByHandle returned error for %s\n", debugstr_w(source));
|
||||
HeapFree( GetProcessHeap(), 0, buffer );
|
||||
@@ -552,7 +565,11 @@ BOOL WINAPI CopyFileExW( const WCHAR *source, const WCHAR *dest, LPPROGRESS_ROUT
|
||||
}
|
||||
}
|
||||
|
||||
- if ((h2 = CreateFileW( dest, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
|
||||
+ if ((h2 = CreateFileW( dest, GENERIC_WRITE | DELETE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
|
||||
+ (flags & COPY_FILE_FAIL_IF_EXISTS) ? CREATE_NEW : CREATE_ALWAYS,
|
||||
+ info.dwFileAttributes, h1 )) == INVALID_HANDLE_VALUE &&
|
||||
+ info.FileAttributes, h1 )) == INVALID_HANDLE_VALUE &&
|
||||
+ /* retry without DELETE if we got a sharing violation */
|
||||
+ (h2 = CreateFileW( dest, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
|
||||
(flags & COPY_FILE_FAIL_IF_EXISTS) ? CREATE_NEW : CREATE_ALWAYS,
|
||||
info.dwFileAttributes, h1 )) == INVALID_HANDLE_VALUE)
|
||||
info.FileAttributes, h1 )) == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
@@ -561,6 +577,30 @@ BOOL WINAPI CopyFileExW( const WCHAR *source, const WCHAR *dest, LPPROGRESS_ROUT
|
||||
@@ -562,6 +579,29 @@ BOOL WINAPI CopyFileExW( const WCHAR *source, const WCHAR *dest, LPPROGRESS_ROUT
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
+ size.u.LowPart = info.nFileSizeLow;
|
||||
+ size.u.HighPart = info.nFileSizeHigh;
|
||||
+ size = info.EndOfFile;
|
||||
+ transferred.QuadPart = 0;
|
||||
+
|
||||
+ if (progress)
|
||||
@ -112,7 +127,7 @@ index 3b00321eb1a..ab95c8babf1 100644
|
||||
while (ReadFile( h1, buffer, buffer_size, &count, NULL ) && count)
|
||||
{
|
||||
char *p = buffer;
|
||||
@@ -570,6 +610,27 @@ BOOL WINAPI CopyFileExW( const WCHAR *source, const WCHAR *dest, LPPROGRESS_ROUT
|
||||
@@ -571,13 +611,38 @@ BOOL WINAPI CopyFileExW( const WCHAR *source, const WCHAR *dest, LPPROGRESS_ROUT
|
||||
if (!WriteFile( h2, p, count, &res, NULL ) || !res) goto done;
|
||||
p += res;
|
||||
count -= res;
|
||||
@ -140,6 +155,19 @@ index 3b00321eb1a..ab95c8babf1 100644
|
||||
}
|
||||
}
|
||||
ret = TRUE;
|
||||
done:
|
||||
/* Maintain the timestamp of source file to destination file */
|
||||
- info.FileAttributes = 0;
|
||||
- NtSetInformationFile( h2, &io, &info, sizeof(info), FileBasicInformation );
|
||||
+ basic_info.CreationTime = info.CreationTime;
|
||||
+ basic_info.LastAccessTime = info.LastAccessTime;
|
||||
+ basic_info.LastWriteTime = info.LastWriteTime;
|
||||
+ basic_info.ChangeTime = info.ChangeTime;
|
||||
+ basic_info.FileAttributes = 0;
|
||||
+ NtSetInformationFile( h2, &io, &basic_info, sizeof(basic_info), FileBasicInformation );
|
||||
HeapFree( GetProcessHeap(), 0, buffer );
|
||||
CloseHandle( h1 );
|
||||
CloseHandle( h2 );
|
||||
--
|
||||
2.26.2
|
||||
2.30.2
|
||||
|
||||
|
Reference in New Issue
Block a user