You've already forked wine-staging
mirror of
https://gitlab.winehq.org/wine/wine-staging.git
synced 2025-09-12 18:50:20 -07:00
Rename ntdll-CopyFileEx patchset to kernel32-CopyFileEx (Oops..).
This commit is contained in:
@@ -0,0 +1,103 @@
|
||||
From 27594f22cdf94cef9f3bca905e42f61566c1d489 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: kernel32: Add support for progress callback in CopyFileEx.
|
||||
|
||||
---
|
||||
dlls/kernel32/path.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++--
|
||||
1 file changed, 50 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/dlls/kernel32/path.c b/dlls/kernel32/path.c
|
||||
index 475b1f6..c91f741 100644
|
||||
--- a/dlls/kernel32/path.c
|
||||
+++ b/dlls/kernel32/path.c
|
||||
@@ -1092,6 +1092,9 @@ BOOL WINAPI CopyFileExW(LPCWSTR source, LPCWSTR dest,
|
||||
DWORD count;
|
||||
BOOL ret = FALSE;
|
||||
char *buffer;
|
||||
+ LARGE_INTEGER size;
|
||||
+ LARGE_INTEGER transferred;
|
||||
+ DWORD cbret;
|
||||
|
||||
if (!source || !dest)
|
||||
{
|
||||
@@ -1106,7 +1109,13 @@ BOOL WINAPI CopyFileExW(LPCWSTR source, LPCWSTR dest,
|
||||
|
||||
TRACE("%s -> %s, %x\n", debugstr_w(source), debugstr_w(dest), flags);
|
||||
|
||||
- if ((h1 = CreateFileW(source, GENERIC_READ,
|
||||
+ if (flags & COPY_FILE_RESTARTABLE)
|
||||
+ FIXME("COPY_FILE_RESTARTABLE is not supported\n");
|
||||
+ if (flags & COPY_FILE_COPY_SYMLINK)
|
||||
+ FIXME("COPY_FILE_COPY_SYMLINK is not supported\n");
|
||||
+
|
||||
+ if ((h1 = CreateFileW(source, (flags & COPY_FILE_OPEN_SOURCE_FOR_WRITE) ?
|
||||
+ GENERIC_WRITE | GENERIC_READ : GENERIC_READ,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
|
||||
NULL, OPEN_EXISTING, 0, 0)) == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
@@ -1142,7 +1151,7 @@ BOOL WINAPI CopyFileExW(LPCWSTR source, LPCWSTR dest,
|
||||
}
|
||||
}
|
||||
|
||||
- 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)
|
||||
{
|
||||
@@ -1152,6 +1161,27 @@ BOOL WINAPI CopyFileExW(LPCWSTR source, LPCWSTR dest,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
+ size.u.LowPart = info.nFileSizeLow;
|
||||
+ size.u.HighPart = info.nFileSizeHigh;
|
||||
+ transferred.QuadPart = 0;
|
||||
+
|
||||
+ if (progress)
|
||||
+ {
|
||||
+ cbret = progress( size, transferred, size, transferred, 1,
|
||||
+ CALLBACK_STREAM_SWITCH, h1, h2, param );
|
||||
+ if (cbret == PROGRESS_QUIET)
|
||||
+ progress = NULL;
|
||||
+ else if (cbret == PROGRESS_STOP)
|
||||
+ goto done;
|
||||
+ else if (cbret == PROGRESS_CANCEL)
|
||||
+ {
|
||||
+ FILE_DISPOSITION_INFO disp;
|
||||
+ disp.DoDeleteFile = TRUE;
|
||||
+ SetFileInformationByHandle( h2, FileDispositionInfo, &disp, sizeof(disp) );
|
||||
+ goto done;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
while (ReadFile( h1, buffer, buffer_size, &count, NULL ) && count)
|
||||
{
|
||||
char *p = buffer;
|
||||
@@ -1161,6 +1191,24 @@ BOOL WINAPI CopyFileExW(LPCWSTR source, LPCWSTR dest,
|
||||
if (!WriteFile( h2, p, count, &res, NULL ) || !res) goto done;
|
||||
p += res;
|
||||
count -= res;
|
||||
+
|
||||
+ if (progress)
|
||||
+ {
|
||||
+ transferred.QuadPart += res;
|
||||
+ cbret = progress( size, transferred, size, transferred, 1,
|
||||
+ CALLBACK_CHUNK_FINISHED, h1, h2, param );
|
||||
+ if (cbret == PROGRESS_QUIET)
|
||||
+ progress = NULL;
|
||||
+ else if (cbret == PROGRESS_STOP)
|
||||
+ goto done;
|
||||
+ else if (cbret == PROGRESS_CANCEL)
|
||||
+ {
|
||||
+ FILE_DISPOSITION_INFO disp;
|
||||
+ disp.DoDeleteFile = TRUE;
|
||||
+ SetFileInformationByHandle( h2, FileDispositionInfo, &disp, sizeof(disp) );
|
||||
+ goto done;
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
}
|
||||
ret = TRUE;
|
||||
--
|
||||
2.3.0
|
||||
|
4
patches/kernel32-CopyFileEx/definition
Normal file
4
patches/kernel32-CopyFileEx/definition
Normal file
@@ -0,0 +1,4 @@
|
||||
Fixes: [22692] Add support for CopyFileEx progress callback
|
||||
Fixes: [22690] Allow to cancel a file operation via progress callback
|
||||
Depends: ntdll-FileDispositionInformation
|
||||
Depends: kernel32-SetFileInformationByHandle
|
Reference in New Issue
Block a user