msi: prevent locking the cd
Aric Stewart
aric at codeweavers.com
Fri Jun 24 09:00:19 CDT 2005
Copy the msi file to a temp file to prevent locking a CD during an
install. This allows multi disc installs to eject the first volume.
-------------- next part --------------
Index: dlls/msi/action.c
===================================================================
RCS file: /home/wine/wine/dlls/msi/action.c,v
retrieving revision 1.165
diff -u -r1.165 action.c
--- dlls/msi/action.c 24 Jun 2005 12:14:52 -0000 1.165
+++ dlls/msi/action.c 24 Jun 2005 13:55:51 -0000
@@ -432,7 +432,7 @@
*****************************************************/
UINT ACTION_DoTopLevelINSTALL(MSIPACKAGE *package, LPCWSTR szPackagePath,
- LPCWSTR szCommandLine)
+ LPCWSTR szCommandLine, LPCWSTR msiFilePath)
{
DWORD sz;
WCHAR buffer[10];
@@ -447,6 +447,8 @@
package->script = HeapAlloc(GetProcessHeap(),0,sizeof(MSISCRIPT));
memset(package->script,0,sizeof(MSISCRIPT));
+ package->msiFilePath= strdupW(msiFilePath);
+
if (szPackagePath)
{
LPWSTR p, check, path;
@@ -1371,9 +1373,6 @@
if (targetdir[0] == '.' && targetdir[1] == 0)
targetdir = NULL;
- if (srcdir && srcdir[0] == '.' && srcdir[1] == 0)
- srcdir = NULL;
-
if (targetdir)
{
TRACE(" TargetDefault = %s\n",debugstr_w(targetdir));
@@ -3574,9 +3573,9 @@
snprintfW(path,sizeof(path)/sizeof(path[0]),installerPathFmt,windir);
create_full_pathW(path);
TRACE("Copying to local package %s\n",debugstr_w(packagefile));
- if (!CopyFileW(package->PackagePath,packagefile,FALSE))
+ if (!CopyFileW(package->msiFilePath,packagefile,FALSE))
ERR("Unable to copy package (%s -> %s) (error %ld)\n",
- debugstr_w(package->PackagePath), debugstr_w(packagefile),
+ debugstr_w(package->msiFilePath), debugstr_w(packagefile),
GetLastError());
size = strlenW(packagefile)*sizeof(WCHAR);
RegSetValueExW(hkey,szLocalPackage,0,REG_SZ,(LPSTR)packagefile,size);
Index: dlls/msi/helpers.c
===================================================================
RCS file: /home/wine/wine/dlls/msi/helpers.c,v
retrieving revision 1.2
diff -u -r1.2 helpers.c
--- dlls/msi/helpers.c 21 Jun 2005 20:21:30 -0000 1.2
+++ dlls/msi/helpers.c 24 Jun 2005 13:55:52 -0000
@@ -580,6 +580,7 @@
}
HeapFree(GetProcessHeap(),0,package->PackagePath);
+ HeapFree(GetProcessHeap(),0,package->msiFilePath);
/* cleanup control event subscriptions */
ControlEvent_CleanupSubscriptions(package);
Index: dlls/msi/msi.c
===================================================================
RCS file: /home/wine/wine/dlls/msi/msi.c,v
retrieving revision 1.88
diff -u -r1.88 msi.c
--- dlls/msi/msi.c 13 Jun 2005 19:04:39 -0000 1.88
+++ dlls/msi/msi.c 24 Jun 2005 13:55:53 -0000
@@ -202,6 +202,9 @@
MSIPACKAGE *package = NULL;
UINT r;
MSIHANDLE handle;
+ WCHAR path[MAX_PATH];
+ WCHAR filename[MAX_PATH];
+ static const WCHAR szMSI[] = {'M','S','I',0};
FIXME("%s %s\n",debugstr_w(szPackagePath), debugstr_w(szCommandLine));
@@ -209,16 +212,31 @@
if (r != ERROR_SUCCESS)
return r;
- r = MSI_OpenPackageW(szPackagePath,&package);
+ /* copy the msi file to a temp file to pervent locking a CD
+ * with a multi disc install
+ */
+ GetTempPathW(MAX_PATH, path);
+ GetTempFileNameW(path, szMSI, 0, filename);
+
+ CopyFileW(szPackagePath, filename, FALSE);
+
+ TRACE("Opening relocated package %s\n",debugstr_w(filename));
+ r = MSI_OpenPackageW(filename, &package);
if (r != ERROR_SUCCESS)
+ {
+ DeleteFileW(filename);
return r;
+ }
handle = alloc_msihandle( &package->hdr );
- r = ACTION_DoTopLevelINSTALL(package, szPackagePath, szCommandLine);
+ r = ACTION_DoTopLevelINSTALL(package, szPackagePath, szCommandLine,
+ filename);
MsiCloseHandle(handle);
msiobj_release( &package->hdr );
+
+ DeleteFileW(filename);
return r;
}
@@ -324,7 +342,7 @@
if (MsiQueryProductStateW(szProduct) != INSTALLSTATE_UNKNOWN)
lstrcatW(commandline,szInstalled);
- rc = ACTION_DoTopLevelINSTALL(package, sourcepath, commandline);
+ rc = ACTION_DoTopLevelINSTALL(package, sourcepath, commandline, sourcepath);
msiobj_release( &package->hdr );
Index: dlls/msi/msipriv.h
===================================================================
RCS file: /home/wine/wine/dlls/msi/msipriv.h,v
retrieving revision 1.68
diff -u -r1.68 msipriv.h
--- dlls/msi/msipriv.h 23 Jun 2005 16:43:38 -0000 1.68
+++ dlls/msi/msipriv.h 24 Jun 2005 13:55:54 -0000
@@ -216,6 +216,7 @@
UINT RunningActionCount;
LPWSTR PackagePath;
+ LPWSTR msiFilePath;
UINT CurrentInstallState;
msi_dialog *dialog;
@@ -307,7 +308,7 @@
USHORT **pdata, UINT *psz );
/* action internals */
-extern UINT ACTION_DoTopLevelINSTALL( MSIPACKAGE *, LPCWSTR, LPCWSTR );
+extern UINT ACTION_DoTopLevelINSTALL( MSIPACKAGE *, LPCWSTR, LPCWSTR, LPCWSTR );
extern void ACTION_free_package_structures( MSIPACKAGE* );
extern UINT ACTION_DialogBox( MSIPACKAGE*, LPCWSTR);
Index: dlls/msi/package.c
===================================================================
RCS file: /home/wine/wine/dlls/msi/package.c,v
retrieving revision 1.43
diff -u -r1.43 package.c
--- dlls/msi/package.c 6 Jun 2005 15:40:15 -0000 1.43
+++ dlls/msi/package.c 24 Jun 2005 13:55:54 -0000
@@ -454,18 +454,32 @@
{
MSIPACKAGE *package = NULL;
UINT ret;
+ WCHAR path[MAX_PATH];
+ WCHAR filename[MAX_PATH];
+ static const WCHAR szMSI[] = {'M','S','I',0};
TRACE("%s %08lx %p\n",debugstr_w(szPackage), dwOptions, phPackage);
+ /* copy the msi file to a temp file to pervent locking a CD
+ * with a multi disc install
+ */
+ GetTempPathW(MAX_PATH, path);
+ GetTempFileNameW(path, szMSI, 0, filename);
+
+ CopyFileW(szPackage, filename, FALSE);
+
+ TRACE("Opening relocated package %s\n",debugstr_w(filename));
+
if( dwOptions )
FIXME("dwOptions %08lx not supported\n", dwOptions);
- ret = MSI_OpenPackageW( szPackage, &package);
+ ret = MSI_OpenPackageW( filename, &package);
if( ret == ERROR_SUCCESS )
{
*phPackage = alloc_msihandle( &package->hdr );
msiobj_release( &package->hdr );
}
+ DeleteFileW(filename);
return ret;
}
More information about the wine-patches
mailing list