[PATCH 2/4] setupapi: Retrieve the default destination path in SetupInstallFile().

Zebediah Figura z.figura12 at gmail.com
Fri May 17 17:36:51 CDT 2019


Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
 dlls/setupapi/queue.c         | 16 ++++++++++++++--
 dlls/setupapi/tests/install.c |  6 +++---
 2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/dlls/setupapi/queue.c b/dlls/setupapi/queue.c
index cacab2dc6f..a0a9012b0a 100644
--- a/dlls/setupapi/queue.c
+++ b/dlls/setupapi/queue.c
@@ -1216,7 +1216,7 @@ BOOL WINAPI SetupInstallFileExW( HINF hinf, PINFCONTEXT inf_context, PCWSTR sour
     static const WCHAR CopyFiles[] = {'C','o','p','y','F','i','l','e','s',0};
 
     BOOL ret, absolute = (root && *root && !(style & SP_COPY_SOURCE_ABSOLUTE));
-    WCHAR *buffer, *p, *inf_source = NULL;
+    WCHAR *buffer, *p, *inf_source = NULL, dest_path[MAX_PATH];
     unsigned int len;
 
     TRACE("%p %p %s %s %s %x %p %p %p\n", hinf, inf_context, debugstr_w(source), debugstr_w(root),
@@ -1224,8 +1224,11 @@ BOOL WINAPI SetupInstallFileExW( HINF hinf, PINFCONTEXT inf_context, PCWSTR sour
 
     if (in_use) FIXME("no file in use support\n");
 
+    dest_path[0] = 0;
+
     if (hinf)
     {
+        WCHAR *dest_dir;
         INFCONTEXT ctx;
 
         if (!inf_context)
@@ -1245,6 +1248,13 @@ BOOL WINAPI SetupInstallFileExW( HINF hinf, PINFCONTEXT inf_context, PCWSTR sour
             return FALSE;
         }
         source = inf_source;
+
+        if ((dest_dir = get_destination_dir( hinf, NULL )))
+        {
+            strcpyW( dest_path, dest_dir );
+            strcatW( dest_path, backslashW );
+            heap_free( dest_dir );
+        }
     }
     else if (!source)
     {
@@ -1271,7 +1281,9 @@ BOOL WINAPI SetupInstallFileExW( HINF hinf, PINFCONTEXT inf_context, PCWSTR sour
     while (*source == '\\') source++;
     strcpyW( p, source );
 
-    ret = do_file_copyW( buffer, dest, style, handler, context );
+    strcatW( dest_path, dest );
+
+    ret = do_file_copyW( buffer, dest_path, style, handler, context );
 
     HeapFree( GetProcessHeap(), 0, inf_source );
     HeapFree( GetProcessHeap(), 0, buffer );
diff --git a/dlls/setupapi/tests/install.c b/dlls/setupapi/tests/install.c
index 3677e0e530..c27c9ca772 100644
--- a/dlls/setupapi/tests/install.c
+++ b/dlls/setupapi/tests/install.c
@@ -1364,11 +1364,11 @@ static void test_install_file(void)
     ret = SetupInstallFileA(hinf, &infctx, "one.txt", "src", "one.txt", 0, NULL, NULL);
     ok(ret, "Expected success.\n");
     ok(GetLastError() == ERROR_SUCCESS, "Got unexpected error %#x.\n", GetLastError());
-    todo_wine ok(delete_file("dst/one.txt"), "Destination file should exist.\n");
+    ok(delete_file("dst/one.txt"), "Destination file should exist.\n");
 
     SetLastError(0xdeadbeef);
     ret = SetupInstallFileA(hinf, &infctx, "one.txt", "src", "one.txt", SP_COPY_REPLACEONLY, NULL, NULL);
-    todo_wine ok(!ret, "Expected failure.\n");
+    ok(!ret, "Expected failure.\n");
     todo_wine ok(GetLastError() == ERROR_SUCCESS, "Got unexpected error %#x.\n", GetLastError());
     ok(!file_exists("dst/one.txt"), "Destination file should not exist.\n");
 
@@ -1394,7 +1394,7 @@ static void test_install_file(void)
     ret = SetupInstallFileA(hinf, &infctx, "three.txt", "src/alpha", "three.txt", 0, NULL, NULL);
     ok(ret, "Expected success.\n");
     ok(GetLastError() == ERROR_SUCCESS, "Got unexpected error %#x.\n", GetLastError());
-    todo_wine ok(delete_file("dst/three.txt"), "Destination file should exist.\n");
+    ok(delete_file("dst/three.txt"), "Destination file should exist.\n");
 
     SetupCloseInfFile(hinf);
     delete_file("src/one.txt");
-- 
2.21.0




More information about the wine-devel mailing list