Commit f3e7ed44 authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

msi: Open the log file once per package.

parent 29ee6540
......@@ -1766,24 +1766,26 @@ UINT WINAPI MsiEnableLogA(DWORD dwLogMode, LPCSTR szLogFile, DWORD attributes)
UINT WINAPI MsiEnableLogW(DWORD dwLogMode, LPCWSTR szLogFile, DWORD attributes)
{
HANDLE file = INVALID_HANDLE_VALUE;
TRACE("%08x %s %08x\n", dwLogMode, debugstr_w(szLogFile), attributes);
msi_free(gszLogFile);
gszLogFile = NULL;
if (szLogFile)
{
lstrcpyW(gszLogFile,szLogFile);
HANDLE file;
if (!(attributes & INSTALLLOGATTRIBUTES_APPEND))
DeleteFileW(szLogFile);
file = CreateFileW(szLogFile, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, OPEN_ALWAYS,
FILE_ATTRIBUTE_NORMAL, NULL);
if (file != INVALID_HANDLE_VALUE)
{
gszLogFile = strdupW(szLogFile);
CloseHandle(file);
}
else
ERR("Unable to enable log %s (%u)\n", debugstr_w(szLogFile), GetLastError());
}
else
gszLogFile[0] = '\0';
return ERROR_SUCCESS;
}
......
......@@ -44,7 +44,7 @@ INSTALLUI_HANDLERW gUIHandlerW = NULL;
INSTALLUI_HANDLER_RECORD gUIHandlerRecord = NULL;
DWORD gUIFilter = 0;
LPVOID gUIContext = NULL;
WCHAR gszLogFile[MAX_PATH];
WCHAR *gszLogFile = NULL;
HINSTANCE msi_hInstance;
static WCHAR msi_path[MAX_PATH];
......@@ -78,6 +78,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
if (msi_typelib) ITypeLib_Release( msi_typelib );
msi_dialog_unregister_class();
msi_free_handle_table();
msi_free( gszLogFile );
break;
}
return TRUE;
......
......@@ -331,6 +331,7 @@ typedef struct tagMSIPACKAGE
struct list folders;
LPWSTR ActionFormat;
LPWSTR LastAction;
HANDLE log_file;
struct list classes;
struct list extensions;
......@@ -879,7 +880,7 @@ extern INSTALLUI_HANDLERW gUIHandlerW;
extern INSTALLUI_HANDLER_RECORD gUIHandlerRecord;
extern DWORD gUIFilter;
extern LPVOID gUIContext;
extern WCHAR gszLogFile[MAX_PATH];
extern WCHAR *gszLogFile;
extern HINSTANCE msi_hInstance;
/* action related functions */
......
......@@ -295,6 +295,7 @@ static void MSI_FreePackage( MSIOBJECTHDR *arg)
msiobj_release( &package->db->hdr );
free_package_structures(package);
CloseHandle( package->log_file );
}
static UINT create_temp_property_table(MSIPACKAGE *package)
......@@ -1121,6 +1122,8 @@ MSIPACKAGE *MSI_CreatePackage( MSIDATABASE *db, LPCWSTR base_url )
if (package->WordCount & msidbSumInfoSourceTypeAdminImage)
msi_load_admin_properties( package );
package->log_file = INVALID_HANDLE_VALUE;
}
return package;
......@@ -1551,6 +1554,10 @@ UINT MSI_OpenPackageW(LPCWSTR szPackage, MSIPACKAGE **pPackage)
msi_adjust_privilege_properties( package );
}
if (gszLogFile)
package->log_file = CreateFileW( gszLogFile, GENERIC_WRITE, FILE_SHARE_WRITE, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
*pPackage = package;
return ERROR_SUCCESS;
}
......@@ -1657,17 +1664,13 @@ INT MSI_ProcessMessage( MSIPACKAGE *package, INSTALLMESSAGE eMessageType,
{'S','e','t','P','r','o','g','r','e','s','s',0};
static const WCHAR szActionText[] =
{'A','c','t','i','o','n','T','e','x','t',0};
DWORD log_type = 0;
LPWSTR message;
DWORD sz;
DWORD total_size = 0;
INT i;
INT rc;
DWORD sz, total_size = 0, log_type = 0;
INT i, rc = 0;
char *msg;
int len;
TRACE("%x\n", eMessageType);
rc = 0;
if ((eMessageType & 0xff000000) == INSTALLMESSAGE_ERROR)
log_type |= INSTALLLOGMODE_ERROR;
......@@ -1773,19 +1776,12 @@ INT MSI_ProcessMessage( MSIPACKAGE *package, INSTALLMESSAGE eMessageType,
MsiCloseHandle( rec );
}
if (!rc && gszLogFile[0] && (eMessageType & 0xff000000) != INSTALLMESSAGE_PROGRESS)
if (!rc && package->log_file != INVALID_HANDLE_VALUE &&
(eMessageType & 0xff000000) != INSTALLMESSAGE_PROGRESS)
{
DWORD write;
HANDLE log_file = CreateFileW(gszLogFile, GENERIC_WRITE, FILE_SHARE_WRITE, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (log_file != INVALID_HANDLE_VALUE)
{
SetFilePointer(log_file,0, NULL, FILE_END);
WriteFile(log_file,msg,strlen(msg),&write,NULL);
WriteFile(log_file,"\n",1,&write,NULL);
CloseHandle(log_file);
}
DWORD written;
WriteFile( package->log_file, msg, len - 1, &written, NULL );
WriteFile( package->log_file, "\n", 1, &written, NULL );
}
msi_free( msg );
msi_free( message );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment