From d5f6d6419b16ef81ce882f01a318189251320fcb Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Fri, 17 May 2019 17:36:51 -0500 Subject: [PATCH] setupapi: Retrieve the default destination path in SetupInstallFile(). Signed-off-by: Zebediah Figura Signed-off-by: Alexandre Julliard --- 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 cacab2dc6f9..a0a9012b0a7 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 3677e0e5304..c27c9ca7722 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");