James Hawkins : msi: Only use the long filename when resolving the source path.

Alexandre Julliard julliard at winehq.org
Tue Jul 8 06:11:09 CDT 2008


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

Author: James Hawkins <jhawkins at codeweavers.com>
Date:   Tue Jul  8 00:07:31 2008 -0500

msi: Only use the long filename when resolving the source path.

---

 dlls/msi/helpers.c       |   24 -----------
 dlls/msi/tests/install.c |    2 +-
 dlls/msi/tests/package.c |  102 +++++++++++++++++++++++++++++++++++++---------
 3 files changed, 83 insertions(+), 45 deletions(-)

diff --git a/dlls/msi/helpers.c b/dlls/msi/helpers.c
index cffc09a..c578c68 100644
--- a/dlls/msi/helpers.c
+++ b/dlls/msi/helpers.c
@@ -323,34 +323,10 @@ LPWSTR resolve_folder(MSIPACKAGE *package, LPCWSTR name, BOOL source,
     }
     else
     {
-        /* source may be in a few different places ... check each of them */
         path = NULL;
 
-        /* try the long path directory */
         if (f->SourceLongPath)
-        {
             path = build_directory_name( 3, p, f->SourceLongPath, NULL );
-            if (INVALID_FILE_ATTRIBUTES == GetFileAttributesW( path ))
-            {
-                msi_free( path );
-                path = NULL;
-            }
-        }
-
-        /* try the short path directory */
-        if (!path && f->SourceShortPath)
-        {
-            path = build_directory_name( 3, p, f->SourceShortPath, NULL );
-            if (INVALID_FILE_ATTRIBUTES == GetFileAttributesW( path ))
-            {
-                msi_free( path );
-                path = NULL;
-            }
-        }
-
-        /* try the root of the install */
-        if (!path)
-            path = get_source_root( package );
 
         TRACE("source -> %s\n", debugstr_w(path));
         f->ResolvedSource = strdupW( path );
diff --git a/dlls/msi/tests/install.c b/dlls/msi/tests/install.c
index 8fa729a..e81e3a5 100644
--- a/dlls/msi/tests/install.c
+++ b/dlls/msi/tests/install.c
@@ -4422,11 +4422,11 @@ static void test_sourcefolder(void)
     RemoveDirectoryA("msitest");
 
     r = MsiInstallProductA(msifile, NULL);
+    ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n");
     todo_wine
     {
         ok(r == ERROR_INSTALL_FAILURE,
            "Expected ERROR_INSTALL_FAILURE, got %u\n", r);
-        ok(!delete_pf("msitest\\augustus", TRUE), "File installed\n");
         ok(!delete_pf("msitest", FALSE), "File installed\n");
     }
 
diff --git a/dlls/msi/tests/package.c b/dlls/msi/tests/package.c
index c2ebe6b..2304703 100644
--- a/dlls/msi/tests/package.c
+++ b/dlls/msi/tests/package.c
@@ -5546,11 +5546,8 @@ static void test_MsiGetSourcePath(void)
     lstrcpyA(path, "kiwi");
     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
-    todo_wine
-    {
-        ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
-        ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
-    }
+    ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
+    ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
 
     r = MsiDoAction(hpkg, "ResolveSource");
     ok(r == ERROR_SUCCESS, "file cost failed\n");
@@ -5593,11 +5590,8 @@ static void test_MsiGetSourcePath(void)
     lstrcpyA(path, "kiwi");
     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
-    todo_wine
-    {
-        ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
-        ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
-    }
+    ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
+    ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
 
     r = MsiDoAction(hpkg, "FileCost");
     ok(r == ERROR_SUCCESS, "file cost failed\n");
@@ -5632,11 +5626,8 @@ static void test_MsiGetSourcePath(void)
     lstrcpyA(path, "kiwi");
     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
-    todo_wine
-    {
-        ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
-        ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
-    }
+    ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
+    ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
 
     r = MsiDoAction(hpkg, "CostFinalize");
     ok(r == ERROR_SUCCESS, "file cost failed\n");
@@ -5671,11 +5662,8 @@ static void test_MsiGetSourcePath(void)
     lstrcpyA(path, "kiwi");
     r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
-    todo_wine
-    {
-        ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
-        ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
-    }
+    ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
+    ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
 
     /* nonexistent directory */
     size = MAX_PATH;
@@ -5730,6 +5718,79 @@ static void test_MsiGetSourcePath(void)
     DeleteFile(msifile);
 }
 
+static void test_shortlongsource(void)
+{
+    MSIHANDLE hdb, hpkg;
+    CHAR path[MAX_PATH];
+    CHAR cwd[MAX_PATH];
+    CHAR subsrc[MAX_PATH];
+    DWORD size;
+    UINT r;
+
+    lstrcpyA(cwd, CURR_DIR);
+    lstrcatA(cwd, "\\");
+
+    lstrcpyA(subsrc, cwd);
+    lstrcatA(subsrc, "long");
+    lstrcatA(subsrc, "\\");
+
+    hdb = create_package_db();
+    ok( hdb, "failed to create database\n");
+
+    r = add_directory_entry(hdb, "'TARGETDIR', '', 'SourceDir'");
+    ok(r == S_OK, "failed\n");
+
+    r = add_directory_entry(hdb, "'SubDir', 'TARGETDIR', 'short|long'");
+    ok(r == S_OK, "failed\n");
+
+    hpkg = package_from_db(hdb);
+    ok(hpkg, "failed to create package\n");
+
+    MsiCloseHandle(hdb);
+
+    r = MsiDoAction(hpkg, "CostInitialize");
+    ok(r == ERROR_SUCCESS, "file cost failed\n");
+
+    r = MsiDoAction(hpkg, "FileCost");
+    ok(r == ERROR_SUCCESS, "file cost failed\n");
+
+    r = MsiDoAction(hpkg, "CostFinalize");
+    ok(r == ERROR_SUCCESS, "file cost failed\n");
+
+    /* neither short nor long source directories exist */
+    size = MAX_PATH;
+    lstrcpyA(path, "kiwi");
+    r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
+    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+    ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
+    ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
+
+    CreateDirectoryA("short", NULL);
+
+    /* short source directory exists */
+    size = MAX_PATH;
+    lstrcpyA(path, "kiwi");
+    r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
+    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+    ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
+    ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
+
+    CreateDirectoryA("long", NULL);
+
+    /* both short and long source directories exist */
+    size = MAX_PATH;
+    lstrcpyA(path, "kiwi");
+    r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
+    ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+    ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
+    ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
+
+    MsiCloseHandle(hpkg);
+    RemoveDirectoryA("short");
+    RemoveDirectoryA("long");
+    DeleteFileA(msifile);
+}
+
 START_TEST(package)
 {
     GetCurrentDirectoryA(MAX_PATH, CURR_DIR);
@@ -5755,4 +5816,5 @@ START_TEST(package)
     test_ccpsearch();
     test_complocator();
     test_MsiGetSourcePath();
+    test_shortlongsource();
 }




More information about the wine-cvs mailing list