Module: wine Branch: stable Commit: b7958fb0a88d77e31c9d16e98cc7eebd245255b0 URL: https://source.winehq.org/git/wine.git/?a=commit;h=b7958fb0a88d77e31c9d16e98...
Author: Michael Müller michael@fds-team.de Date: Thu Feb 13 03:11:22 2020 +0000
setupapi: Implement SP_COPY_IN_USE_NEEDS_REBOOT.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=36059 Signed-off-by: Alistair Leslie-Hughes leslie_alistair@hotmail.com Signed-off-by: Alexandre Julliard julliard@winehq.org (cherry picked from commit 87b2af73baf3cc26fe5ed135cbd6ed494a9003be) Signed-off-by: Michael Stefaniuc mstefani@winehq.org
---
dlls/setupapi/queue.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/dlls/setupapi/queue.c b/dlls/setupapi/queue.c index 2d2c833474..0fbcac965b 100644 --- a/dlls/setupapi/queue.c +++ b/dlls/setupapi/queue.c @@ -1132,7 +1132,7 @@ static BOOL do_file_copyW( LPCWSTR source, LPCWSTR target, DWORD style, } } if (style & (SP_COPY_NODECOMP | SP_COPY_LANGUAGEAWARE | SP_COPY_FORCE_IN_USE | - SP_COPY_IN_USE_NEEDS_REBOOT | SP_COPY_NOSKIP | SP_COPY_WARNIFSKIP)) + SP_COPY_NOSKIP | SP_COPY_WARNIFSKIP)) { ERR("Unsupported style(s) 0x%x\n",style); } @@ -1140,6 +1140,22 @@ static BOOL do_file_copyW( LPCWSTR source, LPCWSTR target, DWORD style, if (docopy) { rc = CopyFileW(source,target,FALSE); + if (!rc && GetLastError() == ERROR_SHARING_VIOLATION && + (style & SP_COPY_IN_USE_NEEDS_REBOOT)) + { + WCHAR temp_file[MAX_PATH]; + WCHAR temp[MAX_PATH]; + + if (GetTempPathW(MAX_PATH, temp) && + GetTempFileNameW(temp, L"SET", 0, temp_file)) + { + rc = CopyFileW(source, temp_file, FALSE); + if (rc) + rc = MoveFileExW(temp_file, target, MOVEFILE_DELAY_UNTIL_REBOOT); + else + DeleteFileW(temp_file); + } + } if (!rc) WARN( "failed to copy, err %u\n", GetLastError() ); } else