From 03b4dbbdc47a797627ba50c9617d39ed782f8377 Mon Sep 17 00:00:00 2001 From: Mike McCormack Date: Fri, 28 Oct 2005 09:39:29 +0000 Subject: [PATCH] Create component folders in the CreateFolders action. --- dlls/msi/action.c | 33 +++++++++++++++++++++++++++++- dlls/msi/files.c | 52 +++-------------------------------------------- 2 files changed, 35 insertions(+), 50 deletions(-) diff --git a/dlls/msi/action.c b/dlls/msi/action.c index cc4802b6165..bda0a2a10fd 100644 --- a/dlls/msi/action.c +++ b/dlls/msi/action.c @@ -1052,6 +1052,27 @@ static UINT ITERATE_CreateFolders(MSIRECORD *row, LPVOID param) return ERROR_SUCCESS; } +/* FIXME: probably should merge this with the above function */ +static UINT msi_create_directory( MSIPACKAGE* package, LPCWSTR dir ) +{ + UINT rc = ERROR_SUCCESS; + MSIFOLDER *folder; + LPWSTR install_path; + + install_path = resolve_folder(package, dir, FALSE, FALSE, &folder); + if (!install_path) + return ERROR_FUNCTION_FAILED; + + /* create the path */ + if (folder->State == 0) + { + create_full_pathW(install_path); + folder->State = 2; + } + msi_free(install_path); + + return rc; +} /* * Also we cannot enable/disable components either, so for now I am just going @@ -1066,14 +1087,24 @@ static UINT ACTION_CreateFolders(MSIPACKAGE *package) '`','C','r','e','a','t','e','F','o','l','d','e','r','`',0 }; UINT rc; MSIQUERY *view; + MSICOMPONENT *comp; + /* create all the empty folders specified in the CreateFolder table */ rc = MSI_DatabaseOpenViewW(package->db, ExecSeqQuery, &view ); if (rc != ERROR_SUCCESS) return ERROR_SUCCESS; rc = MSI_IterateRecords(view, NULL, ITERATE_CreateFolders, package); msiobj_release(&view->hdr); - + + /* create all the folders required by the components are going to install */ + LIST_FOR_EACH_ENTRY( comp, &package->components, MSICOMPONENT, entry ) + { + if (!ACTION_VerifyComponentForAction(package, comp, INSTALLSTATE_LOCAL)) + continue; + msi_create_directory( package, comp->Directory ); + } + return rc; } diff --git a/dlls/msi/files.c b/dlls/msi/files.c index c292833191e..a32ef1b5277 100644 --- a/dlls/msi/files.c +++ b/dlls/msi/files.c @@ -56,26 +56,6 @@ extern const WCHAR szRemoveFiles[]; static const WCHAR cszTempFolder[]= {'T','e','m','p','F','o','l','d','e','r',0}; -static UINT create_component_directory( MSIPACKAGE* package, MSICOMPONENT *comp ) -{ - UINT rc = ERROR_SUCCESS; - MSIFOLDER *folder; - LPWSTR install_path; - - install_path = resolve_folder(package, comp->Directory, FALSE, FALSE, &folder); - if (!install_path) - return ERROR_FUNCTION_FAILED; - - /* create the path */ - if (folder->State == 0) - { - create_full_pathW(install_path); - folder->State = 2; - } - msi_free(install_path); - - return rc; -} /* * This is a helper function for handling embedded cabinet media @@ -463,7 +443,7 @@ static void free_media_info( struct media_info *mi ) } static UINT ready_media_for_file( MSIPACKAGE *package, struct media_info *mi, - MSIFILE *file, MSICOMPONENT* comp ) + MSIFILE *file ) { UINT rc = ERROR_SUCCESS; MSIRECORD * row = 0; @@ -478,6 +458,7 @@ static UINT ready_media_for_file( MSIPACKAGE *package, struct media_info *mi, INT seq; UINT type; LPCWSTR prompt; + MSICOMPONENT *comp = file->Component; if (file->Sequence <= mi->last_sequence) { @@ -681,8 +662,6 @@ UINT ACTION_InstallFiles(MSIPACKAGE *package) /* Pass 1 */ LIST_FOR_EACH_ENTRY( file, &package->files, MSIFILE, entry ) { - MSICOMPONENT* comp = NULL; - if (!ACTION_VerifyComponentForAction(package, file->Component, INSTALLSTATE_LOCAL)) { @@ -691,31 +670,6 @@ UINT ACTION_InstallFiles(MSIPACKAGE *package) debugstr_w(file->File)); file->State = 5; - continue; - } - - if ((file->State == 1) || (file->State == 2)) - { - LPWSTR p = NULL; - - TRACE("Pass 1: %s\n",debugstr_w(file->File)); - - create_component_directory( package, file->Component ); - - /* recalculate file paths because things may have changed */ - - comp = file->Component; - if (!comp) - { - ERR("No Component for file\n"); - continue; - } - - p = resolve_folder(package, comp->Directory, FALSE, FALSE, NULL); - msi_free(file->TargetPath); - - file->TargetPath = build_directory_name(2, p, file->FileName); - msi_free(p); } } @@ -728,7 +682,7 @@ UINT ACTION_InstallFiles(MSIPACKAGE *package) { TRACE("Pass 2: %s\n",debugstr_w(file->File)); - rc = ready_media_for_file( package, mi, file, file->Component ); + rc = ready_media_for_file( package, mi, file ); if (rc != ERROR_SUCCESS) { ERR("Unable to ready media\n");