msi: work on SetTargetPath and Folder resolution

Aric Stewart aric at codeweavers.com
Mon Jan 3 13:56:48 CST 2005


CustomAction 35 should call SetTargetPath not just set the property

TARGETDIR and SOURCEDIR may not be entries 0 in the directory tables. So 
when resolving the folder we need to seek them out.

When we handle SetTargetPath we need to be sure to recalculate the 
resulting paths as things with the now set Directory as the parent will 
change.
-------------- next part --------------
Index: dlls/msi/action.c
===================================================================
RCS file: /home/wine/wine/dlls/msi/action.c,v
retrieving revision 1.57
diff -u -r1.57 action.c
--- dlls/msi/action.c	3 Jan 2005 16:06:44 -0000	1.57
+++ dlls/msi/action.c	3 Jan 2005 19:51:10 -0000
@@ -1299,6 +1299,10 @@
             rc = HANDLE_CustomType34(package,source,target,type);
             break;
         case 35: /* Directory set with formatted text. */
+            deformat_string(package,target,&deformated);
+            MSI_SetTargetPathW(package, source, deformated);
+            HeapFree(GetProcessHeap(),0,deformated);
+            break;
         case 51: /* Property set with formatted text. */
             deformat_string(package,target,&deformated);
             rc = MSI_SetPropertyW(package,source,deformated);
@@ -2321,7 +2325,14 @@
                     MSI_SetPropertyW(package,cszTargetDir,path);
             }
             if (folder)
-                *folder = &(package->folders[0]);
+            {
+                for (i = 0; i < package->loaded_folders; i++)
+                {
+                    if (strcmpW(package->folders[i].Directory,name)==0)
+                        break;
+                }
+                *folder = &(package->folders[i]);
+            }
             return path;
         }
         else
@@ -2338,7 +2349,14 @@
                 }
             }
             if (folder)
-                *folder = &(package->folders[0]);
+            {
+                for (i = 0; i < package->loaded_folders; i++)
+                {
+                    if (strcmpW(package->folders[i].Directory,name)==0)
+                        break;
+                }
+                *folder = &(package->folders[i]);
+            }
             return path;
         }
     }
@@ -5055,6 +5073,7 @@
 {
     DWORD i;
     LPWSTR path = NULL;
+    LPWSTR path2 = NULL;
     INT len;
     MSIFOLDER *folder;
 
@@ -5070,9 +5089,12 @@
         return ERROR_FUNCTION_FAILED;
 
     path = resolve_folder(package,szFolder,FALSE,FALSE,&folder);
+
     if (!path)
         return ERROR_INVALID_PARAMETER;
-    HeapFree(GetProcessHeap(),0,path);
+
+    if (folder->Property)
+        HeapFree(GetProcessHeap(),0,folder->Property);
 
     len = strlenW(szFolderPath);
 
@@ -5086,15 +5108,34 @@
     else
         folder->Property = dupstrW(szFolderPath);
 
+    if (strcmpiW(path, szFolderPath) == 0)
+    {
+        /*
+         *  Resolved Target has not really changed, so just 
+         *  set this folder and do not recalculate everything.
+         */
+        HeapFree(GetProcessHeap(),0,folder->ResolvedTarget);
+        folder->ResolvedTarget = NULL;
+        path2 = resolve_folder(package,szFolder,FALSE,TRUE,NULL);
+        HeapFree(GetProcessHeap(),0,path2);
+    }
+    else
+    {
     for (i = 0; i < package->loaded_folders; i++)
+        {
+            if (package->folders[i].ResolvedTarget)
+                HeapFree(GetProcessHeap(),0,package->folders[i].ResolvedTarget);
         package->folders[i].ResolvedTarget=NULL;
+        }
 
     for (i = 0; i < package->loaded_folders; i++)
     {
-        path = resolve_folder(package, package->folders[i].Directory, FALSE,
+            path2=resolve_folder(package, package->folders[i].Directory, FALSE,
                        TRUE, NULL);
-        HeapFree(GetProcessHeap(),0,path);
+            HeapFree(GetProcessHeap(),0,path2);
+    }
     }
+    HeapFree(GetProcessHeap(),0,path);
 
     return ERROR_SUCCESS;
 }


More information about the wine-patches mailing list