MSI: fix MSI_SetTargetPath
Aric Stewart
aric at codeweavers.com
Fri Jun 17 09:22:05 CDT 2005
a long overdue fix to MSI_SetTargetPath.
This should fix an error with some installers that where unable to change the target path.
-------------- next part --------------
Index: dlls/msi/install.c
===================================================================
RCS file: /home/wine/wine/dlls/msi/install.c,v
retrieving revision 1.1
diff -u -r1.1 install.c
--- dlls/msi/install.c 16 Jun 2005 20:40:34 -0000 1.1
+++ dlls/msi/install.c 17 Jun 2005 14:20:35 -0000
@@ -255,10 +255,16 @@
return rc;
}
+/*
+ * Ok my original interpertation of this was wrong. And it looks like msdn has
+ * changed a bit also. The given folder path does not have to actaully already
+ * exist, it just cannot be read only and must be a legal folder path.
+ */
UINT MSI_SetTargetPathW(MSIPACKAGE *package, LPCWSTR szFolder,
LPCWSTR szFolderPath)
{
DWORD i;
+ DWORD attrib;
LPWSTR path = NULL;
LPWSTR path2 = NULL;
MSIFOLDER *folder;
@@ -271,13 +277,27 @@
if (szFolderPath[0]==0)
return ERROR_FUNCTION_FAILED;
- if (GetFileAttributesW(szFolderPath) == INVALID_FILE_ATTRIBUTES)
+ attrib = GetFileAttributesW(szFolderPath);
+ if ( attrib != INVALID_FILE_ATTRIBUTES &&
+ (attrib != FILE_ATTRIBUTE_DIRECTORY ||
+ attrib == FILE_ATTRIBUTE_OFFLINE ||
+ attrib == FILE_ATTRIBUTE_READONLY))
return ERROR_FUNCTION_FAILED;
path = resolve_folder(package,szFolder,FALSE,FALSE,&folder);
if (!path)
return ERROR_INVALID_PARAMETER;
+
+ if (attrib == INVALID_FILE_ATTRIBUTES)
+ {
+ BOOL create_ok = FALSE;
+ create_ok = CreateDirectoryW(szFolderPath,NULL);
+ if (!create_ok)
+ return ERROR_FUNCTION_FAILED;
+ else
+ RemoveDirectoryW(szFolderPath);
+ }
HeapFree(GetProcessHeap(),0,folder->Property);
folder->Property = build_directory_name(2, szFolderPath, NULL);
More information about the wine-patches
mailing list