diff options
Diffstat (limited to 'src/WixToolset.Core/Bind/Databases/CreateDeltaPatchesCommand.cs')
| -rw-r--r-- | src/WixToolset.Core/Bind/Databases/CreateDeltaPatchesCommand.cs | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/src/WixToolset.Core/Bind/Databases/CreateDeltaPatchesCommand.cs b/src/WixToolset.Core/Bind/Databases/CreateDeltaPatchesCommand.cs new file mode 100644 index 00000000..933a1ea8 --- /dev/null +++ b/src/WixToolset.Core/Bind/Databases/CreateDeltaPatchesCommand.cs | |||
| @@ -0,0 +1,86 @@ | |||
| 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.Bind.Databases | ||
| 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.Rows; | ||
| 11 | |||
| 12 | /// <summary> | ||
| 13 | /// Creates delta patches and updates the appropriate rows to point to the newly generated patches. | ||
| 14 | /// </summary> | ||
| 15 | internal class CreateDeltaPatchesCommand : ICommand | ||
| 16 | { | ||
| 17 | public IEnumerable<FileFacade> FileFacades { private get; set; } | ||
| 18 | |||
| 19 | public Table WixPatchIdTable { private get; set; } | ||
| 20 | |||
| 21 | public string TempFilesLocation { private get; set; } | ||
| 22 | |||
| 23 | public void Execute() | ||
| 24 | { | ||
| 25 | bool optimizePatchSizeForLargeFiles = false; | ||
| 26 | PatchAPI.PatchInterop.PatchSymbolFlagsType apiPatchingSymbolFlags = 0; | ||
| 27 | |||
| 28 | if (null != this.WixPatchIdTable) | ||
| 29 | { | ||
| 30 | Row row = this.WixPatchIdTable.Rows[0]; | ||
| 31 | if (null != row) | ||
| 32 | { | ||
| 33 | if (null != row[2]) | ||
| 34 | { | ||
| 35 | optimizePatchSizeForLargeFiles = (1 == Convert.ToUInt32(row[2], CultureInfo.InvariantCulture)); | ||
| 36 | } | ||
| 37 | |||
| 38 | if (null != row[3]) | ||
| 39 | { | ||
| 40 | apiPatchingSymbolFlags = (PatchAPI.PatchInterop.PatchSymbolFlagsType)Convert.ToUInt32(row[3], CultureInfo.InvariantCulture); | ||
| 41 | } | ||
| 42 | } | ||
| 43 | } | ||
| 44 | |||
| 45 | foreach (FileFacade facade in this.FileFacades) | ||
| 46 | { | ||
| 47 | if (RowOperation.Modify == facade.File.Operation && | ||
| 48 | 0 != (facade.WixFile.PatchAttributes & PatchAttributeType.IncludeWholeFile)) | ||
| 49 | { | ||
| 50 | string deltaBase = String.Concat("delta_", facade.File.File); | ||
| 51 | string deltaFile = Path.Combine(this.TempFilesLocation, String.Concat(deltaBase, ".dpf")); | ||
| 52 | string headerFile = Path.Combine(this.TempFilesLocation, String.Concat(deltaBase, ".phd")); | ||
| 53 | |||
| 54 | bool retainRangeWarning = false; | ||
| 55 | |||
| 56 | if (PatchAPI.PatchInterop.CreateDelta( | ||
| 57 | deltaFile, | ||
| 58 | facade.WixFile.Source, | ||
| 59 | facade.DeltaPatchFile.Symbols, | ||
| 60 | facade.DeltaPatchFile.RetainOffsets, | ||
| 61 | new[] { facade.WixFile.PreviousSource }, | ||
| 62 | facade.DeltaPatchFile.PreviousSymbols.Split(new[] { ';' }), | ||
| 63 | facade.DeltaPatchFile.PreviousIgnoreLengths.Split(new[] { ';' }), | ||
| 64 | facade.DeltaPatchFile.PreviousIgnoreOffsets.Split(new[] { ';' }), | ||
| 65 | facade.DeltaPatchFile.PreviousRetainLengths.Split(new[] { ';' }), | ||
| 66 | facade.DeltaPatchFile.PreviousRetainOffsets.Split(new[] { ';' }), | ||
| 67 | apiPatchingSymbolFlags, | ||
| 68 | optimizePatchSizeForLargeFiles, | ||
| 69 | out retainRangeWarning)) | ||
| 70 | { | ||
| 71 | PatchAPI.PatchInterop.ExtractDeltaHeader(deltaFile, headerFile); | ||
| 72 | |||
| 73 | facade.WixFile.Source = deltaFile; | ||
| 74 | facade.WixFile.DeltaPatchHeaderSource = headerFile; | ||
| 75 | } | ||
| 76 | |||
| 77 | if (retainRangeWarning) | ||
| 78 | { | ||
| 79 | // TODO: get patch family to add to warning message for PatchWiz parity. | ||
| 80 | Messaging.Instance.OnMessage(WixWarnings.RetainRangeMismatch(facade.File.SourceLineNumbers, facade.File.File)); | ||
| 81 | } | ||
| 82 | } | ||
| 83 | } | ||
| 84 | } | ||
| 85 | } | ||
| 86 | } | ||
