Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/setupapi/tests/install.c | 91 +++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+)
diff --git a/dlls/setupapi/tests/install.c b/dlls/setupapi/tests/install.c index 85f532a78b..3677e0e530 100644 --- a/dlls/setupapi/tests/install.c +++ b/dlls/setupapi/tests/install.c @@ -1317,6 +1317,96 @@ static void run_queue_(unsigned int line, HSPFILEQ queue, PSP_FILE_CALLBACK_A cb ok_(__FILE__,line)(ret, "Failed to close queue, error %#x.\n", GetLastError()); }
+static void test_install_file(void) +{ + static const char inf_data[] = "[Version]\n" + "Signature="$Chicago$"\n" + "[section1]\n" + "one.txt\n" + "two.txt\n" + "three.txt\n" + "[SourceDisksNames]\n" + "1=heis\n" + "2=duo,,,alpha\n" + "[SourceDisksFiles]\n" + "one.txt=1\n" + "two.txt=1,beta\n" + "three.txt=2\n" + "[DestinationDirs]\n" + "DefaultDestDir=40000,dst\n"; + + char path[MAX_PATH]; + INFCONTEXT infctx; + HINF hinf; + BOOL ret; + + create_inf_file(inffile, inf_data); + + sprintf(path, "%s\%s", CURR_DIR, inffile); + hinf = SetupOpenInfFileA(path, NULL, INF_STYLE_WIN4, NULL); + ok(hinf != INVALID_HANDLE_VALUE, "Failed to open INF file, error %#x.\n", GetLastError()); + + ret = CreateDirectoryA("src", NULL); + ok(ret, "Failed to create test directory, error %u.\n", GetLastError()); + ret = CreateDirectoryA("src/alpha", NULL); + ok(ret, "Failed to create test directory, error %u.\n", GetLastError()); + ret = CreateDirectoryA("src/beta", NULL); + ok(ret, "Failed to create test directory, error %u.\n", GetLastError()); + ret = CreateDirectoryA("dst", NULL); + ok(ret, "Failed to create test directory, error %u.\n", GetLastError()); + create_file("src/one.txt"); + create_file("src/beta/two.txt"); + create_file("src/alpha/three.txt"); + + ret = SetupFindFirstLineA(hinf, "section1", "one.txt", &infctx); + ok(ret, "Failed to find line.\n"); + SetLastError(0xdeadbeef); + 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"); + + SetLastError(0xdeadbeef); + ret = SetupInstallFileA(hinf, &infctx, "one.txt", "src", "one.txt", SP_COPY_REPLACEONLY, NULL, NULL); + todo_wine 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"); + + ret = SetupFindFirstLineA(hinf, "section1", "two.txt", &infctx); + ok(ret, "Failed to find line.\n"); + SetLastError(0xdeadbeef); + ret = SetupInstallFileA(hinf, &infctx, "two.txt", "src", "two.txt", 0, NULL, NULL); + todo_wine ok(ret, "Expected success.\n"); + todo_wine ok(GetLastError() == ERROR_SUCCESS, "Got unexpected error %#x.\n", GetLastError()); + todo_wine ok(delete_file("dst/two.txt"), "Destination file should exist.\n"); + + ret = SetupFindFirstLineA(hinf, "section1", "three.txt", &infctx); + ok(ret, "Failed to find line.\n"); + SetLastError(0xdeadbeef); + ret = SetupInstallFileA(hinf, &infctx, "three.txt", "src", "three.txt", 0, NULL, NULL); + ok(!ret, "Expected failure.\n"); + ok(GetLastError() == ERROR_FILE_NOT_FOUND, "Got unexpected error %#x.\n", GetLastError()); + ok(!file_exists("dst/three.txt"), "Destination file should not exist.\n"); + + ret = SetupFindFirstLineA(hinf, "section1", "three.txt", &infctx); + ok(ret, "Failed to find line.\n"); + SetLastError(0xdeadbeef); + 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"); + + SetupCloseInfFile(hinf); + delete_file("src/one.txt"); + delete_file("src/beta/two.txt"); + delete_file("src/beta/"); + delete_file("src/alpha/three.txt"); + delete_file("src/alpha/"); + delete_file("src/"); + delete_file("dst/"); + ok(delete_file(inffile), "Failed to delete INF file.\n"); +} + static void test_need_media(void) { static const char inf_data[] = "[Version]\n" @@ -1857,6 +1947,7 @@ START_TEST(install) test_install_files_queue(); test_need_media(); test_close_queue(); + test_install_file();
UnhookWindowsHookEx(hhook);
Signed-off-by: Zebediah Figura z.figura12@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");
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/setupapi/queue.c | 2 ++ dlls/setupapi/tests/install.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/dlls/setupapi/queue.c b/dlls/setupapi/queue.c index a0a9012b0a..4a70c5b390 100644 --- a/dlls/setupapi/queue.c +++ b/dlls/setupapi/queue.c @@ -1145,6 +1145,8 @@ static BOOL do_file_copyW( LPCWSTR source, LPCWSTR target, DWORD style, rc = CopyFileW(source,target,FALSE); TRACE("Did copy... rc was %i\n",rc); } + else + SetLastError(ERROR_SUCCESS);
/* after copy processing */ if (style & SP_COPY_DELETESOURCE) diff --git a/dlls/setupapi/tests/install.c b/dlls/setupapi/tests/install.c index c27c9ca772..624751fcda 100644 --- a/dlls/setupapi/tests/install.c +++ b/dlls/setupapi/tests/install.c @@ -1369,7 +1369,7 @@ static void test_install_file(void) SetLastError(0xdeadbeef); ret = SetupInstallFileA(hinf, &infctx, "one.txt", "src", "one.txt", SP_COPY_REPLACEONLY, NULL, NULL); ok(!ret, "Expected failure.\n"); - todo_wine ok(GetLastError() == ERROR_SUCCESS, "Got unexpected error %#x.\n", GetLastError()); + ok(GetLastError() == ERROR_SUCCESS, "Got unexpected error %#x.\n", GetLastError()); ok(!file_exists("dst/one.txt"), "Destination file should not exist.\n");
ret = SetupFindFirstLineA(hinf, "section1", "two.txt", &infctx);
This fixes a regression introduced by 3e5c9798a80641e0e39e95e4467c60405b22b062.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47219 Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/setupapi/queue.c | 2 +- dlls/setupapi/tests/install.c | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/dlls/setupapi/queue.c b/dlls/setupapi/queue.c index 4a70c5b390..d51a228d02 100644 --- a/dlls/setupapi/queue.c +++ b/dlls/setupapi/queue.c @@ -1309,7 +1309,7 @@ static BOOL queue_copy_file( const WCHAR *source, const WCHAR *dest, if (op->dst_path && !create_full_pathW(op->dst_path)) return FALSE;
- if (do_file_copyW(source, dest, op->style, handler, context)) + if (do_file_copyW(source, dest, op->style, handler, context) || GetLastError() == ERROR_SUCCESS) return TRUE;
/* try to extract it from the cabinet file */ diff --git a/dlls/setupapi/tests/install.c b/dlls/setupapi/tests/install.c index 624751fcda..a0a45969a4 100644 --- a/dlls/setupapi/tests/install.c +++ b/dlls/setupapi/tests/install.c @@ -1468,6 +1468,16 @@ static void test_need_media(void) ok(got_need_media == 1, "Got %u callbacks.\n", got_need_media); ok(delete_file("dst/one.txt"), "Destination file should exist.\n");
+ got_need_media = 0; + queue = SetupOpenFileQueue(); + ok(queue != INVALID_HANDLE_VALUE, "Failed to open queue, error %#x.\n", GetLastError()); + ret = SetupQueueCopyA(queue, "src", NULL, "one.txt", "File One", NULL, + "dst", NULL, SP_COPY_WARNIFSKIP | SP_COPY_REPLACEONLY); + ok(ret, "Failed to queue copy, error %#x.\n", GetLastError()); + run_queue(queue, need_media_cb); + ok(got_need_media == 1, "Got %u callbacks.\n", got_need_media); + ok(!file_exists("dst/one.txt"), "Destination file should exist.\n"); + /* Test with a subdirectory. */
got_need_media = 0;