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/Bind/CreateCabinetsCommand.cs | |
| 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/Bind/CreateCabinetsCommand.cs')
| -rw-r--r-- | src/WixToolset.Core.WindowsInstaller/Bind/CreateCabinetsCommand.cs | 38 |
1 files changed, 18 insertions, 20 deletions
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 | ||
