Zebediah Figura : setupapi: Separate the entire copy operation into a helper function.

Alexandre Julliard julliard at winehq.org
Thu May 2 16:45:09 CDT 2019


Module: wine
Branch: master
Commit: 3cb621e6ca78064adeb2415bf3467e476e9eba6a
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=3cb621e6ca78064adeb2415bf3467e476e9eba6a

Author: Zebediah Figura <z.figura12 at gmail.com>
Date:   Wed May  1 18:24:07 2019 -0500

setupapi: Separate the entire copy operation into a helper function.

So as to centralize SPFILENOTIFY_COPYERROR callbacks into one place.

Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/setupapi/queue.c | 43 ++++++++++++++++++++++---------------------
 1 file changed, 22 insertions(+), 21 deletions(-)

diff --git a/dlls/setupapi/queue.c b/dlls/setupapi/queue.c
index d18ce9a..73929ea 100644
--- a/dlls/setupapi/queue.c
+++ b/dlls/setupapi/queue.c
@@ -1228,6 +1228,24 @@ BOOL WINAPI SetupInstallFileW( HINF hinf, PINFCONTEXT inf_context, PCWSTR source
     return SetupInstallFileExW( hinf, inf_context, source, root, dest, style, handler, context, NULL );
 }
 
+static BOOL queue_copy_file( const WCHAR *source, const WCHAR *dest,
+        const struct file_op *op, PSP_FILE_CALLBACK_W handler, void *context )
+{
+    TRACE("copying file %s -> %s\n", debugstr_w(source), debugstr_w(dest));
+
+    if (op->dst_path && !create_full_pathW(op->dst_path))
+        return FALSE;
+
+    if (do_file_copyW(source, dest, op->style, handler, context))
+        return TRUE;
+
+    /* try to extract it from the cabinet file */
+    if (op->src_tag && extract_cabinet_file(op->src_tag, op->src_root, op->src_file, dest))
+        return TRUE;
+
+    return FALSE;
+}
+
 /***********************************************************************
  *            SetupCommitFileQueueW   (SETUPAPI.@)
  */
@@ -1312,27 +1330,10 @@ BOOL WINAPI SetupCommitFileQueueW( HWND owner, HSPFILEQ handle, PSP_FILE_CALLBAC
             if (op_result == FILEOP_NEWPATH) op_result = FILEOP_DOIT;
             while (op_result == FILEOP_DOIT || op_result == FILEOP_NEWPATH)
             {
-                TRACE( "copying file %s -> %s\n",
-                       debugstr_w( op_result == FILEOP_NEWPATH ? newpath : paths.Source ),
-                       debugstr_w(paths.Target) );
-                if (op->dst_path)
-		{
-		    if (!create_full_pathW( op->dst_path ))
-		    {
-			paths.Win32Error = GetLastError();
-			op_result = handler( context, SPFILENOTIFY_COPYERROR,
-					     (UINT_PTR)&paths, (UINT_PTR)newpath );
-			if (op_result == FILEOP_ABORT) goto done;
-		    }
-		}
-                if (do_file_copyW( op_result == FILEOP_NEWPATH ? newpath : paths.Source,
-                               paths.Target, op->style, handler, context )) break;  /* success */
-                /* try to extract it from the cabinet file */
-                if (op->src_tag)
-                {
-                    if (extract_cabinet_file( op->src_tag, op->src_root,
-                                              op->src_file, paths.Target )) break;
-                }
+                if (queue_copy_file( op_result == FILEOP_NEWPATH ? newpath : paths.Source,
+                                     paths.Target, op, handler, context ))
+                    break;
+
                 paths.Win32Error = GetLastError();
                 op_result = handler( context, SPFILENOTIFY_COPYERROR,
                                      (UINT_PTR)&paths, (UINT_PTR)newpath );




More information about the wine-cvs mailing list