setupapi: Retrieve the default destination path in SetupInstallFile().

Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2019-05-17 17:36:51 -05:00 committed by Alexandre Julliard
parent 2ddc60c8f0
commit d5f6d6419b
2 changed files with 17 additions and 5 deletions

View File

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

View File

@ -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");