msi [7/11]: Factor copy_install_file out of ACTION_InstallFiles
James Hawkins
truiken at gmail.com
Tue Nov 7 17:12:22 CST 2006
Hi,
Changelog:
* Factor copy_install_file out of ACTION_InstallFiles.
dlls/msi/files.c | 66 ++++++++++++++++++++++++++++++++++--------------------
1 files changed, 42 insertions(+), 24 deletions(-)
--
James Hawkins
-------------- next part --------------
diff --git a/dlls/msi/files.c b/dlls/msi/files.c
index deda59f..4bede98 100644
--- a/dlls/msi/files.c
+++ b/dlls/msi/files.c
@@ -597,6 +597,42 @@ static void schedule_install_files(MSIPA
}
}
+static UINT copy_install_file(MSIFILE *file)
+{
+ BOOL ret;
+ UINT gle;
+
+ TRACE("Copying %s to %s\n", debugstr_w(file->SourcePath),
+ debugstr_w(file->TargetPath));
+
+ ret = CopyFileW(file->SourcePath, file->TargetPath, FALSE);
+ if (ret)
+ {
+ file->state = msifs_installed;
+ return ERROR_SUCCESS;
+ }
+
+ gle = GetLastError();
+ if (gle == ERROR_ALREADY_EXISTS && file->state == msifs_overwrite)
+ {
+ TRACE("overwriting existing file\n");
+ gle = ERROR_SUCCESS;
+ }
+ else if (gle == ERROR_FILE_NOT_FOUND)
+ {
+ /* FIXME: this needs to be tested, I'm pretty sure it fails */
+ TRACE("Source file not found\n");
+ gle = ERROR_SUCCESS;
+ }
+ else if (!(file->Attributes & msidbFileAttributesVital))
+ {
+ TRACE("Ignoring error for nonvital\n");
+ gle = ERROR_SUCCESS;
+ }
+
+ return gle;
+}
+
/*
* ACTION_InstallFiles()
*
@@ -673,31 +709,13 @@ UINT ACTION_InstallFiles(MSIPACKAGE *pac
continue;
}
- 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);
- if (rc == ERROR_ALREADY_EXISTS && file->state == msifs_overwrite)
- {
- rc = 0;
- }
- else if (rc == ERROR_FILE_NOT_FOUND)
- {
- ERR("Source File Not Found! Continuing\n");
- rc = 0;
- }
- else if (file->Attributes & msidbFileAttributesVital)
- {
- ERR("Ignoring Error and continuing (nonvital file)...\n");
- rc = 0;
- }
- }
- else
+ rc = copy_install_file(file);
+ if (rc != ERROR_SUCCESS)
{
- file->state = msifs_installed;
- rc = ERROR_SUCCESS;
+ ERR("Failed to copy %s to %s (%d)\n", debugstr_w(file->SourcePath),
+ debugstr_w(file->TargetPath), rc);
+ rc = ERROR_INSTALL_FAILURE;
+ break;
}
}
--
1.4.2.4
More information about the wine-patches
mailing list