usp10: Update tests in test_ScriptItemIzeShapePlace to match Windows results.
[wine/multimedia.git] / dlls / msi / files.c
blob22cec6d658c1610f72748bf838ed03e5352d155d
1 /*
2 * Implementation of the Microsoft Installer (msi.dll)
4 * Copyright 2005 Aric Stewart for CodeWeavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 * Actions dealing with files These are
25 * InstallFiles
26 * DuplicateFiles
27 * MoveFiles (TODO)
28 * PatchFiles (TODO)
29 * RemoveDuplicateFiles(TODO)
30 * RemoveFiles(TODO)
33 #include <stdarg.h>
35 #include "windef.h"
36 #include "winbase.h"
37 #include "winerror.h"
38 #include "wine/debug.h"
39 #include "fdi.h"
40 #include "msi.h"
41 #include "msidefs.h"
42 #include "msvcrt/fcntl.h"
43 #include "msipriv.h"
44 #include "winuser.h"
45 #include "wine/unicode.h"
46 #include "action.h"
48 WINE_DEFAULT_DEBUG_CHANNEL(msi);
50 extern const WCHAR szInstallFiles[];
51 extern const WCHAR szDuplicateFiles[];
52 extern const WCHAR szMoveFiles[];
53 extern const WCHAR szPatchFiles[];
54 extern const WCHAR szRemoveDuplicateFiles[];
55 extern const WCHAR szRemoveFiles[];
57 static const WCHAR cszTempFolder[]= {'T','e','m','p','F','o','l','d','e','r',0};
61 * This is a helper function for handling embedded cabinet media
63 static UINT writeout_cabinet_stream(MSIPACKAGE *package, LPCWSTR stream_name,
64 WCHAR* source)
66 UINT rc;
67 USHORT* data;
68 UINT size;
69 DWORD write;
70 HANDLE the_file;
71 WCHAR tmp[MAX_PATH];
73 rc = read_raw_stream_data(package->db,stream_name,&data,&size);
74 if (rc != ERROR_SUCCESS)
75 return rc;
77 write = MAX_PATH;
78 if (MSI_GetPropertyW(package, cszTempFolder, tmp, &write))
79 GetTempPathW(MAX_PATH,tmp);
81 GetTempFileNameW(tmp,stream_name,0,source);
83 track_tempfile(package,strrchrW(source,'\\'), source);
84 the_file = CreateFileW(source, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
85 FILE_ATTRIBUTE_NORMAL, NULL);
87 if (the_file == INVALID_HANDLE_VALUE)
89 ERR("Unable to create file %s\n",debugstr_w(source));
90 rc = ERROR_FUNCTION_FAILED;
91 goto end;
94 WriteFile(the_file,data,size,&write,NULL);
95 CloseHandle(the_file);
96 TRACE("wrote %li bytes to %s\n",write,debugstr_w(source));
97 end:
98 msi_free(data);
99 return rc;
103 /* Support functions for FDI functions */
104 typedef struct
106 MSIPACKAGE* package;
107 LPCSTR cab_path;
108 } CabData;
110 static void * cabinet_alloc(ULONG cb)
112 return msi_alloc(cb);
115 static void cabinet_free(void *pv)
117 msi_free(pv);
120 static INT_PTR cabinet_open(char *pszFile, int oflag, int pmode)
122 HANDLE handle;
123 DWORD dwAccess = 0;
124 DWORD dwShareMode = 0;
125 DWORD dwCreateDisposition = OPEN_EXISTING;
126 switch (oflag & _O_ACCMODE)
128 case _O_RDONLY:
129 dwAccess = GENERIC_READ;
130 dwShareMode = FILE_SHARE_READ | FILE_SHARE_DELETE;
131 break;
132 case _O_WRONLY:
133 dwAccess = GENERIC_WRITE;
134 dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE;
135 break;
136 case _O_RDWR:
137 dwAccess = GENERIC_READ | GENERIC_WRITE;
138 dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE;
139 break;
141 if ((oflag & (_O_CREAT | _O_EXCL)) == (_O_CREAT | _O_EXCL))
142 dwCreateDisposition = CREATE_NEW;
143 else if (oflag & _O_CREAT)
144 dwCreateDisposition = CREATE_ALWAYS;
145 handle = CreateFileA( pszFile, dwAccess, dwShareMode, NULL,
146 dwCreateDisposition, 0, NULL );
147 if (handle == INVALID_HANDLE_VALUE)
148 return 0;
149 return (INT_PTR) handle;
152 static UINT cabinet_read(INT_PTR hf, void *pv, UINT cb)
154 HANDLE handle = (HANDLE) hf;
155 DWORD dwRead;
156 if (ReadFile(handle, pv, cb, &dwRead, NULL))
157 return dwRead;
158 return 0;
161 static UINT cabinet_write(INT_PTR hf, void *pv, UINT cb)
163 HANDLE handle = (HANDLE) hf;
164 DWORD dwWritten;
165 if (WriteFile(handle, pv, cb, &dwWritten, NULL))
166 return dwWritten;
167 return 0;
170 static int cabinet_close(INT_PTR hf)
172 HANDLE handle = (HANDLE) hf;
173 return CloseHandle(handle) ? 0 : -1;
176 static long cabinet_seek(INT_PTR hf, long dist, int seektype)
178 HANDLE handle = (HANDLE) hf;
179 /* flags are compatible and so are passed straight through */
180 return SetFilePointer(handle, dist, NULL, seektype);
183 static void msi_file_update_ui( MSIPACKAGE *package, MSIFILE *f, const WCHAR *action )
185 MSIRECORD *uirow;
186 LPWSTR uipath, p;
188 /* the UI chunk */
189 uirow = MSI_CreateRecord( 9 );
190 MSI_RecordSetStringW( uirow, 1, f->FileName );
191 uipath = strdupW( f->TargetPath );
192 p = strrchrW(uipath,'\\');
193 if (p)
194 p[1]=0;
195 MSI_RecordSetStringW( uirow, 9, uipath);
196 MSI_RecordSetInteger( uirow, 6, f->FileSize );
197 ui_actiondata( package, action, uirow);
198 msiobj_release( &uirow->hdr );
199 msi_free( uipath );
200 ui_progress( package, 2, f->FileSize, 0, 0);
203 static INT_PTR cabinet_notify(FDINOTIFICATIONTYPE fdint, PFDINOTIFICATION pfdin)
205 switch (fdint)
207 case fdintCOPY_FILE:
209 CabData *data = (CabData*) pfdin->pv;
210 HANDLE handle;
211 LPWSTR file;
212 MSIFILE *f;
214 file = strdupAtoW(pfdin->psz1);
215 f = get_loaded_file(data->package, file);
216 msi_free(file);
218 if (!f)
220 ERR("Unknown File in Cabinet (%s)\n",debugstr_a(pfdin->psz1));
221 return 0;
224 if (f->state != msifs_missing && f->state != msifs_overwrite)
226 TRACE("Skipping extraction of %s\n",debugstr_a(pfdin->psz1));
227 return 0;
230 msi_file_update_ui( data->package, f, szInstallFiles );
232 TRACE("extracting %s\n", debugstr_w(f->TargetPath) );
234 handle = CreateFileW( f->TargetPath, GENERIC_READ | GENERIC_WRITE, 0,
235 NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL );
236 if ( handle == INVALID_HANDLE_VALUE )
238 ERR("failed to create %s (error %ld)\n",
239 debugstr_w( f->TargetPath ), GetLastError() );
240 return 0;
243 f->state = msifs_installed;
244 return (INT_PTR) handle;
246 case fdintCLOSE_FILE_INFO:
248 FILETIME ft;
249 FILETIME ftLocal;
250 HANDLE handle = (HANDLE) pfdin->hf;
252 if (!DosDateTimeToFileTime(pfdin->date, pfdin->time, &ft))
253 return -1;
254 if (!LocalFileTimeToFileTime(&ft, &ftLocal))
255 return -1;
256 if (!SetFileTime(handle, &ftLocal, 0, &ftLocal))
257 return -1;
258 CloseHandle(handle);
259 return 1;
261 default:
262 return 0;
266 /***********************************************************************
267 * extract_cabinet_file
269 * Extract files from a cab file.
271 static BOOL extract_cabinet_file(MSIPACKAGE* package, LPCWSTR source,
272 LPCWSTR path)
274 HFDI hfdi;
275 ERF erf;
276 BOOL ret;
277 char *cabinet;
278 char *cab_path;
279 CabData data;
281 TRACE("Extracting %s to %s\n",debugstr_w(source), debugstr_w(path));
283 hfdi = FDICreate(cabinet_alloc,
284 cabinet_free,
285 cabinet_open,
286 cabinet_read,
287 cabinet_write,
288 cabinet_close,
289 cabinet_seek,
291 &erf);
292 if (!hfdi)
294 ERR("FDICreate failed\n");
295 return FALSE;
298 if (!(cabinet = strdupWtoA( source )))
300 FDIDestroy(hfdi);
301 return FALSE;
303 if (!(cab_path = strdupWtoA( path )))
305 FDIDestroy(hfdi);
306 msi_free(cabinet);
307 return FALSE;
310 data.package = package;
311 data.cab_path = cab_path;
313 ret = FDICopy(hfdi, cabinet, "", 0, cabinet_notify, NULL, &data);
315 if (!ret)
316 ERR("FDICopy failed\n");
318 FDIDestroy(hfdi);
320 msi_free(cabinet);
321 msi_free(cab_path);
323 return ret;
326 static VOID set_file_source(MSIPACKAGE* package, MSIFILE* file, MSICOMPONENT*
327 comp, LPCWSTR path)
329 if (file->Attributes & msidbFileAttributesNoncompressed)
331 LPWSTR p, path;
332 p = resolve_folder(package, comp->Directory, TRUE, FALSE, NULL);
333 path = build_directory_name(2, p, file->ShortName);
334 if (INVALID_FILE_ATTRIBUTES == GetFileAttributesW( path ))
336 msi_free(path);
337 path = build_directory_name(2, p, file->LongName);
339 file->SourcePath = path;
340 msi_free(p);
342 else
343 file->SourcePath = build_directory_name(2, path, file->File);
346 struct media_info {
347 UINT last_sequence;
348 LPWSTR last_volume;
349 LPWSTR last_path;
350 DWORD count;
351 WCHAR source[MAX_PATH];
354 static struct media_info *create_media_info( void )
356 struct media_info *mi;
358 mi = msi_alloc( sizeof *mi );
359 if (mi)
361 mi->last_sequence = 0;
362 mi->last_volume = NULL;
363 mi->last_path = NULL;
364 mi->count = 0;
365 mi->source[0] = 0;
368 return mi;
371 static void free_media_info( struct media_info *mi )
373 msi_free( mi->last_path );
374 msi_free( mi );
377 static UINT ready_media_for_file( MSIPACKAGE *package, struct media_info *mi,
378 MSIFILE *file )
380 UINT rc = ERROR_SUCCESS;
381 MSIRECORD * row = 0;
382 static const WCHAR ExecSeqQuery[] =
383 {'S','E','L','E','C','T',' ','*',' ', 'F','R','O','M',' ',
384 '`','M','e','d','i','a','`',' ','W','H','E','R','E',' ',
385 '`','L','a','s','t','S','e','q','u','e','n','c','e','`',' ','>','=',
386 ' ','%', 'i',' ','O','R','D','E','R',' ','B','Y',' ',
387 '`','L','a','s','t','S','e','q','u','e','n','c','e','`',0};
388 LPCWSTR cab, volume;
389 DWORD sz;
390 INT seq;
391 LPCWSTR prompt;
392 MSICOMPONENT *comp = file->Component;
394 if (file->Sequence <= mi->last_sequence)
396 set_file_source(package,file,comp,mi->last_path);
397 TRACE("Media already ready (%u, %u)\n",file->Sequence,mi->last_sequence);
398 return ERROR_SUCCESS;
401 mi->count ++;
402 row = MSI_QueryGetRecord(package->db, ExecSeqQuery, file->Sequence);
403 if (!row)
405 TRACE("Unable to query row\n");
406 return ERROR_FUNCTION_FAILED;
409 seq = MSI_RecordGetInteger(row,2);
410 mi->last_sequence = seq;
412 volume = MSI_RecordGetString(row, 5);
413 prompt = MSI_RecordGetString(row, 3);
415 msi_free(mi->last_path);
416 mi->last_path = NULL;
418 if (file->Attributes & msidbFileAttributesNoncompressed)
420 mi->last_path = resolve_folder(package, comp->Directory, TRUE, FALSE, NULL);
421 set_file_source(package,file,comp,mi->last_path);
423 MsiSourceListAddMediaDiskW(package->ProductCode, NULL,
424 MSIINSTALLCONTEXT_USERMANAGED, MSICODE_PRODUCT, mi->count, volume,
425 prompt);
427 MsiSourceListSetInfoW(package->ProductCode, NULL,
428 MSIINSTALLCONTEXT_USERMANAGED,
429 MSICODE_PRODUCT|MSISOURCETYPE_MEDIA,
430 INSTALLPROPERTY_LASTUSEDSOURCEW, mi->last_path);
431 msiobj_release(&row->hdr);
432 return rc;
435 cab = MSI_RecordGetString(row,4);
436 if (cab)
438 TRACE("Source is CAB %s\n",debugstr_w(cab));
439 /* the stream does not contain the # character */
440 if (cab[0]=='#')
442 LPWSTR path;
444 writeout_cabinet_stream(package,&cab[1],mi->source);
445 mi->last_path = strdupW(mi->source);
446 *(strrchrW(mi->last_path,'\\')+1)=0;
448 path = msi_dup_property( package, cszSourceDir );
450 MsiSourceListAddMediaDiskW(package->ProductCode, NULL,
451 MSIINSTALLCONTEXT_USERMANAGED, MSICODE_PRODUCT, mi->count,
452 volume, prompt);
454 MsiSourceListSetInfoW(package->ProductCode, NULL,
455 MSIINSTALLCONTEXT_USERMANAGED,
456 MSICODE_PRODUCT|MSISOURCETYPE_NETWORK,
457 INSTALLPROPERTY_LASTUSEDSOURCEW, path);
459 msi_free(path);
461 else
463 sz = MAX_PATH;
464 mi->last_path = msi_alloc(MAX_PATH*sizeof(WCHAR));
465 if (MSI_GetPropertyW(package, cszSourceDir, mi->source, &sz))
467 ERR("No Source dir defined\n");
468 rc = ERROR_FUNCTION_FAILED;
470 else
472 strcpyW(mi->last_path,mi->source);
473 strcatW(mi->source,cab);
475 MsiSourceListSetInfoW(package->ProductCode, NULL,
476 MSIINSTALLCONTEXT_USERMANAGED,
477 MSICODE_PRODUCT|MSISOURCETYPE_MEDIA,
478 INSTALLPROPERTY_LASTUSEDSOURCEW, mi->last_path);
480 /* extract the cab file into a folder in the temp folder */
481 sz = MAX_PATH;
482 if (MSI_GetPropertyW(package, cszTempFolder,mi->last_path, &sz)
483 != ERROR_SUCCESS)
484 GetTempPathW(MAX_PATH,mi->last_path);
487 rc = !extract_cabinet_file(package, mi->source, mi->last_path);
489 else
491 sz = MAX_PATH;
492 mi->last_path = msi_alloc(MAX_PATH*sizeof(WCHAR));
493 MSI_GetPropertyW(package,cszSourceDir,mi->source,&sz);
494 strcpyW(mi->last_path,mi->source);
496 MsiSourceListSetInfoW(package->ProductCode, NULL,
497 MSIINSTALLCONTEXT_USERMANAGED,
498 MSICODE_PRODUCT|MSISOURCETYPE_MEDIA,
499 INSTALLPROPERTY_LASTUSEDSOURCEW, mi->last_path);
501 set_file_source(package, file, comp, mi->last_path);
503 MsiSourceListAddMediaDiskW(package->ProductCode, NULL,
504 MSIINSTALLCONTEXT_USERMANAGED, MSICODE_PRODUCT, mi->count, volume,
505 prompt);
507 msiobj_release(&row->hdr);
509 return rc;
512 static UINT get_file_target(MSIPACKAGE *package, LPCWSTR file_key,
513 MSIFILE** file)
515 LIST_FOR_EACH_ENTRY( *file, &package->files, MSIFILE, entry )
517 if (lstrcmpW( file_key, (*file)->File )==0)
519 if ((*file)->state >= msifs_overwrite)
520 return ERROR_SUCCESS;
521 else
522 return ERROR_FILE_NOT_FOUND;
526 return ERROR_FUNCTION_FAILED;
530 * ACTION_InstallFiles()
532 * For efficiency, this is done in two passes:
533 * 1) Correct all the TargetPaths and determine what files are to be installed.
534 * 2) Extract Cabinets and copy files.
536 UINT ACTION_InstallFiles(MSIPACKAGE *package)
538 struct media_info *mi;
539 UINT rc = ERROR_SUCCESS;
540 LPWSTR ptr;
541 MSIFILE *file;
543 /* increment progress bar each time action data is sent */
544 ui_progress(package,1,1,0,0);
546 /* handle the keys for the SourceList */
547 ptr = strrchrW(package->PackagePath,'\\');
548 if (ptr)
550 ptr ++;
551 MsiSourceListSetInfoW(package->ProductCode, NULL,
552 MSIINSTALLCONTEXT_USERMANAGED,
553 MSICODE_PRODUCT,
554 INSTALLPROPERTY_PACKAGENAMEW, ptr);
556 /* FIXME("Write DiskPrompt\n"); */
558 /* Pass 1 */
559 LIST_FOR_EACH_ENTRY( file, &package->files, MSIFILE, entry )
561 if (!ACTION_VerifyComponentForAction( file->Component, INSTALLSTATE_LOCAL ))
563 ui_progress(package,2,file->FileSize,0,0);
564 TRACE("File %s is not scheduled for install\n",
565 debugstr_w(file->File));
567 file->state = msifs_skipped;
572 * Despite MSDN specifying that the CreateFolders action
573 * should be called before InstallFiles, some installers don't
574 * do that, and they seem to work correctly. We need to create
575 * directories here to make sure that the files can be copied.
577 msi_create_component_directories( package );
579 mi = create_media_info();
581 /* Pass 2 */
582 LIST_FOR_EACH_ENTRY( file, &package->files, MSIFILE, entry )
584 if (file->state != msifs_missing && file->state != msifs_overwrite)
585 continue;
587 TRACE("Pass 2: %s\n",debugstr_w(file->File));
589 rc = ready_media_for_file( package, mi, file );
590 if (rc != ERROR_SUCCESS)
592 ERR("Unable to ready media\n");
593 rc = ERROR_FUNCTION_FAILED;
594 break;
597 TRACE("file paths %s to %s\n",debugstr_w(file->SourcePath),
598 debugstr_w(file->TargetPath));
600 if (file->state != msifs_missing && file->state != msifs_overwrite)
601 continue;
603 /* compressed files are extracted in ready_media_for_file */
604 if (~file->Attributes & msidbFileAttributesNoncompressed)
606 if (INVALID_FILE_ATTRIBUTES == GetFileAttributesW(file->TargetPath))
607 ERR("compressed file wasn't extracted (%s)\n",
608 debugstr_w(file->TargetPath));
609 continue;
612 rc = CopyFileW(file->SourcePath,file->TargetPath,FALSE);
613 if (!rc)
615 rc = GetLastError();
616 ERR("Unable to copy file (%s -> %s) (error %d)\n",
617 debugstr_w(file->SourcePath), debugstr_w(file->TargetPath), rc);
618 if (rc == ERROR_ALREADY_EXISTS && file->state == msifs_overwrite)
620 rc = 0;
622 else if (rc == ERROR_FILE_NOT_FOUND)
624 ERR("Source File Not Found! Continuing\n");
625 rc = 0;
627 else if (file->Attributes & msidbFileAttributesVital)
629 ERR("Ignoring Error and continuing (nonvital file)...\n");
630 rc = 0;
633 else
635 file->state = msifs_installed;
636 rc = ERROR_SUCCESS;
640 /* cleanup */
641 free_media_info( mi );
642 return rc;
645 static UINT ITERATE_DuplicateFiles(MSIRECORD *row, LPVOID param)
647 MSIPACKAGE *package = (MSIPACKAGE*)param;
648 WCHAR dest_name[0x100];
649 LPWSTR dest_path, dest;
650 LPCWSTR file_key, component;
651 DWORD sz;
652 DWORD rc;
653 MSICOMPONENT *comp;
654 MSIFILE *file;
656 component = MSI_RecordGetString(row,2);
657 comp = get_loaded_component(package,component);
659 if (!ACTION_VerifyComponentForAction( comp, INSTALLSTATE_LOCAL ))
661 TRACE("Skipping copy due to disabled component %s\n",
662 debugstr_w(component));
664 /* the action taken was the same as the current install state */
665 comp->Action = comp->Installed;
667 return ERROR_SUCCESS;
670 comp->Action = INSTALLSTATE_LOCAL;
672 file_key = MSI_RecordGetString(row,3);
673 if (!file_key)
675 ERR("Unable to get file key\n");
676 return ERROR_FUNCTION_FAILED;
679 rc = get_file_target(package,file_key,&file);
681 if (rc != ERROR_SUCCESS)
683 ERR("Original file unknown %s\n",debugstr_w(file_key));
684 return ERROR_SUCCESS;
687 if (MSI_RecordIsNull(row,4))
688 strcpyW(dest_name,strrchrW(file->TargetPath,'\\')+1);
689 else
691 sz=0x100;
692 MSI_RecordGetStringW(row,4,dest_name,&sz);
693 reduce_to_longfilename(dest_name);
696 if (MSI_RecordIsNull(row,5))
698 LPWSTR p;
699 dest_path = strdupW(file->TargetPath);
700 p = strrchrW(dest_path,'\\');
701 if (p)
702 *p=0;
704 else
706 LPCWSTR destkey;
707 destkey = MSI_RecordGetString(row,5);
708 dest_path = resolve_folder(package, destkey, FALSE,FALSE,NULL);
709 if (!dest_path)
711 /* try a Property */
712 dest_path = msi_dup_property( package, destkey );
713 if (!dest_path)
715 FIXME("Unable to get destination folder, try AppSearch properties\n");
716 return ERROR_SUCCESS;
721 dest = build_directory_name(2, dest_path, dest_name);
723 TRACE("Duplicating file %s to %s\n",debugstr_w(file->TargetPath),
724 debugstr_w(dest));
726 if (strcmpW(file->TargetPath,dest))
727 rc = !CopyFileW(file->TargetPath,dest,TRUE);
728 else
729 rc = ERROR_SUCCESS;
731 if (rc != ERROR_SUCCESS)
732 ERR("Failed to copy file %s -> %s, last error %ld\n",
733 debugstr_w(file->TargetPath), debugstr_w(dest_path), GetLastError());
735 FIXME("We should track these duplicate files as well\n");
737 msi_free(dest_path);
738 msi_free(dest);
740 msi_file_update_ui(package, file, szDuplicateFiles);
742 return ERROR_SUCCESS;
745 UINT ACTION_DuplicateFiles(MSIPACKAGE *package)
747 UINT rc;
748 MSIQUERY * view;
749 static const WCHAR ExecSeqQuery[] =
750 {'S','E','L','E','C','T',' ','*',' ','F','R','O','M',' ',
751 '`','D','u','p','l','i','c','a','t','e','F','i','l','e','`',0};
753 rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view);
754 if (rc != ERROR_SUCCESS)
755 return ERROR_SUCCESS;
757 rc = MSI_IterateRecords(view, NULL, ITERATE_DuplicateFiles, package);
758 msiobj_release(&view->hdr);
760 return rc;
763 UINT ACTION_RemoveFiles( MSIPACKAGE *package )
765 MSIFILE *file;
767 LIST_FOR_EACH_ENTRY( file, &package->files, MSIFILE, entry )
769 MSIRECORD *uirow;
770 LPWSTR uipath, p;
772 if ( !file->Component )
773 continue;
774 if ( file->Component->Installed == INSTALLSTATE_LOCAL )
775 continue;
777 if ( file->state == msifs_installed )
778 ERR("removing installed file %s\n", debugstr_w(file->TargetPath));
780 if ( file->state != msifs_present )
781 continue;
783 TRACE("removing %s\n", debugstr_w(file->File) );
784 if ( !DeleteFileW( file->TargetPath ) )
785 ERR("failed to delete %s\n", debugstr_w(file->TargetPath) );
786 file->state = msifs_missing;
788 /* the UI chunk */
789 uirow = MSI_CreateRecord( 9 );
790 MSI_RecordSetStringW( uirow, 1, file->FileName );
791 uipath = strdupW( file->TargetPath );
792 p = strrchrW(uipath,'\\');
793 if (p)
794 p[1]=0;
795 MSI_RecordSetStringW( uirow, 9, uipath);
796 ui_actiondata( package, szRemoveFiles, uirow);
797 msiobj_release( &uirow->hdr );
798 msi_free( uipath );
799 /* FIXME: call ui_progress here? */
802 return ERROR_SUCCESS;