From 3257bcd48c97972a590981b6d13307e535a85324 Mon Sep 17 00:00:00 2001 From: Aric Stewart Date: Fri, 17 Jun 2005 21:25:51 +0000 Subject: [PATCH] A long overdue fix to MSI_SetTargetPath. This should fix an error with some installers that where unable to change the target path. --- dlls/msi/install.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/dlls/msi/install.c b/dlls/msi/install.c index ab8404e3113..9b9ea41dcf7 100644 --- a/dlls/msi/install.c +++ b/dlls/msi/install.c @@ -255,10 +255,16 @@ UINT WINAPI MsiSetTargetPathA(MSIHANDLE hInstall, LPCSTR szFolder, return rc; } +/* + * Ok my original interpretation of this was wrong. And it looks like msdn has + * changed a bit also. The given folder path does not have to actually 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,7 +277,11 @@ UINT MSI_SetTargetPathW(MSIPACKAGE *package, LPCWSTR szFolder, 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); @@ -279,6 +289,13 @@ UINT MSI_SetTargetPathW(MSIPACKAGE *package, LPCWSTR szFolder, if (!path) return ERROR_INVALID_PARAMETER; + if (attrib == INVALID_FILE_ATTRIBUTES) + { + if (!CreateDirectoryW(szFolderPath,NULL)) + return ERROR_FUNCTION_FAILED; + RemoveDirectoryW(szFolderPath); + } + HeapFree(GetProcessHeap(),0,folder->Property); folder->Property = build_directory_name(2, szFolderPath, NULL);