msi: Clean upstore_binary_to_temp.

This commit is contained in:
Mike McCormack 2006-11-13 16:34:37 +09:00 committed by Alexandre Julliard
parent 1ccf944900
commit 0b7a17d282
1 changed files with 37 additions and 42 deletions

View File

@ -287,9 +287,17 @@ end:
static UINT store_binary_to_temp(MSIPACKAGE *package, LPCWSTR source,
LPWSTR tmp_file)
{
DWORD sz=MAX_PATH;
static const WCHAR query[] = {
'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
'`','B','i' ,'n','a','r','y','`',' ','W','H','E','R','E',' ',
'`','N','a','m','e','`',' ','=',' ','\'','%','s','\'',0};
UINT rc;
MSIRECORD *row = 0;
HANDLE file;
CHAR buffer[1024];
static const WCHAR f1[] = {'m','s','i',0};
WCHAR fmt[MAX_PATH];
DWORD sz = MAX_PATH;
if (MSI_GetPropertyW(package, cszTempFolder, fmt, &sz) != ERROR_SUCCESS)
GetTempPathW(MAX_PATH, fmt);
@ -299,47 +307,34 @@ static UINT store_binary_to_temp(MSIPACKAGE *package, LPCWSTR source,
TRACE("Unable to create file\n");
return ERROR_FUNCTION_FAILED;
}
else
{
/* write out the file */
UINT rc;
MSIRECORD * row = 0;
static const WCHAR fmt[] =
{'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
'`','B','i' ,'n','a','r','y','`',' ','W','H','E','R','E',
' ','`','N','a','m','e','`',' ','=',' ','\'','%','s','\'',0};
HANDLE the_file;
CHAR buffer[1024];
the_file = CreateFileW(tmp_file, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
file = CreateFileW(tmp_file, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL, NULL);
if (the_file == INVALID_HANDLE_VALUE)
if (file == INVALID_HANDLE_VALUE)
return ERROR_FUNCTION_FAILED;
row = MSI_QueryGetRecord(package->db, fmt, source);
row = MSI_QueryGetRecord(package->db, query, source);
if (!row)
return ERROR_FUNCTION_FAILED;
do
{
DWORD write;
sz = 1024;
sz = sizeof buffer;
rc = MSI_RecordReadStream(row, 2, buffer, &sz);
if (rc != ERROR_SUCCESS)
{
ERR("Failed to get stream\n");
CloseHandle(the_file);
CloseHandle(file);
DeleteFileW(tmp_file);
break;
}
WriteFile(the_file,buffer,sz,&write,NULL);
} while (sz == 1024);
CloseHandle(the_file);
WriteFile(file, buffer, sz, &write, NULL);
} while (sz == sizeof buffer);
CloseHandle(file);
msiobj_release(&row->hdr);
}
return ERROR_SUCCESS;
}