diff options
| author | Rob Mensching <rob@firegiant.com> | 2018-07-26 23:52:12 -0700 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2018-07-27 11:31:18 -0700 |
| commit | 854e616eb3516c7405691b679617aa08c1dd1cdd (patch) | |
| tree | ce7694749bf88bc796825b84fbc4f9d8acae331d /src/WixToolset.Core.WindowsInstaller | |
| parent | c64faa7f6cb789a0756dff725146728889df8311 (diff) | |
| download | wix-854e616eb3516c7405691b679617aa08c1dd1cdd.tar.gz wix-854e616eb3516c7405691b679617aa08c1dd1cdd.tar.bz2 wix-854e616eb3516c7405691b679617aa08c1dd1cdd.zip | |
Support change of FileTransfer to interface
Diffstat (limited to 'src/WixToolset.Core.WindowsInstaller')
3 files changed, 40 insertions, 39 deletions
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs index 119cbd55..3aad0709 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/BindDatabaseCommand.cs | |||
| @@ -26,6 +26,8 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 26 | { | 26 | { |
| 27 | this.Messaging = context.ServiceProvider.GetService<IMessaging>(); | 27 | this.Messaging = context.ServiceProvider.GetService<IMessaging>(); |
| 28 | 28 | ||
| 29 | this.BackendHelper = context.ServiceProvider.GetService<IBackendHelper>(); | ||
| 30 | |||
| 29 | this.TableDefinitions = WindowsInstallerStandardInternal.GetTableDefinitions(); | 31 | this.TableDefinitions = WindowsInstallerStandardInternal.GetTableDefinitions(); |
| 30 | 32 | ||
| 31 | this.CabbingThreadCount = context.CabbingThreadCount; | 33 | this.CabbingThreadCount = context.CabbingThreadCount; |
| @@ -43,6 +45,10 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 43 | this.BackendExtensions = backendExtension; | 45 | this.BackendExtensions = backendExtension; |
| 44 | } | 46 | } |
| 45 | 47 | ||
| 48 | private IMessaging Messaging { get; } | ||
| 49 | |||
| 50 | private IBackendHelper BackendHelper { get; } | ||
| 51 | |||
| 46 | private int Codepage { get; } | 52 | private int Codepage { get; } |
| 47 | 53 | ||
| 48 | private int CabbingThreadCount { get; } | 54 | private int CabbingThreadCount { get; } |
| @@ -63,8 +69,6 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 63 | 69 | ||
| 64 | private Intermediate Intermediate { get; } | 70 | private Intermediate Intermediate { get; } |
| 65 | 71 | ||
| 66 | private IMessaging Messaging { get; } | ||
| 67 | |||
| 68 | private string OutputPath { get; } | 72 | private string OutputPath { get; } |
| 69 | 73 | ||
| 70 | private bool SuppressAddingValidationRows { get; } | 74 | private bool SuppressAddingValidationRows { get; } |
| @@ -77,7 +81,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 77 | 81 | ||
| 78 | private Validator Validator { get; } | 82 | private Validator Validator { get; } |
| 79 | 83 | ||
| 80 | public IEnumerable<FileTransfer> FileTransfers { get; private set; } | 84 | public IEnumerable<IFileTransfer> FileTransfers { get; private set; } |
| 81 | 85 | ||
| 82 | public IEnumerable<string> ContentFilePaths { get; private set; } | 86 | public IEnumerable<string> ContentFilePaths { get; private set; } |
| 83 | 87 | ||
| @@ -87,7 +91,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 87 | { | 91 | { |
| 88 | var section = this.Intermediate.Sections.Single(); | 92 | var section = this.Intermediate.Sections.Single(); |
| 89 | 93 | ||
| 90 | var fileTransfers = new List<FileTransfer>(); | 94 | var fileTransfers = new List<IFileTransfer>(); |
| 91 | 95 | ||
| 92 | var containsMergeModules = false; | 96 | var containsMergeModules = false; |
| 93 | var suppressedTableNames = new HashSet<string>(); | 97 | var suppressedTableNames = new HashSet<string>(); |
| @@ -375,7 +379,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 375 | { | 379 | { |
| 376 | this.Messaging.Write(VerboseMessages.CreatingCabinetFiles()); | 380 | this.Messaging.Write(VerboseMessages.CreatingCabinetFiles()); |
| 377 | 381 | ||
| 378 | var command = new CreateCabinetsCommand(); | 382 | var command = new CreateCabinetsCommand(this.BackendHelper); |
| 379 | command.CabbingThreadCount = this.CabbingThreadCount; | 383 | command.CabbingThreadCount = this.CabbingThreadCount; |
| 380 | command.CabCachePath = this.CabCachePath; | 384 | command.CabCachePath = this.CabCachePath; |
| 381 | command.DefaultCompressionLevel = this.DefaultCompressionLevel; | 385 | command.DefaultCompressionLevel = this.DefaultCompressionLevel; |
| @@ -415,11 +419,8 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 415 | string tempDatabaseFile = Path.Combine(this.IntermediateFolder, Path.GetFileName(this.OutputPath)); | 419 | string tempDatabaseFile = Path.Combine(this.IntermediateFolder, Path.GetFileName(this.OutputPath)); |
| 416 | this.GenerateDatabase(output, tempDatabaseFile, false, false); | 420 | this.GenerateDatabase(output, tempDatabaseFile, false, false); |
| 417 | 421 | ||
| 418 | if (FileTransfer.TryCreate(tempDatabaseFile, this.OutputPath, true, output.Type.ToString(), null, out var transfer)) // note where this database needs to move in the future | 422 | var transfer = this.BackendHelper.CreateFileTransfer(tempDatabaseFile, this.OutputPath, true, FileTransferType.Built); // note where this database needs to move in the future |
| 419 | { | 423 | fileTransfers.Add(transfer); |
| 420 | transfer.Built = true; | ||
| 421 | fileTransfers.Add(transfer); | ||
| 422 | } | ||
| 423 | 424 | ||
| 424 | // Stop processing if an error previously occurred. | 425 | // Stop processing if an error previously occurred. |
| 425 | if (this.Messaging.EncounteredError) | 426 | if (this.Messaging.EncounteredError) |
| @@ -491,7 +492,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 491 | // Process uncompressed files. | 492 | // Process uncompressed files. |
| 492 | if (!this.Messaging.EncounteredError && !this.SuppressLayout && uncompressedFiles.Any()) | 493 | if (!this.Messaging.EncounteredError && !this.SuppressLayout && uncompressedFiles.Any()) |
| 493 | { | 494 | { |
| 494 | var command = new ProcessUncompressedFilesCommand(section); | 495 | var command = new ProcessUncompressedFilesCommand(section, this.BackendHelper); |
| 495 | command.Compressed = compressed; | 496 | command.Compressed = compressed; |
| 496 | command.FileFacades = uncompressedFiles; | 497 | command.FileFacades = uncompressedFiles; |
| 497 | command.LayoutDirectory = layoutDirectory; | 498 | command.LayoutDirectory = layoutDirectory; |
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/CreateCabinetsCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/CreateCabinetsCommand.cs index 328bb082..ed8f0ece 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/CreateCabinetsCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/CreateCabinetsCommand.cs | |||
| @@ -26,19 +26,23 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 26 | public const int DefaultMaximumUncompressedMediaSize = 200; // Default value is 200 MB | 26 | public const int DefaultMaximumUncompressedMediaSize = 200; // Default value is 200 MB |
| 27 | public const int MaxValueOfMaxCabSizeForLargeFileSplitting = 2 * 1024; // 2048 MB (i.e. 2 GB) | 27 | public const int MaxValueOfMaxCabSizeForLargeFileSplitting = 2 * 1024; // 2048 MB (i.e. 2 GB) |
| 28 | 28 | ||
| 29 | private List<FileTransfer> fileTransfers; | 29 | private List<IFileTransfer> fileTransfers; |
| 30 | 30 | ||
| 31 | private FileSplitCabNamesCallback newCabNamesCallBack; | 31 | private FileSplitCabNamesCallback newCabNamesCallBack; |
| 32 | 32 | ||
| 33 | private Dictionary<string, string> lastCabinetAddedToMediaTable; // Key is First Cabinet Name, Value is Last Cabinet Added in the Split Sequence | 33 | private Dictionary<string, string> lastCabinetAddedToMediaTable; // Key is First Cabinet Name, Value is Last Cabinet Added in the Split Sequence |
| 34 | 34 | ||
| 35 | public CreateCabinetsCommand() | 35 | public CreateCabinetsCommand(IBackendHelper backendHelper) |
| 36 | { | 36 | { |
| 37 | this.fileTransfers = new List<FileTransfer>(); | 37 | this.fileTransfers = new List<IFileTransfer>(); |
| 38 | 38 | ||
| 39 | this.newCabNamesCallBack = this.NewCabNamesCallBack; | 39 | this.newCabNamesCallBack = this.NewCabNamesCallBack; |
| 40 | |||
| 41 | this.BackendHelper = backendHelper; | ||
| 40 | } | 42 | } |
| 41 | 43 | ||
| 44 | public IBackendHelper BackendHelper { get; } | ||
| 45 | |||
| 42 | /// <summary> | 46 | /// <summary> |
| 43 | /// Sets the number of threads to use for cabinet creation. | 47 | /// Sets the number of threads to use for cabinet creation. |
| 44 | /// </summary> | 48 | /// </summary> |
| @@ -72,7 +76,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 72 | 76 | ||
| 73 | public IEnumerable<WixMediaTuple> WixMediaTuples { private get; set; } | 77 | public IEnumerable<WixMediaTuple> WixMediaTuples { private get; set; } |
| 74 | 78 | ||
| 75 | public IEnumerable<FileTransfer> FileTransfers => this.fileTransfers; | 79 | public IEnumerable<IFileTransfer> FileTransfers => this.fileTransfers; |
| 76 | 80 | ||
| 77 | /// <param name="output">Output to generate image for.</param> | 81 | /// <param name="output">Output to generate image for.</param> |
| 78 | /// <param name="fileTransfers">Array of files to be transfered.</param> | 82 | /// <param name="fileTransfers">Array of files to be transfered.</param> |
| @@ -186,7 +190,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 186 | /// <param name="fileFacades">Collection of files in this cabinet.</param> | 190 | /// <param name="fileFacades">Collection of files in this cabinet.</param> |
| 187 | /// <param name="fileTransfers">Array of files to be transfered.</param> | 191 | /// <param name="fileTransfers">Array of files to be transfered.</param> |
| 188 | /// <returns>created CabinetWorkItem object</returns> | 192 | /// <returns>created CabinetWorkItem object</returns> |
| 189 | private CabinetWorkItem CreateCabinetWorkItem(Output output, string cabinetDir, MediaTuple mediaRow, CompressionLevel compressionLevel, IEnumerable<FileFacade> fileFacades, List<FileTransfer> fileTransfers) | 193 | private CabinetWorkItem CreateCabinetWorkItem(Output output, string cabinetDir, MediaTuple mediaRow, CompressionLevel compressionLevel, IEnumerable<FileFacade> fileFacades, List<IFileTransfer> fileTransfers) |
| 190 | { | 194 | { |
| 191 | CabinetWorkItem cabinetWorkItem = null; | 195 | CabinetWorkItem cabinetWorkItem = null; |
| 192 | string tempCabinetFileX = Path.Combine(this.TempFilesLocation, mediaRow.Cabinet); | 196 | string tempCabinetFileX = Path.Combine(this.TempFilesLocation, mediaRow.Cabinet); |
| @@ -254,12 +258,9 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 254 | } | 258 | } |
| 255 | else | 259 | else |
| 256 | { | 260 | { |
| 257 | string destinationPath = Path.Combine(cabinetDir, mediaRow.Cabinet); | 261 | var destinationPath = Path.Combine(cabinetDir, mediaRow.Cabinet); |
| 258 | if (FileTransfer.TryCreate(resolvedCabinet.Path, destinationPath, CabinetBuildOption.BuildAndMove == resolvedCabinet.BuildOption, "Cabinet", mediaRow.SourceLineNumbers, out var transfer)) | 262 | var transfer = this.BackendHelper.CreateFileTransfer(resolvedCabinet.Path, destinationPath, CabinetBuildOption.BuildAndMove == resolvedCabinet.BuildOption, FileTransferType.Built, mediaRow.SourceLineNumbers); |
| 259 | { | 263 | fileTransfers.Add(transfer); |
| 260 | transfer.Built = true; | ||
| 261 | fileTransfers.Add(transfer); | ||
| 262 | } | ||
| 263 | } | 264 | } |
| 264 | 265 | ||
| 265 | return cabinetWorkItem; | 266 | return cabinetWorkItem; |
| @@ -315,21 +316,18 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 315 | bool transferAdded = false; // Used for Error Handling | 316 | bool transferAdded = false; // Used for Error Handling |
| 316 | 317 | ||
| 317 | // Create File Transfer for new Cabinet using transfer of Base Cabinet | 318 | // Create File Transfer for new Cabinet using transfer of Base Cabinet |
| 318 | foreach (FileTransfer transfer in this.FileTransfers) | 319 | foreach (var transfer in this.FileTransfers) |
| 319 | { | 320 | { |
| 320 | if (firstCabinetName.Equals(Path.GetFileName(transfer.Source), StringComparison.InvariantCultureIgnoreCase)) | 321 | if (firstCabinetName.Equals(Path.GetFileName(transfer.Source), StringComparison.InvariantCultureIgnoreCase)) |
| 321 | { | 322 | { |
| 322 | string newCabSourcePath = Path.Combine(Path.GetDirectoryName(transfer.Source), newCabinetName); | 323 | string newCabSourcePath = Path.Combine(Path.GetDirectoryName(transfer.Source), newCabinetName); |
| 323 | string newCabTargetPath = Path.Combine(Path.GetDirectoryName(transfer.Destination), newCabinetName); | 324 | string newCabTargetPath = Path.Combine(Path.GetDirectoryName(transfer.Destination), newCabinetName); |
| 324 | 325 | ||
| 325 | FileTransfer newTransfer; | 326 | var newTransfer = this.BackendHelper.CreateFileTransfer(newCabSourcePath, newCabTargetPath, transfer.Move, FileTransferType.Built, transfer.SourceLineNumbers); |
| 326 | if (FileTransfer.TryCreate(newCabSourcePath, newCabTargetPath, transfer.Move, "Cabinet", transfer.SourceLineNumbers, out newTransfer)) | 327 | this.fileTransfers.Add(newTransfer); |
| 327 | { | 328 | |
| 328 | newTransfer.Built = true; | 329 | transferAdded = true; |
| 329 | this.fileTransfers.Add(newTransfer); | 330 | break; |
| 330 | transferAdded = true; | ||
| 331 | break; | ||
| 332 | } | ||
| 333 | } | 331 | } |
| 334 | } | 332 | } |
| 335 | 333 | ||
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/ProcessUncompressedFilesCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/ProcessUncompressedFilesCommand.cs index 4b143ead..b09f92bb 100644 --- a/src/WixToolset.Core.WindowsInstaller/Bind/ProcessUncompressedFilesCommand.cs +++ b/src/WixToolset.Core.WindowsInstaller/Bind/ProcessUncompressedFilesCommand.cs | |||
| @@ -11,6 +11,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 11 | using WixToolset.Data; | 11 | using WixToolset.Data; |
| 12 | using WixToolset.Data.Tuples; | 12 | using WixToolset.Data.Tuples; |
| 13 | using WixToolset.Extensibility.Data; | 13 | using WixToolset.Extensibility.Data; |
| 14 | using WixToolset.Extensibility.Services; | ||
| 14 | using WixToolset.Msi; | 15 | using WixToolset.Msi; |
| 15 | 16 | ||
| 16 | /// <summary> | 17 | /// <summary> |
| @@ -18,13 +19,16 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 18 | /// </summary> | 19 | /// </summary> |
| 19 | internal class ProcessUncompressedFilesCommand | 20 | internal class ProcessUncompressedFilesCommand |
| 20 | { | 21 | { |
| 21 | public ProcessUncompressedFilesCommand(IntermediateSection section) | 22 | public ProcessUncompressedFilesCommand(IntermediateSection section, IBackendHelper backendHelper) |
| 22 | { | 23 | { |
| 23 | this.Section = section; | 24 | this.Section = section; |
| 25 | this.BackendHelper = backendHelper; | ||
| 24 | } | 26 | } |
| 25 | 27 | ||
| 26 | private IntermediateSection Section { get; } | 28 | private IntermediateSection Section { get; } |
| 27 | 29 | ||
| 30 | public IBackendHelper BackendHelper { get; } | ||
| 31 | |||
| 28 | public string DatabasePath { private get; set; } | 32 | public string DatabasePath { private get; set; } |
| 29 | 33 | ||
| 30 | public IEnumerable<FileFacade> FileFacades { private get; set; } | 34 | public IEnumerable<FileFacade> FileFacades { private get; set; } |
| @@ -37,11 +41,11 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 37 | 41 | ||
| 38 | public Func<MediaTuple, string, string, string> ResolveMedia { private get; set; } | 42 | public Func<MediaTuple, string, string, string> ResolveMedia { private get; set; } |
| 39 | 43 | ||
| 40 | public IEnumerable<FileTransfer> FileTransfers { get; private set; } | 44 | public IEnumerable<IFileTransfer> FileTransfers { get; private set; } |
| 41 | 45 | ||
| 42 | public void Execute() | 46 | public void Execute() |
| 43 | { | 47 | { |
| 44 | var fileTransfers = new List<FileTransfer>(); | 48 | var fileTransfers = new List<IFileTransfer>(); |
| 45 | 49 | ||
| 46 | var directories = new Dictionary<string, ResolvedDirectory>(); | 50 | var directories = new Dictionary<string, ResolvedDirectory>(); |
| 47 | 51 | ||
| @@ -103,11 +107,9 @@ namespace WixToolset.Core.WindowsInstaller.Bind | |||
| 103 | } | 107 | } |
| 104 | 108 | ||
| 105 | // finally put together the base media layout path and the relative file layout path | 109 | // finally put together the base media layout path and the relative file layout path |
| 106 | string fileLayoutPath = Path.Combine(mediaLayoutDirectory, relativeFileLayoutPath); | 110 | var fileLayoutPath = Path.Combine(mediaLayoutDirectory, relativeFileLayoutPath); |
| 107 | if (FileTransfer.TryCreate(facade.WixFile.Source.Path, fileLayoutPath, false, "File", facade.File.SourceLineNumbers, out var transfer)) | 111 | var transfer = this.BackendHelper.CreateFileTransfer(facade.WixFile.Source.Path, fileLayoutPath, false, FileTransferType.Content, facade.File.SourceLineNumbers); |
| 108 | { | 112 | fileTransfers.Add(transfer); |
| 109 | fileTransfers.Add(transfer); | ||
| 110 | } | ||
| 111 | } | 113 | } |
| 112 | } | 114 | } |
| 113 | } | 115 | } |
