James Hawkins : msi: If the filename is empty or NULL, remove the directory .

Alexandre Julliard julliard at winehq.org
Thu Aug 21 10:02:25 CDT 2008


Module: wine
Branch: master
Commit: 7b858882ac13ba9b86f98b56e3c916f10ea022fe
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=7b858882ac13ba9b86f98b56e3c916f10ea022fe

Author: James Hawkins <jhawkins at codeweavers.com>
Date:   Thu Aug 21 02:14:59 2008 -0500

msi: If the filename is empty or NULL, remove the directory.

---

 dlls/msi/files.c         |   20 +++++++++++++++-----
 dlls/msi/tests/install.c |   25 ++++++++++++++++++++++---
 2 files changed, 37 insertions(+), 8 deletions(-)

diff --git a/dlls/msi/files.c b/dlls/msi/files.c
index 3c8ac60..c829ce9 100644
--- a/dlls/msi/files.c
+++ b/dlls/msi/files.c
@@ -491,7 +491,8 @@ static UINT ITERATE_RemoveFiles(MSIRECORD *row, LPVOID param)
     if (!dir)
         return ERROR_OUTOFMEMORY;
 
-    size = lstrlenW(filename) + lstrlenW(dir) + 2;
+    size = (filename != NULL) ? lstrlenW(filename) : 0;
+    size += lstrlenW(dir) + 2;
     path = msi_alloc(size * sizeof(WCHAR));
     if (!path)
     {
@@ -500,11 +501,20 @@ static UINT ITERATE_RemoveFiles(MSIRECORD *row, LPVOID param)
     }
 
     lstrcpyW(path, dir);
-    lstrcatW(path, filename);
+    PathAddBackslashW(path);
 
-    TRACE("Deleting misc file: %s\n", debugstr_w(path));
-    if (!DeleteFileW(path))
-        TRACE("DeleteFileW failed: %d\n", GetLastError());
+    if (filename)
+    {
+        lstrcatW(path, filename);
+
+        TRACE("Deleting misc file: %s\n", debugstr_w(path));
+        DeleteFileW(path);
+    }
+    else
+    {
+        TRACE("Removing misc directory: %s\n", debugstr_w(path));
+        RemoveDirectoryW(path);
+    }
 
 done:
     msi_free(path);
diff --git a/dlls/msi/tests/install.c b/dlls/msi/tests/install.c
index 04a9675..b326758 100644
--- a/dlls/msi/tests/install.c
+++ b/dlls/msi/tests/install.c
@@ -551,7 +551,8 @@ static const CHAR rem_remove_files_dat[] = "FileKey\tComponent_\tFileName\tDirPr
                                            "attoparsec\tlithium\tattoparsec\tMSITESTDIR\t2\n"
                                            "storeys\thydrogen\tstoreys\tMSITESTDIR\t3\n"
                                            "block\thelium\tblock\tMSITESTDIR\t3\n"
-                                           "siriometer\tlithium\tsiriometer\tMSITESTDIR\t3\n";
+                                           "siriometer\tlithium\tsiriometer\tMSITESTDIR\t3\n"
+                                           "nanoacre\thydrogen\t\tCABOUTDIR\t3\n";
 
 static const CHAR mov_move_file_dat[] = "FileKey\tComponent_\tSourceName\tDestName\tSourceFolder\tDestFolder\tOptions\n"
                                         "s72\ts72\tS255\tS255\tS72\ts72\ti2\n"
@@ -4228,7 +4229,6 @@ static void test_removefiles(void)
     create_file("msitest\\hydrogen", 500);
     create_file("msitest\\helium", 500);
     create_file("msitest\\lithium", 500);
-    create_file("msitest\\beryllium", 500);
 
     create_database(msifile, rem_tables, sizeof(rem_tables) / sizeof(msi_table));
 
@@ -4283,6 +4283,8 @@ static void test_removefiles(void)
     create_pf("msitest\\storeys", TRUE);
     create_pf("msitest\\block", TRUE);
     create_pf("msitest\\siriometer", TRUE);
+    create_pf("msitest\\cabout", FALSE);
+    create_pf("msitest\\cabout\\blocker", TRUE);
 
     r = MsiInstallProductA(msifile, NULL);
     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
@@ -4298,6 +4300,7 @@ static void test_removefiles(void)
     ok(!pf_exists("msitest\\storeys"), "File not deleted\n");
     ok(!pf_exists("msitest\\block"), "File not deleted\n");
     ok(!pf_exists("msitest\\siriometer"), "File not deleted\n");
+    ok(pf_exists("msitest\\cabout"), "Directory removed\n");
     ok(pf_exists("msitest"), "File not installed\n");
 
     create_pf("msitest\\furlong", TRUE);
@@ -4324,7 +4327,23 @@ static void test_removefiles(void)
     ok(!delete_pf("msitest\\storeys", TRUE), "File not deleted\n");
     ok(!delete_pf("msitest\\block", TRUE), "File not deleted\n");
     ok(delete_pf("msitest\\siriometer", TRUE), "File deleted\n");
-    ok(delete_pf("msitest", FALSE), "File deleted\n");
+    ok(pf_exists("msitest\\cabout"), "Directory deleted\n");
+    ok(pf_exists("msitest"), "Directory deleted\n");
+
+    r = MsiInstallProductA(msifile, NULL);
+    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
+    ok(delete_pf("msitest\\hydrogen", TRUE), "File not installed\n");
+    ok(!delete_pf("msitest\\helium", TRUE), "File installed\n");
+    ok(delete_pf("msitest\\lithium", TRUE), "File not installed\n");
+    ok(pf_exists("msitest\\cabout"), "Directory deleted\n");
+    ok(pf_exists("msitest"), "Directory deleted\n");
+
+    delete_pf("msitest\\cabout\\blocker", TRUE);
+
+    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");
 
     DeleteFile(msifile);
     DeleteFile("msitest\\hydrogen");




More information about the wine-cvs mailing list