diff options
| author | Rob Mensching <rob@firegiant.com> | 2017-10-14 16:12:07 -0700 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2017-10-14 16:12:07 -0700 |
| commit | dbde9e7104b907bbbaea17e21247d8cafc8b3a4c (patch) | |
| tree | 0f5fbbb6fe12c6b2e5e622a0e18ce4c5b4eb2b96 /src/WixToolset.Core.WindowsInstaller/Bind/CreateDeltaPatchesCommand.cs | |
| parent | fbf986eb97f68396797a89fc7d40dec07b775440 (diff) | |
| download | wix-dbde9e7104b907bbbaea17e21247d8cafc8b3a4c.tar.gz wix-dbde9e7104b907bbbaea17e21247d8cafc8b3a4c.tar.bz2 wix-dbde9e7104b907bbbaea17e21247d8cafc8b3a4c.zip | |
Massive refactoring to introduce the concept of IBackend
Diffstat (limited to 'src/WixToolset.Core.WindowsInstaller/Bind/CreateDeltaPatchesCommand.cs')
| -rw-r--r-- | src/WixToolset.Core.WindowsInstaller/Bind/CreateDeltaPatchesCommand.cs | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/CreateDeltaPatchesCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/CreateDeltaPatchesCommand.cs new file mode 100644 index 00000000..767671b8 --- /dev/null +++ b/src/WixToolset.Core.WindowsInstaller/Bind/CreateDeltaPatchesCommand.cs | |||
| @@ -0,0 +1,87 @@ | |||
| 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.Databases | ||
| 4 | { | ||
| 5 | using System; | ||
| 6 | using System.Collections.Generic; | ||
| 7 | using System.Globalization; | ||
| 8 | using System.IO; | ||
| 9 | using WixToolset.Core.Bind; | ||
| 10 | using WixToolset.Data; | ||
| 11 | using WixToolset.Data.Rows; | ||
| 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 IEnumerable<FileFacade> FileFacades { private get; set; } | ||
| 19 | |||
| 20 | public Table WixPatchIdTable { private get; set; } | ||
| 21 | |||
| 22 | public string TempFilesLocation { private get; set; } | ||
| 23 | |||
| 24 | public void Execute() | ||
| 25 | { | ||
| 26 | bool optimizePatchSizeForLargeFiles = false; | ||
| 27 | PatchSymbolFlagsType apiPatchingSymbolFlags = 0; | ||
| 28 | |||
| 29 | if (null != this.WixPatchIdTable) | ||
| 30 | { | ||
| 31 | Row row = this.WixPatchIdTable.Rows[0]; | ||
| 32 | if (null != row) | ||
| 33 | { | ||
| 34 | if (null != row[2]) | ||
| 35 | { | ||
| 36 | optimizePatchSizeForLargeFiles = (1 == Convert.ToUInt32(row[2], CultureInfo.InvariantCulture)); | ||
| 37 | } | ||
| 38 | |||
| 39 | if (null != row[3]) | ||
| 40 | { | ||
| 41 | apiPatchingSymbolFlags = (PatchSymbolFlagsType)Convert.ToUInt32(row[3], CultureInfo.InvariantCulture); | ||
| 42 | } | ||
| 43 | } | ||
| 44 | } | ||
| 45 | |||
| 46 | foreach (FileFacade facade in this.FileFacades) | ||
| 47 | { | ||
| 48 | if (RowOperation.Modify == facade.File.Operation && | ||
| 49 | 0 != (facade.WixFile.PatchAttributes & PatchAttributeType.IncludeWholeFile)) | ||
| 50 | { | ||
| 51 | string deltaBase = String.Concat("delta_", facade.File.File); | ||
| 52 | string deltaFile = Path.Combine(this.TempFilesLocation, String.Concat(deltaBase, ".dpf")); | ||
| 53 | string headerFile = Path.Combine(this.TempFilesLocation, String.Concat(deltaBase, ".phd")); | ||
| 54 | |||
| 55 | bool retainRangeWarning = false; | ||
| 56 | |||
| 57 | if (PatchAPI.PatchInterop.CreateDelta( | ||
| 58 | deltaFile, | ||
| 59 | facade.WixFile.Source, | ||
| 60 | facade.DeltaPatchFile.Symbols, | ||
| 61 | facade.DeltaPatchFile.RetainOffsets, | ||
| 62 | new[] { facade.WixFile.PreviousSource }, | ||
| 63 | facade.DeltaPatchFile.PreviousSymbols.Split(new[] { ';' }), | ||
| 64 | facade.DeltaPatchFile.PreviousIgnoreLengths.Split(new[] { ';' }), | ||
| 65 | facade.DeltaPatchFile.PreviousIgnoreOffsets.Split(new[] { ';' }), | ||
| 66 | facade.DeltaPatchFile.PreviousRetainLengths.Split(new[] { ';' }), | ||
| 67 | facade.DeltaPatchFile.PreviousRetainOffsets.Split(new[] { ';' }), | ||
| 68 | apiPatchingSymbolFlags, | ||
| 69 | optimizePatchSizeForLargeFiles, | ||
| 70 | out retainRangeWarning)) | ||
| 71 | { | ||
| 72 | PatchAPI.PatchInterop.ExtractDeltaHeader(deltaFile, headerFile); | ||
| 73 | |||
| 74 | facade.WixFile.Source = deltaFile; | ||
| 75 | facade.WixFile.DeltaPatchHeaderSource = headerFile; | ||
| 76 | } | ||
| 77 | |||
| 78 | if (retainRangeWarning) | ||
| 79 | { | ||
| 80 | // TODO: get patch family to add to warning message for PatchWiz parity. | ||
| 81 | Messaging.Instance.OnMessage(WixWarnings.RetainRangeMismatch(facade.File.SourceLineNumbers, facade.File.File)); | ||
| 82 | } | ||
| 83 | } | ||
| 84 | } | ||
| 85 | } | ||
| 86 | } | ||
| 87 | } | ||
