| 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. |
| 2 | |
| 3 | namespace WixToolset.Core.WindowsInstaller.Bind |
| 4 | { |
| 5 | using System; |
| 6 | using System.Collections.Generic; |
| 7 | using System.Globalization; |
| 8 | using System.IO; |
| 9 | using WixToolset.Data; |
| 10 | using WixToolset.Data.Symbols; |
| 11 | using WixToolset.Extensibility.Data; |
| 12 | |
| 13 | /// <summary> |
| 14 | /// Creates delta patches and updates the appropriate rows to point to the newly generated patches. |
| 15 | /// </summary> |
| 16 | internal class CreateDeltaPatchesCommand |
| 17 | { |
| 18 | public CreateDeltaPatchesCommand(List<IFileFacade> fileFacades, string intermediateFolder, WixPatchSymbol wixPatchId) |
| 19 | { |
| 20 | this.FileFacades = fileFacades; |
| 21 | this.IntermediateFolder = intermediateFolder; |
| 22 | this.WixPatchId = wixPatchId; |
| 23 | } |
| 24 | |
| 25 | private IEnumerable<IFileFacade> FileFacades { get; } |
| 26 | |
| 27 | private WixPatchSymbol WixPatchId { get; } |
| 28 | |
| 29 | private string IntermediateFolder { get; } |
| 30 | |
| 31 | public void Execute() |
| 32 | { |
| 33 | var optimizePatchSizeForLargeFiles = this.WixPatchId?.OptimizePatchSizeForLargeFiles ?? false; |
| 34 | var apiPatchingSymbolFlags = (PatchSymbolFlags)(this.WixPatchId?.ApiPatchingSymbolFlags ?? 0); |
| 35 | |
| 36 | #if TODO_PATCHING_DELTA |
| 37 | foreach (FileFacade facade in this.FileFacades) |
| 38 | { |
| 39 | if (RowOperation.Modify == facade.File.Operation && |
| 40 | 0 != (facade.WixFile.PatchAttributes & PatchAttributeType.IncludeWholeFile)) |
| 41 | { |
| 42 | string deltaBase = String.Concat("delta_", facade.File.File); |
| 43 | string deltaFile = Path.Combine(this.IntermediateFolder, String.Concat(deltaBase, ".dpf")); |
| 44 | string headerFile = Path.Combine(this.IntermediateFolder, String.Concat(deltaBase, ".phd")); |
| 45 | |
| 46 | bool retainRangeWarning = false; |
| 47 | |
| 48 | if (PatchAPI.PatchInterop.CreateDelta( |
| 49 | deltaFile, |
| 50 | facade.WixFile.Source, |
| 51 | facade.DeltaPatchFile.Symbols, |
| 52 | facade.DeltaPatchFile.RetainOffsets, |
| 53 | new[] { facade.WixFile.PreviousSource }, |
| 54 | facade.DeltaPatchFile.PreviousSymbols.Split(new[] { ';' }), |
| 55 | facade.DeltaPatchFile.PreviousIgnoreLengths.Split(new[] { ';' }), |
| 56 | facade.DeltaPatchFile.PreviousIgnoreOffsets.Split(new[] { ';' }), |
| 57 | facade.DeltaPatchFile.PreviousRetainLengths.Split(new[] { ';' }), |
| 58 | facade.DeltaPatchFile.PreviousRetainOffsets.Split(new[] { ';' }), |
| 59 | apiPatchingSymbolFlags, |
| 60 | optimizePatchSizeForLargeFiles, |
| 61 | out retainRangeWarning)) |
| 62 | { |
| 63 | PatchAPI.PatchInterop.ExtractDeltaHeader(deltaFile, headerFile); |
| 64 | |
| 65 | facade.WixFile.Source = deltaFile; |
| 66 | facade.WixFile.DeltaPatchHeaderSource = headerFile; |
| 67 | } |
| 68 | |
| 69 | if (retainRangeWarning) |
| 70 | { |
| 71 | // TODO: get patch family to add to warning message for PatchWiz parity. |
| 72 | Messaging.Instance.OnMessage(WixWarnings.RetainRangeMismatch(facade.File.SourceLineNumbers, facade.File.File)); |
| 73 | } |
| 74 | } |
| 75 | } |
| 76 | #endif |
| 77 | |
| 78 | throw new NotImplementedException(); |
| 79 | } |
| 80 | } |
| 81 | } |