Added patch for CopyFileEx progress callback and cancellation support.

This commit is contained in:
Sebastian Lackner 2015-02-26 07:10:29 +01:00
parent 7d2b751466
commit b74ea4b14d
5 changed files with 177 additions and 36 deletions

View File

@ -38,8 +38,10 @@ Wine. All those differences are also documented on the
Included bug fixes and improvements
===================================
**Bugfixes and features included in the next upcoming release [3]:**
**Bugfixes and features included in the next upcoming release [5]:**
* Add support for CopyFileEx progress callback ([Wine Bug #22692](https://bugs.winehq.org/show_bug.cgi?id=22692))
* Allow to cancel a file operation via progress callback ([Wine Bug #22690](https://bugs.winehq.org/show_bug.cgi?id=22690))
* Fallback to global key state for threads without a queue ([Wine Bug #27238](https://bugs.winehq.org/show_bug.cgi?id=27238))
* Fix race-condition when threads are killed during shutdown
* Implement SetFileInformationByHandle

1
debian/changelog vendored
View File

@ -9,6 +9,7 @@ wine-staging (1.7.38) UNRELEASED; urgency=low
* Added patch to avoid deadlock by using _exit() in NtTerminateProcess.
* Added patch to fallback to global key state for threads without a queue.
* Added patch to implement SetFileInformationByHandle.
* Added patch for CopyFileEx progress callback and cancellation support.
* Removed patch to properly call DriverUnload when unloading device drivers (accepted upstream).
* Removed patch to allow Accept-Encoding for HTTP/1.0 in wininet (accepted upstream).
* Removed patch to declare pDirectInputCreateEx in a MSVC compatible way (accepted upstream).

View File

@ -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

View 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: ntdll-SetFileInformationByHandle

View File

@ -115,6 +115,7 @@ patch_enable_all ()
enable_msvcrt_atof_strtod="$1"
enable_msvfw32_Image_Size="$1"
enable_netprofm_IConnectionPoint="$1"
enable_ntdll_CopyFileEx="$1"
enable_ntdll_DOS_Attributes="$1"
enable_ntdll_DVD_Read_Size="$1"
enable_ntdll_DllRedirects="$1"
@ -379,6 +380,9 @@ patch_enable ()
netprofm-IConnectionPoint)
enable_netprofm_IConnectionPoint="$2"
;;
ntdll-CopyFileEx)
enable_ntdll_CopyFileEx="$2"
;;
ntdll-DOS_Attributes)
enable_ntdll_DOS_Attributes="$2"
;;
@ -960,6 +964,17 @@ if test "$enable_ntdll_Junction_Points" -eq 1; then
enable_ntdll_Fix_Free=1
fi
if test "$enable_ntdll_CopyFileEx" -eq 1; then
if test "$enable_ntdll_FileDispositionInformation" -gt 1; then
abort "Patchset ntdll-FileDispositionInformation disabled, but ntdll-CopyFileEx depends on that."
fi
if test "$enable_ntdll_SetFileInformationByHandle" -gt 1; then
abort "Patchset ntdll-SetFileInformationByHandle disabled, but ntdll-CopyFileEx depends on that."
fi
enable_ntdll_FileDispositionInformation=1
enable_ntdll_SetFileInformationByHandle=1
fi
if test "$enable_dxva2_Video_Decoder" -eq 1; then
if test "$enable_winecfg_Staging" -gt 1; then
abort "Patchset winecfg-Staging disabled, but dxva2-Video_Decoder depends on that."
@ -2470,6 +2485,57 @@ if test "$enable_netprofm_IConnectionPoint" -eq 1; then
) >> "$patchlist"
fi
# Patchset ntdll-FileDispositionInformation
# |
# | This patchset fixes the following Wine bugs:
# | * [#30397] Support for NtSetInformationFile class FileDispositionInformation
# |
# | Modified files:
# | * dlls/ntdll/file.c, dlls/ntdll/tests/file.c, server/fd.c, server/file.c, server/file.h, server/protocol.def
# |
if test "$enable_ntdll_FileDispositionInformation" -eq 1; then
patch_apply ntdll-FileDispositionInformation/0001-server-Keep-a-pointer-to-parent-s-fd-unix_name-in-th.patch
patch_apply ntdll-FileDispositionInformation/0002-server-Add-support-for-setting-file-disposition-info.patch
patch_apply ntdll-FileDispositionInformation/0003-server-Do-not-permit-FileDispositionInformation-to-d.patch
(
echo '+ { "Dmitry Timoshkov", "server: Keep a pointer to parent'\''s fd unix_name in the closed_fd structure.", 1 },';
echo '+ { "Dmitry Timoshkov", "server: Add support for setting file disposition information.", 1 },';
echo '+ { "Erich E. Hoover", "server: Do not permit FileDispositionInformation to delete a file without write access.", 1 },';
) >> "$patchlist"
fi
# Patchset ntdll-SetFileInformationByHandle
# |
# | Modified files:
# | * dlls/kernel32/file.c, dlls/ntdll/file.c, include/winbase.h, include/winternl.h
# |
if test "$enable_ntdll_SetFileInformationByHandle" -eq 1; then
patch_apply ntdll-SetFileInformationByHandle/0001-ntdll-Define-a-couple-more-information-classes.patch
patch_apply ntdll-SetFileInformationByHandle/0002-include-Declare-a-couple-more-file-information-class.patch
patch_apply ntdll-SetFileInformationByHandle/0003-ntdll-Implement-SetFileInformationByHandle.patch
(
echo '+ { "Michael Müller", "ntdll: Define a couple more information classes.", 1 },';
echo '+ { "Michael Müller", "include: Declare a couple more file information class structures.", 1 },';
echo '+ { "Michael Müller", "ntdll: Implement SetFileInformationByHandle.", 1 },';
) >> "$patchlist"
fi
# Patchset ntdll-CopyFileEx
# |
# | This patchset fixes the following Wine bugs:
# | * [#22692] Add support for CopyFileEx progress callback
# | * [#22690] Allow to cancel a file operation via progress callback
# |
# | Modified files:
# | * dlls/kernel32/path.c
# |
if test "$enable_ntdll_CopyFileEx" -eq 1; then
patch_apply ntdll-CopyFileEx/0001-kernel32-Add-support-for-progress-callback-in-CopyFi.patch
(
echo '+ { "Michael Müller", "kernel32: Add support for progress callback in CopyFileEx.", 1 },';
) >> "$patchlist"
fi
# Patchset ntdll-DOS_Attributes
# |
# | This patchset fixes the following Wine bugs:
@ -2556,25 +2622,6 @@ if test "$enable_ntdll_FD_Cache" -eq 1; then
) >> "$patchlist"
fi
# Patchset ntdll-FileDispositionInformation
# |
# | This patchset fixes the following Wine bugs:
# | * [#30397] Support for NtSetInformationFile class FileDispositionInformation
# |
# | Modified files:
# | * dlls/ntdll/file.c, dlls/ntdll/tests/file.c, server/fd.c, server/file.c, server/file.h, server/protocol.def
# |
if test "$enable_ntdll_FileDispositionInformation" -eq 1; then
patch_apply ntdll-FileDispositionInformation/0001-server-Keep-a-pointer-to-parent-s-fd-unix_name-in-th.patch
patch_apply ntdll-FileDispositionInformation/0002-server-Add-support-for-setting-file-disposition-info.patch
patch_apply ntdll-FileDispositionInformation/0003-server-Do-not-permit-FileDispositionInformation-to-d.patch
(
echo '+ { "Dmitry Timoshkov", "server: Keep a pointer to parent'\''s fd unix_name in the closed_fd structure.", 1 },';
echo '+ { "Dmitry Timoshkov", "server: Add support for setting file disposition information.", 1 },';
echo '+ { "Erich E. Hoover", "server: Do not permit FileDispositionInformation to delete a file without write access.", 1 },';
) >> "$patchlist"
fi
# Patchset ntdll-Fix_Alignment
# |
# | This patchset fixes the following Wine bugs:
@ -2740,22 +2787,6 @@ if test "$enable_ntdll_RtlUnwindEx" -eq 1; then
) >> "$patchlist"
fi
# Patchset ntdll-SetFileInformationByHandle
# |
# | Modified files:
# | * dlls/kernel32/file.c, dlls/ntdll/file.c, include/winbase.h, include/winternl.h
# |
if test "$enable_ntdll_SetFileInformationByHandle" -eq 1; then
patch_apply ntdll-SetFileInformationByHandle/0001-ntdll-Define-a-couple-more-information-classes.patch
patch_apply ntdll-SetFileInformationByHandle/0002-include-Declare-a-couple-more-file-information-class.patch
patch_apply ntdll-SetFileInformationByHandle/0003-ntdll-Implement-SetFileInformationByHandle.patch
(
echo '+ { "Michael Müller", "ntdll: Define a couple more information classes.", 1 },';
echo '+ { "Michael Müller", "include: Declare a couple more file information class structures.", 1 },';
echo '+ { "Michael Müller", "ntdll: Implement SetFileInformationByHandle.", 1 },';
) >> "$patchlist"
fi
# Patchset ntdll-ThreadTime
# |
# | This patchset fixes the following Wine bugs: