diff options
Diffstat (limited to 'src/WixToolset.Core.Burn/Inscribe/InscribeBundleEngineCommand.cs')
| -rw-r--r-- | src/WixToolset.Core.Burn/Inscribe/InscribeBundleEngineCommand.cs | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/src/WixToolset.Core.Burn/Inscribe/InscribeBundleEngineCommand.cs b/src/WixToolset.Core.Burn/Inscribe/InscribeBundleEngineCommand.cs index 37f64312..a6789796 100644 --- a/src/WixToolset.Core.Burn/Inscribe/InscribeBundleEngineCommand.cs +++ b/src/WixToolset.Core.Burn/Inscribe/InscribeBundleEngineCommand.cs | |||
| @@ -1,33 +1,40 @@ | |||
| 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. | 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 | 2 | ||
| 3 | namespace WixToolset.Core.Burn.Inscribe | 3 | namespace WixToolset.Core.Burn.Inscribe |
| 4 | { | 4 | { |
| 5 | using System; | 5 | using System; |
| 6 | using System.IO; | 6 | using System.IO; |
| 7 | using WixToolset.Core.Burn.Bundles; | 7 | using WixToolset.Core.Burn.Bundles; |
| 8 | using WixToolset.Core.Native; | ||
| 8 | using WixToolset.Extensibility.Data; | 9 | using WixToolset.Extensibility.Data; |
| 9 | 10 | ||
| 10 | internal class InscribeBundleEngineCommand | 11 | internal class InscribeBundleEngineCommand |
| 11 | { | 12 | { |
| 12 | public InscribeBundleEngineCommand(IInscribeContext context) | 13 | public InscribeBundleEngineCommand(IInscribeContext context) |
| 13 | { | 14 | { |
| 14 | this.Context = context; | 15 | this.IntermediateFolder = context.IntermediateFolder; |
| 16 | this.InputFilePath = context.InputFilePath; | ||
| 17 | this.OutputFile = context.OutputFile; | ||
| 15 | } | 18 | } |
| 16 | 19 | ||
| 17 | private IInscribeContext Context { get; } | 20 | private string IntermediateFolder { get; } |
| 21 | |||
| 22 | private string InputFilePath { get; } | ||
| 23 | |||
| 24 | private string OutputFile { get; } | ||
| 18 | 25 | ||
| 19 | public bool Execute() | 26 | public bool Execute() |
| 20 | { | 27 | { |
| 21 | string tempFile = Path.Combine(this.Context.IntermediateFolder, "bundle_engine_unsigned.exe"); | 28 | var tempFile = Path.Combine(this.IntermediateFolder, "bundle_engine_unsigned.exe"); |
| 22 | 29 | ||
| 23 | using (BurnReader reader = BurnReader.Open(this.Context.InputFilePath)) | 30 | using (var reader = BurnReader.Open(this.InputFilePath)) |
| 24 | using (FileStream writer = File.Open(tempFile, FileMode.Create, FileAccess.Write, FileShare.Read | FileShare.Delete)) | 31 | using (var writer = File.Open(tempFile, FileMode.Create, FileAccess.Write, FileShare.Read | FileShare.Delete)) |
| 25 | { | 32 | { |
| 26 | reader.Stream.Seek(0, SeekOrigin.Begin); | 33 | reader.Stream.Seek(0, SeekOrigin.Begin); |
| 27 | 34 | ||
| 28 | byte[] buffer = new byte[4 * 1024]; | 35 | var buffer = new byte[4 * 1024]; |
| 29 | int total = 0; | 36 | var total = 0; |
| 30 | int read = 0; | 37 | var read = 0; |
| 31 | do | 38 | do |
| 32 | { | 39 | { |
| 33 | read = Math.Min(buffer.Length, (int)reader.EngineSize - total); | 40 | read = Math.Min(buffer.Length, (int)reader.EngineSize - total); |
| @@ -46,14 +53,9 @@ namespace WixToolset.Core.Burn.Inscribe | |||
| 46 | // TODO: update writer with detached container signatures. | 53 | // TODO: update writer with detached container signatures. |
| 47 | } | 54 | } |
| 48 | 55 | ||
| 49 | Directory.CreateDirectory(Path.GetDirectoryName(this.Context.OutputFile)); | 56 | Directory.CreateDirectory(Path.GetDirectoryName(this.OutputFile)); |
| 50 | if (File.Exists(this.Context.OutputFile)) | ||
| 51 | { | ||
| 52 | File.Delete(this.Context.OutputFile); | ||
| 53 | } | ||
| 54 | 57 | ||
| 55 | File.Move(tempFile, this.Context.OutputFile); | 58 | FileSystem.MoveFile(tempFile, this.OutputFile); |
| 56 | WixToolset.Core.Native.NativeMethods.ResetAcls(new string[] { this.Context.OutputFile }, 1); | ||
| 57 | 59 | ||
| 58 | return true; | 60 | return true; |
| 59 | } | 61 | } |
