2005-06-17 22:56:55 +02:00
|
|
|
/*
|
|
|
|
* Implementation of the Microsoft Installer (msi.dll)
|
|
|
|
*
|
|
|
|
* Copyright 2005 Aric Stewart for CodeWeavers
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Actions dealing with files These are
|
|
|
|
*
|
|
|
|
* InstallFiles
|
|
|
|
* DuplicateFiles
|
|
|
|
* MoveFiles (TODO)
|
|
|
|
* PatchFiles (TODO)
|
|
|
|
* RemoveDuplicateFiles(TODO)
|
|
|
|
* RemoveFiles(TODO)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winerror.h"
|
|
|
|
#include "wine/debug.h"
|
|
|
|
#include "fdi.h"
|
2005-07-05 23:00:06 +02:00
|
|
|
#include "msi.h"
|
2005-06-17 22:56:55 +02:00
|
|
|
#include "msidefs.h"
|
|
|
|
#include "msvcrt/fcntl.h"
|
|
|
|
#include "msipriv.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "wine/unicode.h"
|
|
|
|
#include "action.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(msi);
|
|
|
|
|
|
|
|
extern const WCHAR szInstallFiles[];
|
|
|
|
extern const WCHAR szDuplicateFiles[];
|
|
|
|
extern const WCHAR szMoveFiles[];
|
|
|
|
extern const WCHAR szPatchFiles[];
|
|
|
|
extern const WCHAR szRemoveDuplicateFiles[];
|
|
|
|
extern const WCHAR szRemoveFiles[];
|
|
|
|
|
|
|
|
static const WCHAR cszTempFolder[]= {'T','e','m','p','F','o','l','d','e','r',0};
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This is a helper function for handling embedded cabinet media
|
|
|
|
*/
|
|
|
|
static UINT writeout_cabinet_stream(MSIPACKAGE *package, LPCWSTR stream_name,
|
|
|
|
WCHAR* source)
|
|
|
|
{
|
|
|
|
UINT rc;
|
|
|
|
USHORT* data;
|
|
|
|
UINT size;
|
|
|
|
DWORD write;
|
|
|
|
HANDLE the_file;
|
|
|
|
WCHAR tmp[MAX_PATH];
|
|
|
|
|
|
|
|
rc = read_raw_stream_data(package->db,stream_name,&data,&size);
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
write = MAX_PATH;
|
|
|
|
if (MSI_GetPropertyW(package, cszTempFolder, tmp, &write))
|
|
|
|
GetTempPathW(MAX_PATH,tmp);
|
|
|
|
|
|
|
|
GetTempFileNameW(tmp,stream_name,0,source);
|
|
|
|
|
|
|
|
track_tempfile(package,strrchrW(source,'\\'), source);
|
|
|
|
the_file = CreateFileW(source, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
|
|
|
|
FILE_ATTRIBUTE_NORMAL, NULL);
|
|
|
|
|
|
|
|
if (the_file == INVALID_HANDLE_VALUE)
|
|
|
|
{
|
|
|
|
ERR("Unable to create file %s\n",debugstr_w(source));
|
|
|
|
rc = ERROR_FUNCTION_FAILED;
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
|
|
|
|
WriteFile(the_file,data,size,&write,NULL);
|
|
|
|
CloseHandle(the_file);
|
|
|
|
TRACE("wrote %li bytes to %s\n",write,debugstr_w(source));
|
|
|
|
end:
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free(data);
|
2005-06-17 22:56:55 +02:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Support functions for FDI functions */
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
MSIPACKAGE* package;
|
|
|
|
LPCSTR cab_path;
|
|
|
|
} CabData;
|
|
|
|
|
|
|
|
static void * cabinet_alloc(ULONG cb)
|
|
|
|
{
|
2005-09-20 13:59:14 +02:00
|
|
|
return msi_alloc(cb);
|
2005-06-17 22:56:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void cabinet_free(void *pv)
|
|
|
|
{
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free(pv);
|
2005-06-17 22:56:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static INT_PTR cabinet_open(char *pszFile, int oflag, int pmode)
|
|
|
|
{
|
2005-10-28 12:40:54 +02:00
|
|
|
HANDLE handle;
|
2005-06-17 22:56:55 +02:00
|
|
|
DWORD dwAccess = 0;
|
|
|
|
DWORD dwShareMode = 0;
|
|
|
|
DWORD dwCreateDisposition = OPEN_EXISTING;
|
|
|
|
switch (oflag & _O_ACCMODE)
|
|
|
|
{
|
|
|
|
case _O_RDONLY:
|
|
|
|
dwAccess = GENERIC_READ;
|
|
|
|
dwShareMode = FILE_SHARE_READ | FILE_SHARE_DELETE;
|
|
|
|
break;
|
|
|
|
case _O_WRONLY:
|
|
|
|
dwAccess = GENERIC_WRITE;
|
|
|
|
dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE;
|
|
|
|
break;
|
|
|
|
case _O_RDWR:
|
|
|
|
dwAccess = GENERIC_READ | GENERIC_WRITE;
|
|
|
|
dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if ((oflag & (_O_CREAT | _O_EXCL)) == (_O_CREAT | _O_EXCL))
|
|
|
|
dwCreateDisposition = CREATE_NEW;
|
|
|
|
else if (oflag & _O_CREAT)
|
|
|
|
dwCreateDisposition = CREATE_ALWAYS;
|
2005-10-28 12:40:54 +02:00
|
|
|
handle = CreateFileA( pszFile, dwAccess, dwShareMode, NULL,
|
|
|
|
dwCreateDisposition, 0, NULL );
|
|
|
|
if (handle == INVALID_HANDLE_VALUE)
|
|
|
|
return 0;
|
|
|
|
return (INT_PTR) handle;
|
2005-06-17 22:56:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static UINT cabinet_read(INT_PTR hf, void *pv, UINT cb)
|
|
|
|
{
|
2005-10-28 12:40:54 +02:00
|
|
|
HANDLE handle = (HANDLE) hf;
|
2005-06-17 22:56:55 +02:00
|
|
|
DWORD dwRead;
|
2005-10-28 12:40:54 +02:00
|
|
|
if (ReadFile(handle, pv, cb, &dwRead, NULL))
|
2005-06-17 22:56:55 +02:00
|
|
|
return dwRead;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT cabinet_write(INT_PTR hf, void *pv, UINT cb)
|
|
|
|
{
|
2005-10-28 12:40:54 +02:00
|
|
|
HANDLE handle = (HANDLE) hf;
|
2005-06-17 22:56:55 +02:00
|
|
|
DWORD dwWritten;
|
2005-10-28 12:40:54 +02:00
|
|
|
if (WriteFile(handle, pv, cb, &dwWritten, NULL))
|
2005-06-17 22:56:55 +02:00
|
|
|
return dwWritten;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int cabinet_close(INT_PTR hf)
|
|
|
|
{
|
2005-10-28 12:40:54 +02:00
|
|
|
HANDLE handle = (HANDLE) hf;
|
|
|
|
return CloseHandle(handle) ? 0 : -1;
|
2005-06-17 22:56:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static long cabinet_seek(INT_PTR hf, long dist, int seektype)
|
|
|
|
{
|
2005-10-28 12:40:54 +02:00
|
|
|
HANDLE handle = (HANDLE) hf;
|
2005-06-17 22:56:55 +02:00
|
|
|
/* flags are compatible and so are passed straight through */
|
2005-10-28 12:40:54 +02:00
|
|
|
return SetFilePointer(handle, dist, NULL, seektype);
|
2005-06-17 22:56:55 +02:00
|
|
|
}
|
|
|
|
|
2006-01-23 17:29:50 +01:00
|
|
|
static void msi_file_update_ui( MSIPACKAGE *package, MSIFILE *f, const WCHAR *action )
|
2005-10-28 12:43:50 +02:00
|
|
|
{
|
|
|
|
MSIRECORD *uirow;
|
|
|
|
LPWSTR uipath, p;
|
|
|
|
|
|
|
|
/* the UI chunk */
|
|
|
|
uirow = MSI_CreateRecord( 9 );
|
|
|
|
MSI_RecordSetStringW( uirow, 1, f->FileName );
|
|
|
|
uipath = strdupW( f->TargetPath );
|
|
|
|
p = strrchrW(uipath,'\\');
|
|
|
|
if (p)
|
|
|
|
p[1]=0;
|
|
|
|
MSI_RecordSetStringW( uirow, 9, uipath);
|
|
|
|
MSI_RecordSetInteger( uirow, 6, f->FileSize );
|
2006-01-23 17:29:50 +01:00
|
|
|
ui_actiondata( package, action, uirow);
|
2005-10-28 12:43:50 +02:00
|
|
|
msiobj_release( &uirow->hdr );
|
|
|
|
msi_free( uipath );
|
|
|
|
ui_progress( package, 2, f->FileSize, 0, 0);
|
|
|
|
}
|
|
|
|
|
2005-06-17 22:56:55 +02:00
|
|
|
static INT_PTR cabinet_notify(FDINOTIFICATIONTYPE fdint, PFDINOTIFICATION pfdin)
|
|
|
|
{
|
|
|
|
switch (fdint)
|
|
|
|
{
|
|
|
|
case fdintCOPY_FILE:
|
|
|
|
{
|
|
|
|
CabData *data = (CabData*) pfdin->pv;
|
2005-10-29 12:31:06 +02:00
|
|
|
HANDLE handle;
|
|
|
|
LPWSTR file;
|
2005-08-23 12:03:17 +02:00
|
|
|
MSIFILE *f;
|
2005-06-24 14:14:35 +02:00
|
|
|
|
2005-10-29 12:31:06 +02:00
|
|
|
file = strdupAtoW(pfdin->psz1);
|
|
|
|
f = get_loaded_file(data->package, file);
|
|
|
|
msi_free(file);
|
2005-06-24 14:14:35 +02:00
|
|
|
|
2005-08-23 12:03:17 +02:00
|
|
|
if (!f)
|
2005-06-24 14:14:35 +02:00
|
|
|
{
|
2005-09-22 12:56:26 +02:00
|
|
|
ERR("Unknown File in Cabinet (%s)\n",debugstr_a(pfdin->psz1));
|
2005-06-24 14:14:35 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-11-02 11:56:42 +01:00
|
|
|
if (f->state != msifs_missing && f->state != msifs_overwrite)
|
2005-06-24 14:14:35 +02:00
|
|
|
{
|
2005-09-22 12:56:26 +02:00
|
|
|
TRACE("Skipping extraction of %s\n",debugstr_a(pfdin->psz1));
|
2005-06-24 14:14:35 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-01-23 17:29:50 +01:00
|
|
|
msi_file_update_ui( data->package, f, szInstallFiles );
|
2005-06-17 22:56:55 +02:00
|
|
|
|
2005-10-29 12:31:06 +02:00
|
|
|
TRACE("extracting %s\n", debugstr_w(f->TargetPath) );
|
2005-06-17 22:56:55 +02:00
|
|
|
|
2005-10-29 12:31:06 +02:00
|
|
|
handle = CreateFileW( f->TargetPath, GENERIC_READ | GENERIC_WRITE, 0,
|
|
|
|
NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL );
|
|
|
|
if ( handle == INVALID_HANDLE_VALUE )
|
|
|
|
{
|
|
|
|
ERR("failed to create %s (error %ld)\n",
|
|
|
|
debugstr_w( f->TargetPath ), GetLastError() );
|
|
|
|
return 0;
|
|
|
|
}
|
2005-06-17 22:56:55 +02:00
|
|
|
|
2005-11-02 11:56:42 +01:00
|
|
|
f->state = msifs_installed;
|
2005-10-29 12:31:06 +02:00
|
|
|
return (INT_PTR) handle;
|
2005-06-17 22:56:55 +02:00
|
|
|
}
|
|
|
|
case fdintCLOSE_FILE_INFO:
|
|
|
|
{
|
|
|
|
FILETIME ft;
|
2005-10-28 12:40:54 +02:00
|
|
|
FILETIME ftLocal;
|
|
|
|
HANDLE handle = (HANDLE) pfdin->hf;
|
|
|
|
|
2005-06-17 22:56:55 +02:00
|
|
|
if (!DosDateTimeToFileTime(pfdin->date, pfdin->time, &ft))
|
|
|
|
return -1;
|
|
|
|
if (!LocalFileTimeToFileTime(&ft, &ftLocal))
|
|
|
|
return -1;
|
2005-10-28 12:40:54 +02:00
|
|
|
if (!SetFileTime(handle, &ftLocal, 0, &ftLocal))
|
2005-06-17 22:56:55 +02:00
|
|
|
return -1;
|
2005-10-28 12:40:54 +02:00
|
|
|
CloseHandle(handle);
|
2005-06-17 22:56:55 +02:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* extract_cabinet_file
|
|
|
|
*
|
|
|
|
* Extract files from a cab file.
|
|
|
|
*/
|
2005-06-24 14:14:35 +02:00
|
|
|
static BOOL extract_cabinet_file(MSIPACKAGE* package, LPCWSTR source,
|
|
|
|
LPCWSTR path)
|
2005-06-17 22:56:55 +02:00
|
|
|
{
|
|
|
|
HFDI hfdi;
|
|
|
|
ERF erf;
|
|
|
|
BOOL ret;
|
|
|
|
char *cabinet;
|
|
|
|
char *cab_path;
|
|
|
|
CabData data;
|
|
|
|
|
2005-06-24 14:14:35 +02:00
|
|
|
TRACE("Extracting %s to %s\n",debugstr_w(source), debugstr_w(path));
|
2005-06-17 22:56:55 +02:00
|
|
|
|
|
|
|
hfdi = FDICreate(cabinet_alloc,
|
|
|
|
cabinet_free,
|
|
|
|
cabinet_open,
|
|
|
|
cabinet_read,
|
|
|
|
cabinet_write,
|
|
|
|
cabinet_close,
|
|
|
|
cabinet_seek,
|
|
|
|
0,
|
|
|
|
&erf);
|
|
|
|
if (!hfdi)
|
|
|
|
{
|
|
|
|
ERR("FDICreate failed\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(cabinet = strdupWtoA( source )))
|
|
|
|
{
|
|
|
|
FDIDestroy(hfdi);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (!(cab_path = strdupWtoA( path )))
|
|
|
|
{
|
|
|
|
FDIDestroy(hfdi);
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free(cabinet);
|
2005-06-17 22:56:55 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
data.package = package;
|
|
|
|
data.cab_path = cab_path;
|
|
|
|
|
|
|
|
ret = FDICopy(hfdi, cabinet, "", 0, cabinet_notify, NULL, &data);
|
|
|
|
|
|
|
|
if (!ret)
|
|
|
|
ERR("FDICopy failed\n");
|
|
|
|
|
|
|
|
FDIDestroy(hfdi);
|
|
|
|
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free(cabinet);
|
|
|
|
msi_free(cab_path);
|
2005-06-17 22:56:55 +02:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2005-06-24 14:14:35 +02:00
|
|
|
static VOID set_file_source(MSIPACKAGE* package, MSIFILE* file, MSICOMPONENT*
|
|
|
|
comp, LPCWSTR path)
|
|
|
|
{
|
|
|
|
if (file->Attributes & msidbFileAttributesNoncompressed)
|
|
|
|
{
|
|
|
|
LPWSTR p;
|
|
|
|
p = resolve_folder(package, comp->Directory, TRUE, FALSE, NULL);
|
|
|
|
file->SourcePath = build_directory_name(2, p, file->ShortName);
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free(p);
|
2005-06-24 14:14:35 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
file->SourcePath = build_directory_name(2, path, file->File);
|
|
|
|
}
|
|
|
|
|
2005-07-05 23:00:06 +02:00
|
|
|
static BOOL check_volume(LPCWSTR path, LPCWSTR want_volume, LPWSTR volume,
|
|
|
|
UINT *intype)
|
2005-06-29 21:19:09 +02:00
|
|
|
{
|
|
|
|
WCHAR drive[4];
|
|
|
|
WCHAR name[MAX_PATH];
|
|
|
|
UINT type;
|
|
|
|
|
|
|
|
if (!(path[0] && path[1] == ':'))
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
drive[0] = path[0];
|
|
|
|
drive[1] = path[1];
|
|
|
|
drive[2] = '\\';
|
|
|
|
drive[3] = 0;
|
|
|
|
TRACE("Checking volume %s .. (%s)\n",debugstr_w(drive), debugstr_w(want_volume));
|
|
|
|
type = GetDriveTypeW(drive);
|
|
|
|
TRACE("drive is of type %x\n",type);
|
|
|
|
|
|
|
|
if (type == DRIVE_UNKNOWN || type == DRIVE_NO_ROOT_DIR ||
|
|
|
|
type == DRIVE_FIXED || type == DRIVE_RAMDISK)
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
GetVolumeInformationW(drive, name, MAX_PATH, NULL, NULL, NULL, NULL, 0);
|
|
|
|
TRACE("Drive contains %s\n", debugstr_w(name));
|
|
|
|
volume = strdupW(name);
|
2005-07-05 23:00:06 +02:00
|
|
|
if (*intype)
|
|
|
|
*intype=type;
|
2005-06-29 21:19:09 +02:00
|
|
|
return (strcmpiW(want_volume,name)==0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL check_for_sourcefile(LPCWSTR source)
|
|
|
|
{
|
|
|
|
DWORD attrib = GetFileAttributesW(source);
|
|
|
|
return (!(attrib == INVALID_FILE_ATTRIBUTES));
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT ready_volume(MSIPACKAGE* package, LPCWSTR path, LPWSTR last_volume,
|
2005-07-05 23:00:06 +02:00
|
|
|
MSIRECORD *row,UINT *type )
|
2005-06-29 21:19:09 +02:00
|
|
|
{
|
|
|
|
LPWSTR volume = NULL;
|
|
|
|
LPCWSTR want_volume = MSI_RecordGetString(row, 5);
|
2005-07-05 23:00:06 +02:00
|
|
|
BOOL ok = check_volume(path, want_volume, volume, type);
|
2005-06-29 21:19:09 +02:00
|
|
|
|
2005-10-29 12:31:06 +02:00
|
|
|
TRACE("Readying Volume for %s (%s, %s)\n", debugstr_w(path),
|
|
|
|
debugstr_w(want_volume), debugstr_w(last_volume));
|
2005-06-29 21:19:09 +02:00
|
|
|
|
|
|
|
if (check_for_sourcefile(path) && !ok)
|
|
|
|
{
|
|
|
|
FIXME("Found the Sourcefile but not on the correct volume.(%s,%s,%s)\n",
|
|
|
|
debugstr_w(path),debugstr_w(want_volume), debugstr_w(volume));
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (!ok)
|
|
|
|
{
|
|
|
|
INT rc;
|
|
|
|
LPCWSTR prompt;
|
|
|
|
LPWSTR msg;
|
|
|
|
|
|
|
|
prompt = MSI_RecordGetString(row,3);
|
|
|
|
msg = generate_error_string(package, 1302, 1, prompt);
|
|
|
|
rc = MessageBoxW(NULL,msg,NULL,MB_OKCANCEL);
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free(volume);
|
|
|
|
msi_free(msg);
|
2005-06-29 21:19:09 +02:00
|
|
|
if (rc == IDOK)
|
|
|
|
ok = check_for_sourcefile(path);
|
|
|
|
else
|
|
|
|
return ERROR_INSTALL_USEREXIT;
|
|
|
|
}
|
|
|
|
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free(last_volume);
|
2005-06-29 21:19:09 +02:00
|
|
|
last_volume = strdupW(volume);
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2005-09-23 12:05:08 +02:00
|
|
|
struct media_info {
|
|
|
|
UINT last_sequence;
|
|
|
|
LPWSTR last_volume;
|
|
|
|
LPWSTR last_path;
|
|
|
|
DWORD count;
|
|
|
|
WCHAR source[MAX_PATH];
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct media_info *create_media_info( void )
|
|
|
|
{
|
|
|
|
struct media_info *mi;
|
|
|
|
|
|
|
|
mi = msi_alloc( sizeof *mi );
|
|
|
|
if (mi)
|
|
|
|
{
|
|
|
|
mi->last_sequence = 0;
|
|
|
|
mi->last_volume = NULL;
|
|
|
|
mi->last_path = NULL;
|
|
|
|
mi->count = 0;
|
|
|
|
mi->source[0] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return mi;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void free_media_info( struct media_info *mi )
|
|
|
|
{
|
2005-09-25 17:14:16 +02:00
|
|
|
msi_free( mi->last_path );
|
2005-09-23 12:05:08 +02:00
|
|
|
msi_free( mi );
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT ready_media_for_file( MSIPACKAGE *package, struct media_info *mi,
|
2005-10-28 11:39:29 +02:00
|
|
|
MSIFILE *file )
|
2005-06-17 22:56:55 +02:00
|
|
|
{
|
|
|
|
UINT rc = ERROR_SUCCESS;
|
|
|
|
MSIRECORD * row = 0;
|
|
|
|
static const WCHAR ExecSeqQuery[] =
|
|
|
|
{'S','E','L','E','C','T',' ','*',' ', 'F','R','O','M',' ',
|
|
|
|
'`','M','e','d','i','a','`',' ','W','H','E','R','E',' ',
|
|
|
|
'`','L','a','s','t','S','e','q','u','e','n','c','e','`',' ','>','=',
|
|
|
|
' ','%', 'i',' ','O','R','D','E','R',' ','B','Y',' ',
|
|
|
|
'`','L','a','s','t','S','e','q','u','e','n','c','e','`',0};
|
2005-06-29 21:19:09 +02:00
|
|
|
LPCWSTR cab, volume;
|
2005-06-17 22:56:55 +02:00
|
|
|
DWORD sz;
|
|
|
|
INT seq;
|
2005-07-05 23:00:06 +02:00
|
|
|
UINT type;
|
|
|
|
LPCWSTR prompt;
|
2005-10-28 11:39:29 +02:00
|
|
|
MSICOMPONENT *comp = file->Component;
|
2005-06-17 22:56:55 +02:00
|
|
|
|
2005-09-23 12:05:08 +02:00
|
|
|
if (file->Sequence <= mi->last_sequence)
|
2005-06-17 22:56:55 +02:00
|
|
|
{
|
2005-09-23 12:05:08 +02:00
|
|
|
set_file_source(package,file,comp,mi->last_path);
|
|
|
|
TRACE("Media already ready (%u, %u)\n",file->Sequence,mi->last_sequence);
|
2005-06-17 22:56:55 +02:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2005-09-23 12:05:08 +02:00
|
|
|
mi->count ++;
|
2005-06-17 22:56:55 +02:00
|
|
|
row = MSI_QueryGetRecord(package->db, ExecSeqQuery, file->Sequence);
|
|
|
|
if (!row)
|
2005-06-24 14:14:35 +02:00
|
|
|
{
|
|
|
|
TRACE("Unable to query row\n");
|
2005-06-17 22:56:55 +02:00
|
|
|
return ERROR_FUNCTION_FAILED;
|
2005-06-24 14:14:35 +02:00
|
|
|
}
|
2005-06-17 22:56:55 +02:00
|
|
|
|
|
|
|
seq = MSI_RecordGetInteger(row,2);
|
2005-09-23 12:05:08 +02:00
|
|
|
mi->last_sequence = seq;
|
2005-06-17 22:56:55 +02:00
|
|
|
|
2005-06-29 21:19:09 +02:00
|
|
|
volume = MSI_RecordGetString(row, 5);
|
2005-07-05 23:00:06 +02:00
|
|
|
prompt = MSI_RecordGetString(row, 3);
|
2005-06-29 21:19:09 +02:00
|
|
|
|
2005-09-23 12:05:08 +02:00
|
|
|
msi_free(mi->last_path);
|
|
|
|
mi->last_path = NULL;
|
2005-06-24 14:14:35 +02:00
|
|
|
|
|
|
|
if (file->Attributes & msidbFileAttributesNoncompressed)
|
|
|
|
{
|
2005-09-23 12:05:08 +02:00
|
|
|
mi->last_path = resolve_folder(package, comp->Directory, TRUE, FALSE, NULL);
|
|
|
|
set_file_source(package,file,comp,mi->last_path);
|
|
|
|
rc = ready_volume(package, file->SourcePath, mi->last_volume, row,&type);
|
2005-07-05 23:00:06 +02:00
|
|
|
|
|
|
|
MsiSourceListAddMediaDiskW(package->ProductCode, NULL,
|
2005-09-23 12:05:08 +02:00
|
|
|
MSIINSTALLCONTEXT_USERMANAGED, MSICODE_PRODUCT, mi->count, volume,
|
2005-07-05 23:00:06 +02:00
|
|
|
prompt);
|
|
|
|
|
|
|
|
if (type == DRIVE_REMOVABLE || type == DRIVE_CDROM ||
|
|
|
|
type == DRIVE_RAMDISK)
|
|
|
|
MsiSourceListSetInfoW(package->ProductCode, NULL,
|
|
|
|
MSIINSTALLCONTEXT_USERMANAGED,
|
|
|
|
MSICODE_PRODUCT|MSISOURCETYPE_MEDIA,
|
2005-09-23 12:05:08 +02:00
|
|
|
INSTALLPROPERTY_LASTUSEDSOURCEW, mi->last_path);
|
2005-07-05 23:00:06 +02:00
|
|
|
else
|
|
|
|
MsiSourceListSetInfoW(package->ProductCode, NULL,
|
|
|
|
MSIINSTALLCONTEXT_USERMANAGED,
|
|
|
|
MSICODE_PRODUCT|MSISOURCETYPE_NETWORK,
|
2005-09-23 12:05:08 +02:00
|
|
|
INSTALLPROPERTY_LASTUSEDSOURCEW, mi->last_path);
|
2005-06-24 14:14:35 +02:00
|
|
|
msiobj_release(&row->hdr);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2005-06-17 22:56:55 +02:00
|
|
|
cab = MSI_RecordGetString(row,4);
|
|
|
|
if (cab)
|
|
|
|
{
|
|
|
|
TRACE("Source is CAB %s\n",debugstr_w(cab));
|
|
|
|
/* the stream does not contain the # character */
|
|
|
|
if (cab[0]=='#')
|
|
|
|
{
|
2005-07-05 23:00:06 +02:00
|
|
|
LPWSTR path;
|
|
|
|
|
2005-09-23 12:05:08 +02:00
|
|
|
writeout_cabinet_stream(package,&cab[1],mi->source);
|
|
|
|
mi->last_path = strdupW(mi->source);
|
|
|
|
*(strrchrW(mi->last_path,'\\')+1)=0;
|
2005-07-05 23:00:06 +02:00
|
|
|
|
2005-09-15 17:04:08 +02:00
|
|
|
path = msi_dup_property( package, cszSourceDir );
|
2005-07-05 23:00:06 +02:00
|
|
|
|
|
|
|
MsiSourceListAddMediaDiskW(package->ProductCode, NULL,
|
2005-09-23 12:05:08 +02:00
|
|
|
MSIINSTALLCONTEXT_USERMANAGED, MSICODE_PRODUCT, mi->count,
|
2005-07-05 23:00:06 +02:00
|
|
|
volume, prompt);
|
|
|
|
|
|
|
|
MsiSourceListSetInfoW(package->ProductCode, NULL,
|
|
|
|
MSIINSTALLCONTEXT_USERMANAGED,
|
|
|
|
MSICODE_PRODUCT|MSISOURCETYPE_NETWORK,
|
2005-07-13 14:07:41 +02:00
|
|
|
INSTALLPROPERTY_LASTUSEDSOURCEW, path);
|
2005-07-05 23:00:06 +02:00
|
|
|
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free(path);
|
2005-06-17 22:56:55 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sz = MAX_PATH;
|
2005-09-23 12:05:08 +02:00
|
|
|
mi->last_path = msi_alloc(MAX_PATH*sizeof(WCHAR));
|
|
|
|
if (MSI_GetPropertyW(package, cszSourceDir, mi->source, &sz))
|
2005-06-17 22:56:55 +02:00
|
|
|
{
|
2005-11-10 13:14:56 +01:00
|
|
|
ERR("No Source dir defined\n");
|
2005-06-17 22:56:55 +02:00
|
|
|
rc = ERROR_FUNCTION_FAILED;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-09-23 12:05:08 +02:00
|
|
|
strcpyW(mi->last_path,mi->source);
|
|
|
|
strcatW(mi->source,cab);
|
2005-07-05 23:00:06 +02:00
|
|
|
|
2005-09-23 12:05:08 +02:00
|
|
|
rc = ready_volume(package, mi->source, mi->last_volume, row, &type);
|
2005-07-05 23:00:06 +02:00
|
|
|
if (type == DRIVE_REMOVABLE || type == DRIVE_CDROM ||
|
|
|
|
type == DRIVE_RAMDISK)
|
|
|
|
MsiSourceListSetInfoW(package->ProductCode, NULL,
|
|
|
|
MSIINSTALLCONTEXT_USERMANAGED,
|
|
|
|
MSICODE_PRODUCT|MSISOURCETYPE_MEDIA,
|
2005-09-23 12:05:08 +02:00
|
|
|
INSTALLPROPERTY_LASTUSEDSOURCEW, mi->last_path);
|
2005-07-05 23:00:06 +02:00
|
|
|
else
|
|
|
|
MsiSourceListSetInfoW(package->ProductCode, NULL,
|
|
|
|
MSIINSTALLCONTEXT_USERMANAGED,
|
|
|
|
MSICODE_PRODUCT|MSISOURCETYPE_NETWORK,
|
2005-09-23 12:05:08 +02:00
|
|
|
INSTALLPROPERTY_LASTUSEDSOURCEW, mi->last_path);
|
2005-07-05 23:00:06 +02:00
|
|
|
|
2005-06-17 22:56:55 +02:00
|
|
|
/* extract the cab file into a folder in the temp folder */
|
|
|
|
sz = MAX_PATH;
|
2005-09-23 12:05:08 +02:00
|
|
|
if (MSI_GetPropertyW(package, cszTempFolder,mi->last_path, &sz)
|
2005-06-17 22:56:55 +02:00
|
|
|
!= ERROR_SUCCESS)
|
2005-09-23 12:05:08 +02:00
|
|
|
GetTempPathW(MAX_PATH,mi->last_path);
|
2005-06-17 22:56:55 +02:00
|
|
|
}
|
|
|
|
}
|
2005-09-23 12:05:08 +02:00
|
|
|
rc = !extract_cabinet_file(package, mi->source, mi->last_path);
|
2005-06-17 22:56:55 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sz = MAX_PATH;
|
2005-09-23 12:05:08 +02:00
|
|
|
mi->last_path = msi_alloc(MAX_PATH*sizeof(WCHAR));
|
|
|
|
MSI_GetPropertyW(package,cszSourceDir,mi->source,&sz);
|
|
|
|
strcpyW(mi->last_path,mi->source);
|
|
|
|
rc = ready_volume(package, mi->last_path, mi->last_volume, row, &type);
|
2005-07-05 23:00:06 +02:00
|
|
|
|
|
|
|
if (type == DRIVE_REMOVABLE || type == DRIVE_CDROM ||
|
|
|
|
type == DRIVE_RAMDISK)
|
|
|
|
MsiSourceListSetInfoW(package->ProductCode, NULL,
|
|
|
|
MSIINSTALLCONTEXT_USERMANAGED,
|
|
|
|
MSICODE_PRODUCT|MSISOURCETYPE_MEDIA,
|
2005-09-23 12:05:08 +02:00
|
|
|
INSTALLPROPERTY_LASTUSEDSOURCEW, mi->last_path);
|
2005-07-05 23:00:06 +02:00
|
|
|
else
|
|
|
|
MsiSourceListSetInfoW(package->ProductCode, NULL,
|
|
|
|
MSIINSTALLCONTEXT_USERMANAGED,
|
|
|
|
MSICODE_PRODUCT|MSISOURCETYPE_NETWORK,
|
2005-09-23 12:05:08 +02:00
|
|
|
INSTALLPROPERTY_LASTUSEDSOURCEW, mi->last_path);
|
2005-06-17 22:56:55 +02:00
|
|
|
}
|
2005-09-23 12:05:08 +02:00
|
|
|
set_file_source(package, file, comp, mi->last_path);
|
2005-07-05 23:00:06 +02:00
|
|
|
|
|
|
|
MsiSourceListAddMediaDiskW(package->ProductCode, NULL,
|
2005-09-23 12:05:08 +02:00
|
|
|
MSIINSTALLCONTEXT_USERMANAGED, MSICODE_PRODUCT, mi->count, volume,
|
2005-07-05 23:00:06 +02:00
|
|
|
prompt);
|
|
|
|
|
2005-06-17 22:56:55 +02:00
|
|
|
msiobj_release(&row->hdr);
|
2005-06-24 14:14:35 +02:00
|
|
|
|
2005-06-17 22:56:55 +02:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2005-08-23 12:03:17 +02:00
|
|
|
static UINT get_file_target(MSIPACKAGE *package, LPCWSTR file_key,
|
2006-01-23 17:29:50 +01:00
|
|
|
MSIFILE** file)
|
2005-06-17 22:56:55 +02:00
|
|
|
{
|
2006-01-23 17:29:50 +01:00
|
|
|
LIST_FOR_EACH_ENTRY( *file, &package->files, MSIFILE, entry )
|
2005-06-17 22:56:55 +02:00
|
|
|
{
|
2006-01-23 17:29:50 +01:00
|
|
|
if (lstrcmpW( file_key, (*file)->File )==0)
|
2005-06-17 22:56:55 +02:00
|
|
|
{
|
2006-01-23 17:29:50 +01:00
|
|
|
if ((*file)->state >= msifs_overwrite)
|
2005-06-17 22:56:55 +02:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
else
|
|
|
|
return ERROR_FILE_NOT_FOUND;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
|
|
|
}
|
|
|
|
|
2005-06-24 14:14:35 +02:00
|
|
|
/*
|
2005-11-02 11:56:42 +01:00
|
|
|
* ACTION_InstallFiles()
|
|
|
|
*
|
|
|
|
* For efficiency, this is done in two passes:
|
|
|
|
* 1) Correct all the TargetPaths and determine what files are to be installed.
|
|
|
|
* 2) Extract Cabinets and copy files.
|
2005-06-24 14:14:35 +02:00
|
|
|
*/
|
2005-06-17 22:56:55 +02:00
|
|
|
UINT ACTION_InstallFiles(MSIPACKAGE *package)
|
|
|
|
{
|
2005-09-23 12:05:08 +02:00
|
|
|
struct media_info *mi;
|
2005-06-17 22:56:55 +02:00
|
|
|
UINT rc = ERROR_SUCCESS;
|
2005-07-05 23:00:06 +02:00
|
|
|
LPWSTR ptr;
|
2005-08-23 12:03:17 +02:00
|
|
|
MSIFILE *file;
|
2005-06-17 22:56:55 +02:00
|
|
|
|
|
|
|
/* increment progress bar each time action data is sent */
|
|
|
|
ui_progress(package,1,1,0,0);
|
|
|
|
|
2005-11-02 11:56:42 +01:00
|
|
|
/* handle the keys for the SourceList */
|
2005-07-05 23:00:06 +02:00
|
|
|
ptr = strrchrW(package->PackagePath,'\\');
|
|
|
|
if (ptr)
|
|
|
|
{
|
|
|
|
ptr ++;
|
|
|
|
MsiSourceListSetInfoW(package->ProductCode, NULL,
|
|
|
|
MSIINSTALLCONTEXT_USERMANAGED,
|
|
|
|
MSICODE_PRODUCT,
|
2005-07-13 14:07:41 +02:00
|
|
|
INSTALLPROPERTY_PACKAGENAMEW, ptr);
|
2005-07-05 23:00:06 +02:00
|
|
|
}
|
2005-10-29 12:31:06 +02:00
|
|
|
/* FIXME("Write DiskPrompt\n"); */
|
2005-07-05 23:00:06 +02:00
|
|
|
|
2005-06-24 14:14:35 +02:00
|
|
|
/* Pass 1 */
|
2005-08-23 12:03:17 +02:00
|
|
|
LIST_FOR_EACH_ENTRY( file, &package->files, MSIFILE, entry )
|
2005-06-17 22:56:55 +02:00
|
|
|
{
|
2005-10-29 13:36:48 +02:00
|
|
|
if (!ACTION_VerifyComponentForAction( file->Component, INSTALLSTATE_LOCAL ))
|
2005-06-17 22:56:55 +02:00
|
|
|
{
|
|
|
|
ui_progress(package,2,file->FileSize,0,0);
|
|
|
|
TRACE("File %s is not scheduled for install\n",
|
|
|
|
debugstr_w(file->File));
|
|
|
|
|
2005-11-02 11:56:42 +01:00
|
|
|
file->state = msifs_skipped;
|
2005-06-24 14:14:35 +02:00
|
|
|
}
|
|
|
|
}
|
2005-06-17 22:56:55 +02:00
|
|
|
|
2005-10-29 13:29:17 +02:00
|
|
|
/*
|
|
|
|
* Despite MSDN specifying that the CreateFolders action
|
|
|
|
* should be called before InstallFiles, some installers don't
|
|
|
|
* do that, and they seem to work correctly. We need to create
|
|
|
|
* directories here to make sure that the files can be copied.
|
|
|
|
*/
|
|
|
|
msi_create_component_directories( package );
|
|
|
|
|
2005-09-23 12:05:08 +02:00
|
|
|
mi = create_media_info();
|
|
|
|
|
2005-06-24 14:14:35 +02:00
|
|
|
/* Pass 2 */
|
2005-08-23 12:03:17 +02:00
|
|
|
LIST_FOR_EACH_ENTRY( file, &package->files, MSIFILE, entry )
|
2005-06-24 14:14:35 +02:00
|
|
|
{
|
2005-11-02 11:56:42 +01:00
|
|
|
if (file->state != msifs_missing && file->state != msifs_overwrite)
|
2005-10-29 12:31:06 +02:00
|
|
|
continue;
|
|
|
|
|
|
|
|
TRACE("Pass 2: %s\n",debugstr_w(file->File));
|
|
|
|
|
|
|
|
rc = ready_media_for_file( package, mi, file );
|
|
|
|
if (rc != ERROR_SUCCESS)
|
2005-06-24 14:14:35 +02:00
|
|
|
{
|
2005-10-29 12:31:06 +02:00
|
|
|
ERR("Unable to ready media\n");
|
|
|
|
rc = ERROR_FUNCTION_FAILED;
|
|
|
|
break;
|
|
|
|
}
|
2005-06-24 14:14:35 +02:00
|
|
|
|
2005-10-29 12:31:06 +02:00
|
|
|
TRACE("file paths %s to %s\n",debugstr_w(file->SourcePath),
|
|
|
|
debugstr_w(file->TargetPath));
|
2005-06-17 22:56:55 +02:00
|
|
|
|
2005-11-02 11:56:42 +01:00
|
|
|
if (file->state != msifs_missing && file->state != msifs_overwrite)
|
2005-10-29 12:31:06 +02:00
|
|
|
continue;
|
2005-06-17 22:56:55 +02:00
|
|
|
|
2005-10-29 12:31:06 +02:00
|
|
|
/* compressed files are extracted in ready_media_for_file */
|
|
|
|
if (~file->Attributes & msidbFileAttributesNoncompressed)
|
|
|
|
{
|
|
|
|
if (INVALID_FILE_ATTRIBUTES == GetFileAttributesW(file->TargetPath))
|
|
|
|
ERR("compressed file wasn't extracted (%s)\n",
|
|
|
|
debugstr_w(file->TargetPath));
|
|
|
|
continue;
|
|
|
|
}
|
2005-06-17 22:56:55 +02:00
|
|
|
|
2005-10-29 12:31:06 +02:00
|
|
|
rc = CopyFileW(file->SourcePath,file->TargetPath,FALSE);
|
|
|
|
if (!rc)
|
|
|
|
{
|
|
|
|
rc = GetLastError();
|
|
|
|
ERR("Unable to copy file (%s -> %s) (error %d)\n",
|
|
|
|
debugstr_w(file->SourcePath), debugstr_w(file->TargetPath), rc);
|
2005-11-02 11:56:42 +01:00
|
|
|
if (rc == ERROR_ALREADY_EXISTS && file->state == msifs_overwrite)
|
2005-06-17 22:56:55 +02:00
|
|
|
{
|
2005-10-29 12:31:06 +02:00
|
|
|
rc = 0;
|
2005-06-17 22:56:55 +02:00
|
|
|
}
|
2005-10-29 12:31:06 +02:00
|
|
|
else if (rc == ERROR_FILE_NOT_FOUND)
|
|
|
|
{
|
|
|
|
ERR("Source File Not Found! Continuing\n");
|
|
|
|
rc = 0;
|
|
|
|
}
|
|
|
|
else if (file->Attributes & msidbFileAttributesVital)
|
2005-06-17 22:56:55 +02:00
|
|
|
{
|
2005-10-29 12:31:06 +02:00
|
|
|
ERR("Ignoring Error and continuing (nonvital file)...\n");
|
|
|
|
rc = 0;
|
2005-06-17 22:56:55 +02:00
|
|
|
}
|
|
|
|
}
|
2005-10-29 12:31:06 +02:00
|
|
|
else
|
|
|
|
{
|
2005-11-02 11:56:42 +01:00
|
|
|
file->state = msifs_installed;
|
2005-10-29 12:31:06 +02:00
|
|
|
rc = ERROR_SUCCESS;
|
|
|
|
}
|
2005-06-17 22:56:55 +02:00
|
|
|
}
|
|
|
|
|
2005-06-24 14:14:35 +02:00
|
|
|
/* cleanup */
|
2005-09-23 12:05:08 +02:00
|
|
|
free_media_info( mi );
|
2005-06-17 22:56:55 +02:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2005-06-20 17:33:22 +02:00
|
|
|
static UINT ITERATE_DuplicateFiles(MSIRECORD *row, LPVOID param)
|
2005-06-17 22:56:55 +02:00
|
|
|
{
|
2005-06-20 17:33:22 +02:00
|
|
|
MSIPACKAGE *package = (MSIPACKAGE*)param;
|
|
|
|
WCHAR dest_name[0x100];
|
|
|
|
LPWSTR dest_path, dest;
|
|
|
|
LPCWSTR file_key, component;
|
|
|
|
DWORD sz;
|
|
|
|
DWORD rc;
|
2005-08-22 11:15:23 +02:00
|
|
|
MSICOMPONENT *comp;
|
2006-01-23 17:29:50 +01:00
|
|
|
MSIFILE *file;
|
2005-06-17 22:56:55 +02:00
|
|
|
|
2005-06-20 17:33:22 +02:00
|
|
|
component = MSI_RecordGetString(row,2);
|
2005-08-22 11:15:23 +02:00
|
|
|
comp = get_loaded_component(package,component);
|
2005-06-20 17:33:22 +02:00
|
|
|
|
2005-10-29 13:36:48 +02:00
|
|
|
if (!ACTION_VerifyComponentForAction( comp, INSTALLSTATE_LOCAL ))
|
2005-06-20 17:33:22 +02:00
|
|
|
{
|
|
|
|
TRACE("Skipping copy due to disabled component %s\n",
|
|
|
|
debugstr_w(component));
|
|
|
|
|
|
|
|
/* the action taken was the same as the current install state */
|
2005-08-22 11:15:23 +02:00
|
|
|
comp->Action = comp->Installed;
|
2005-06-17 22:56:55 +02:00
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
2005-06-20 17:33:22 +02:00
|
|
|
}
|
2005-06-17 22:56:55 +02:00
|
|
|
|
2005-08-22 11:15:23 +02:00
|
|
|
comp->Action = INSTALLSTATE_LOCAL;
|
2005-06-20 17:33:22 +02:00
|
|
|
|
|
|
|
file_key = MSI_RecordGetString(row,3);
|
|
|
|
if (!file_key)
|
2005-06-17 22:56:55 +02:00
|
|
|
{
|
2005-06-20 17:33:22 +02:00
|
|
|
ERR("Unable to get file key\n");
|
|
|
|
return ERROR_FUNCTION_FAILED;
|
2005-06-17 22:56:55 +02:00
|
|
|
}
|
|
|
|
|
2006-01-23 17:29:50 +01:00
|
|
|
rc = get_file_target(package,file_key,&file);
|
2005-06-20 17:33:22 +02:00
|
|
|
|
|
|
|
if (rc != ERROR_SUCCESS)
|
2005-06-17 22:56:55 +02:00
|
|
|
{
|
2005-06-20 17:33:22 +02:00
|
|
|
ERR("Original file unknown %s\n",debugstr_w(file_key));
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
2005-06-17 22:56:55 +02:00
|
|
|
|
2005-06-20 17:33:22 +02:00
|
|
|
if (MSI_RecordIsNull(row,4))
|
2006-01-23 17:29:50 +01:00
|
|
|
strcpyW(dest_name,strrchrW(file->TargetPath,'\\')+1);
|
2005-06-20 17:33:22 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
sz=0x100;
|
|
|
|
MSI_RecordGetStringW(row,4,dest_name,&sz);
|
|
|
|
reduce_to_longfilename(dest_name);
|
2005-06-24 14:14:35 +02:00
|
|
|
}
|
2005-06-17 22:56:55 +02:00
|
|
|
|
2005-06-20 17:33:22 +02:00
|
|
|
if (MSI_RecordIsNull(row,5))
|
|
|
|
{
|
|
|
|
LPWSTR p;
|
2006-01-23 17:29:50 +01:00
|
|
|
dest_path = strdupW(file->TargetPath);
|
2005-06-20 17:33:22 +02:00
|
|
|
p = strrchrW(dest_path,'\\');
|
|
|
|
if (p)
|
|
|
|
*p=0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
LPCWSTR destkey;
|
|
|
|
destkey = MSI_RecordGetString(row,5);
|
|
|
|
dest_path = resolve_folder(package, destkey, FALSE,FALSE,NULL);
|
|
|
|
if (!dest_path)
|
2005-06-17 22:56:55 +02:00
|
|
|
{
|
2005-06-21 22:03:30 +02:00
|
|
|
/* try a Property */
|
2005-09-15 17:04:08 +02:00
|
|
|
dest_path = msi_dup_property( package, destkey );
|
2005-06-21 22:03:30 +02:00
|
|
|
if (!dest_path)
|
|
|
|
{
|
|
|
|
FIXME("Unable to get destination folder, try AppSearch properties\n");
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
2005-06-17 22:56:55 +02:00
|
|
|
}
|
2005-06-20 17:33:22 +02:00
|
|
|
}
|
2005-06-17 22:56:55 +02:00
|
|
|
|
2005-06-20 17:33:22 +02:00
|
|
|
dest = build_directory_name(2, dest_path, dest_name);
|
2005-06-24 14:14:35 +02:00
|
|
|
|
2006-01-23 17:29:50 +01:00
|
|
|
TRACE("Duplicating file %s to %s\n",debugstr_w(file->TargetPath),
|
2005-06-24 14:14:35 +02:00
|
|
|
debugstr_w(dest));
|
|
|
|
|
2006-01-23 17:29:50 +01:00
|
|
|
if (strcmpW(file->TargetPath,dest))
|
|
|
|
rc = !CopyFileW(file->TargetPath,dest,TRUE);
|
2005-06-20 17:33:22 +02:00
|
|
|
else
|
|
|
|
rc = ERROR_SUCCESS;
|
2005-06-24 14:14:35 +02:00
|
|
|
|
2005-06-20 17:33:22 +02:00
|
|
|
if (rc != ERROR_SUCCESS)
|
2005-10-29 13:36:48 +02:00
|
|
|
ERR("Failed to copy file %s -> %s, last error %ld\n",
|
2006-01-23 17:29:50 +01:00
|
|
|
debugstr_w(file->TargetPath), debugstr_w(dest_path), GetLastError());
|
2005-06-17 22:56:55 +02:00
|
|
|
|
2005-06-20 17:33:22 +02:00
|
|
|
FIXME("We should track these duplicate files as well\n");
|
2005-06-17 22:56:55 +02:00
|
|
|
|
2005-09-20 13:59:14 +02:00
|
|
|
msi_free(dest_path);
|
|
|
|
msi_free(dest);
|
2006-01-23 17:29:50 +01:00
|
|
|
|
|
|
|
msi_file_update_ui(package, file, szDuplicateFiles);
|
2005-06-17 22:56:55 +02:00
|
|
|
|
2005-06-20 17:33:22 +02:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
2005-06-17 22:56:55 +02:00
|
|
|
|
2005-06-20 17:33:22 +02:00
|
|
|
UINT ACTION_DuplicateFiles(MSIPACKAGE *package)
|
|
|
|
{
|
|
|
|
UINT rc;
|
|
|
|
MSIQUERY * view;
|
|
|
|
static const WCHAR ExecSeqQuery[] =
|
|
|
|
{'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
|
|
|
|
'`','D','u','p','l','i','c','a','t','e','F','i','l','e','`',0};
|
2005-06-17 22:56:55 +02:00
|
|
|
|
2005-06-20 17:33:22 +02:00
|
|
|
rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view);
|
|
|
|
if (rc != ERROR_SUCCESS)
|
|
|
|
return ERROR_SUCCESS;
|
2005-06-17 22:56:55 +02:00
|
|
|
|
2005-06-20 17:33:22 +02:00
|
|
|
rc = MSI_IterateRecords(view, NULL, ITERATE_DuplicateFiles, package);
|
2005-06-17 22:56:55 +02:00
|
|
|
msiobj_release(&view->hdr);
|
2005-06-20 17:33:22 +02:00
|
|
|
|
2005-06-17 22:56:55 +02:00
|
|
|
return rc;
|
|
|
|
}
|
2005-11-02 12:42:56 +01:00
|
|
|
|
|
|
|
UINT ACTION_RemoveFiles( MSIPACKAGE *package )
|
|
|
|
{
|
|
|
|
MSIFILE *file;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY( file, &package->files, MSIFILE, entry )
|
|
|
|
{
|
2006-01-23 17:29:50 +01:00
|
|
|
MSIRECORD *uirow;
|
|
|
|
LPWSTR uipath, p;
|
|
|
|
|
2005-11-02 12:42:56 +01:00
|
|
|
if ( !file->Component )
|
|
|
|
continue;
|
|
|
|
if ( file->Component->Installed == INSTALLSTATE_LOCAL )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if ( file->state == msifs_installed )
|
|
|
|
ERR("removing installed file %s\n", debugstr_w(file->TargetPath));
|
|
|
|
|
|
|
|
if ( file->state != msifs_present )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
TRACE("removing %s\n", debugstr_w(file->File) );
|
|
|
|
if ( !DeleteFileW( file->TargetPath ) )
|
|
|
|
ERR("failed to delete %s\n", debugstr_w(file->TargetPath) );
|
|
|
|
file->state = msifs_missing;
|
2006-01-23 17:29:50 +01:00
|
|
|
|
|
|
|
/* the UI chunk */
|
|
|
|
uirow = MSI_CreateRecord( 9 );
|
|
|
|
MSI_RecordSetStringW( uirow, 1, file->FileName );
|
|
|
|
uipath = strdupW( file->TargetPath );
|
|
|
|
p = strrchrW(uipath,'\\');
|
|
|
|
if (p)
|
|
|
|
p[1]=0;
|
|
|
|
MSI_RecordSetStringW( uirow, 9, uipath);
|
|
|
|
ui_actiondata( package, szRemoveFiles, uirow);
|
|
|
|
msiobj_release( &uirow->hdr );
|
|
|
|
msi_free( uipath );
|
|
|
|
/* FIXME: call ui_progress here? */
|
2005-11-02 12:42:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|