[Wine-patches] [eterhack 1/6] msi: Remove empty directories after removing files (eterbug #953).
Alexander Morozov
amorozov на etersoft.ru
Пт Авг 14 16:21:44 MSD 2009
---
dlls/msi/action.c | 34 +++++++++++++++++++++++++++
dlls/msi/files.c | 2 +
dlls/msi/msipriv.h | 1 +
dlls/msi/tests/install.c | 57 ++++++++++++---------------------------------
4 files changed, 52 insertions(+), 42 deletions(-)
diff --git a/dlls/msi/action.c b/dlls/msi/action.c
index 3af3114..ff57a99 100644
--- a/dlls/msi/action.c
+++ b/dlls/msi/action.c
@@ -1248,6 +1248,40 @@ UINT msi_create_component_directories( MSIPACKAGE *package )
return ERROR_SUCCESS;
}
+static UINT msi_remove_directory( MSIPACKAGE* package, LPCWSTR dir )
+{
+ UINT rc = ERROR_SUCCESS;
+ MSIFOLDER *folder;
+ LPWSTR install_path;
+
+ install_path = resolve_folder(package, dir, FALSE, FALSE, TRUE, &folder);
+ if (!install_path)
+ return ERROR_FUNCTION_FAILED;
+
+ if (folder->State != 3 && RemoveDirectoryW(install_path))
+ {
+ folder->State = 0;
+ msi_remove_directory(package, folder->Parent);
+ }
+ msi_free(install_path);
+
+ return rc;
+}
+
+UINT msi_remove_component_directories( MSIPACKAGE *package )
+{
+ MSICOMPONENT *comp;
+
+ LIST_FOR_EACH_ENTRY( comp, &package->components, MSICOMPONENT, entry )
+ {
+ if (!ACTION_VerifyComponentForAction( comp, INSTALLSTATE_ABSENT ))
+ continue;
+ msi_remove_directory( package, comp->Directory );
+ }
+
+ return ERROR_SUCCESS;
+}
+
/*
* Also we cannot enable/disable components either, so for now I am just going
* to do all the directories for all the components.
diff --git a/dlls/msi/files.c b/dlls/msi/files.c
index 87fbb8b..16a1a4a 100644
--- a/dlls/msi/files.c
+++ b/dlls/msi/files.c
@@ -594,5 +594,7 @@ UINT ACTION_RemoveFiles( MSIPACKAGE *package )
/* FIXME: call ui_progress here? */
}
+ msi_remove_component_directories( package );
+
return ERROR_SUCCESS;
}
diff --git a/dlls/msi/msipriv.h b/dlls/msi/msipriv.h
index b61d7b6..31afac0 100644
--- a/dlls/msi/msipriv.h
+++ b/dlls/msi/msipriv.h
@@ -983,6 +983,7 @@ extern UINT register_unique_action(MSIPACKAGE *, LPCWSTR);
extern BOOL check_unique_action(const MSIPACKAGE *, LPCWSTR);
extern WCHAR* generate_error_string(MSIPACKAGE *, UINT, DWORD, ... );
extern UINT msi_create_component_directories( MSIPACKAGE *package );
+extern UINT msi_remove_component_directories( MSIPACKAGE *package );
extern UINT msi_set_last_used_source(LPCWSTR product, LPCWSTR usersid,
MSIINSTALLCONTEXT context, DWORD options, LPCWSTR value);
diff --git a/dlls/msi/tests/install.c b/dlls/msi/tests/install.c
index e6c22fb..2dbd954 100644
--- a/dlls/msi/tests/install.c
+++ b/dlls/msi/tests/install.c
@@ -3873,10 +3873,7 @@ static void test_publish(void)
r = MsiInstallProductA(msifile, "REMOVE=ALL");
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!pf_exists("msitest\\maximus"), "File deleted\n");
- todo_wine
- {
- ok(!pf_exists("msitest"), "File deleted\n");
- }
+ ok(!pf_exists("msitest"), "File deleted\n");
state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
@@ -3951,7 +3948,7 @@ static void test_publish(void)
r = MsiInstallProductA(msifile, "UNPUBLISH_FEATURES=1 REMOVE=feature");
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
todo_wine ok(pf_exists("msitest\\maximus"), "File deleted\n");
- ok(pf_exists("msitest"), "File deleted\n");
+ todo_wine ok(pf_exists("msitest"), "File deleted\n");
state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
@@ -4055,10 +4052,7 @@ static void test_publish(void)
r = MsiInstallProductA(msifile, "UNPUBLISH_FEATURES=1 REMOVE=feature,montecristo");
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!pf_exists("msitest\\maximus"), "File not deleted\n");
- todo_wine
- {
- ok(!pf_exists("msitest"), "File not deleted\n");
- }
+ ok(!pf_exists("msitest"), "File not deleted\n");
state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
@@ -4133,10 +4127,7 @@ static void test_publish(void)
r = MsiInstallProductA(msifile, "FULL=1 REMOVE=ALL");
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!pf_exists("msitest\\maximus"), "File not deleted\n");
- todo_wine
- {
- ok(!pf_exists("msitest"), "File not deleted\n");
- }
+ ok(!pf_exists("msitest"), "File not deleted\n");
state = MsiQueryProductState("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}");
ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
@@ -4350,10 +4341,7 @@ static void test_publishsourcelist(void)
r = MsiInstallProductA(msifile, "FULL=1 REMOVE=ALL");
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!pf_exists("msitest\\maximus"), "File not deleted\n");
- todo_wine
- {
- ok(!pf_exists("msitest"), "File not deleted\n");
- }
+ ok(!pf_exists("msitest"), "File not deleted\n");
/* make sure 'Program Files\msitest' is removed */
delete_pfmsitest_files();
@@ -4858,7 +4846,10 @@ static void test_removefiles(void)
r = MsiInstallProductA(msifile, "REMOVE=ALL");
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
ok(!delete_pf("msitest\\cabout", FALSE), "Directory not deleted\n");
- ok(delete_pf("msitest", FALSE), "Directory deleted\n");
+ todo_wine
+ {
+ ok(delete_pf("msitest", FALSE), "Directory deleted\n");
+ }
DeleteFile(msifile);
DeleteFile("msitest\\hydrogen");
@@ -5713,10 +5704,7 @@ static void test_MsiConfigureProductEx(void)
ok(!delete_pf("msitest\\hydrogen", TRUE), "File not removed\n");
ok(!delete_pf("msitest\\helium", TRUE), "File not removed\n");
ok(!delete_pf("msitest\\lithium", TRUE), "File not removed\n");
- todo_wine
- {
- ok(!delete_pf("msitest", FALSE), "File not removed\n");
- }
+ ok(!delete_pf("msitest", FALSE), "File not removed\n");
/* product has been removed */
r = MsiConfigureProductExA("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}",
@@ -5741,10 +5729,7 @@ static void test_MsiConfigureProductEx(void)
ok(!delete_pf("msitest\\hydrogen", TRUE), "File not removed\n");
ok(!delete_pf("msitest\\helium", TRUE), "File not removed\n");
ok(!delete_pf("msitest\\lithium", TRUE), "File not removed\n");
- todo_wine
- {
- ok(!delete_pf("msitest", FALSE), "File not removed\n");
- }
+ ok(!delete_pf("msitest", FALSE), "File not removed\n");
/* product has been removed */
r = MsiConfigureProductExA("{7DF88A48-996F-4EC8-A022-BF956F9B2CBB}",
@@ -5771,10 +5756,7 @@ static void test_MsiConfigureProductEx(void)
ok(!delete_pf("msitest\\hydrogen", TRUE), "File not removed\n");
ok(!delete_pf("msitest\\helium", TRUE), "File not removed\n");
ok(!delete_pf("msitest\\lithium", TRUE), "File not removed\n");
- todo_wine
- {
- ok(!delete_pf("msitest", FALSE), "File not removed\n");
- }
+ ok(!delete_pf("msitest", FALSE), "File not removed\n");
create_database(msifile, mcp_tables, sizeof(mcp_tables) / sizeof(msi_table));
@@ -5821,10 +5803,7 @@ static void test_MsiConfigureProductEx(void)
ok(!delete_pf("msitest\\hydrogen", TRUE), "File not removed\n");
ok(!delete_pf("msitest\\helium", TRUE), "File not removed\n");
ok(!delete_pf("msitest\\lithium", TRUE), "File not removed\n");
- todo_wine
- {
- ok(!delete_pf("msitest", FALSE), "File not removed\n");
- }
+ ok(!delete_pf("msitest", FALSE), "File not removed\n");
/* install the product, machine */
r = MsiInstallProductA(msifile, "ALLUSERS=1 INSTALLLEVEL=10 PROPVAR=42");
@@ -5885,10 +5864,7 @@ static void test_MsiConfigureProductEx(void)
ok(!delete_pf("msitest\\hydrogen", TRUE), "File not removed\n");
ok(!delete_pf("msitest\\helium", TRUE), "File not removed\n");
ok(!delete_pf("msitest\\lithium", TRUE), "File not removed\n");
- todo_wine
- {
- ok(!delete_pf("msitest", FALSE), "File not removed\n");
- }
+ ok(!delete_pf("msitest", FALSE), "File not removed\n");
DeleteFileA(msifile);
RegCloseKey(source);
@@ -5927,10 +5903,7 @@ static void test_missingcomponent(void)
ok(!delete_pf("msitest\\helium", TRUE), "File not removed\n");
ok(!delete_pf("msitest\\lithium", TRUE), "File not removed\n");
ok(!pf_exists("msitest\\beryllium"), "File installed\n");
- todo_wine
- {
- ok(!delete_pf("msitest", FALSE), "File not removed\n");
- }
+ ok(!delete_pf("msitest", FALSE), "File not removed\n");
DeleteFileA(msifile);
DeleteFileA("msitest\\hydrogen");
--
1.6.3.3
Подробная информация о списке рассылки Wine-patches