aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Core.WindowsInstaller/Bind/ProcessUncompressedFilesCommand.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/WixToolset.Core.WindowsInstaller/Bind/ProcessUncompressedFilesCommand.cs')
-rw-r--r--src/WixToolset.Core.WindowsInstaller/Bind/ProcessUncompressedFilesCommand.cs36
1 files changed, 19 insertions, 17 deletions
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/ProcessUncompressedFilesCommand.cs b/src/WixToolset.Core.WindowsInstaller/Bind/ProcessUncompressedFilesCommand.cs
index b3c09b9e..d71724d1 100644
--- a/src/WixToolset.Core.WindowsInstaller/Bind/ProcessUncompressedFilesCommand.cs
+++ b/src/WixToolset.Core.WindowsInstaller/Bind/ProcessUncompressedFilesCommand.cs
@@ -1,39 +1,42 @@
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
3namespace WixToolset.Core.WindowsInstaller.Databases 3namespace WixToolset.Core.WindowsInstaller.Bind
4{ 4{
5 using System; 5 using System;
6 using System.Collections;
7 using System.Collections.Generic; 6 using System.Collections.Generic;
8 using System.IO; 7 using System.IO;
9 using WixToolset.Data; 8 using WixToolset.Data;
10 using WixToolset.Data.Rows;
11 using WixToolset.Msi; 9 using WixToolset.Msi;
12 using WixToolset.Core.Native; 10 using WixToolset.Core.Native;
13 using WixToolset.Bind; 11 using WixToolset.Bind;
14 using WixToolset.Core.Bind; 12 using WixToolset.Core.Bind;
15 using WixToolset.Data.Bind; 13 using WixToolset.Data.Bind;
14 using WixToolset.Data.Tuples;
15 using System.Linq;
16 16
17 /// <summary> 17 /// <summary>
18 /// Defines the file transfers necessary to layout the uncompressed files. 18 /// Defines the file transfers necessary to layout the uncompressed files.
19 /// </summary> 19 /// </summary>
20 internal class ProcessUncompressedFilesCommand 20 internal class ProcessUncompressedFilesCommand
21 { 21 {
22 public ProcessUncompressedFilesCommand(IntermediateSection section)
23 {
24 this.Section = section;
25 }
26
27 private IntermediateSection Section { get; }
28
22 public string DatabasePath { private get; set; } 29 public string DatabasePath { private get; set; }
23 30
24 public IEnumerable<FileFacade> FileFacades { private get; set; } 31 public IEnumerable<FileFacade> FileFacades { private get; set; }
25 32
26 public RowDictionary<MediaRow> MediaRows { private get; set; }
27
28 public string LayoutDirectory { private get; set; } 33 public string LayoutDirectory { private get; set; }
29 34
30 public bool Compressed { private get; set; } 35 public bool Compressed { private get; set; }
31 36
32 public bool LongNamesInImage { private get; set; } 37 public bool LongNamesInImage { private get; set; }
33 38
34 public Func<MediaRow, string, string, string> ResolveMedia { private get; set; } 39 public Func<MediaTuple, string, string, string> ResolveMedia { private get; set; }
35
36 public Table WixMediaTable { private get; set; }
37 40
38 public IEnumerable<FileTransfer> FileTransfers { get; private set; } 41 public IEnumerable<FileTransfer> FileTransfers { get; private set; }
39 42
@@ -41,9 +44,11 @@ namespace WixToolset.Core.WindowsInstaller.Databases
41 { 44 {
42 List<FileTransfer> fileTransfers = new List<FileTransfer>(); 45 List<FileTransfer> fileTransfers = new List<FileTransfer>();
43 46
44 Hashtable directories = new Hashtable(); 47 var directories = new Dictionary<string, ResolvedDirectory>();
45 48
46 RowDictionary<WixMediaRow> wixMediaRows = new RowDictionary<WixMediaRow>(this.WixMediaTable); 49 var mediaRows = this.Section.Tuples.OfType<MediaTuple>().ToDictionary(t => t.DiskId);
50
51 var wixMediaRows = this.Section.Tuples.OfType<WixMediaTuple>().ToDictionary(t => t.DiskId_);
47 52
48 using (Database db = new Database(this.DatabasePath, OpenDatabase.ReadOnly)) 53 using (Database db = new Database(this.DatabasePath, OpenDatabase.ReadOnly))
49 { 54 {
@@ -72,18 +77,16 @@ namespace WixToolset.Core.WindowsInstaller.Databases
72 // for each file in the array of uncompressed files 77 // for each file in the array of uncompressed files
73 foreach (FileFacade facade in this.FileFacades) 78 foreach (FileFacade facade in this.FileFacades)
74 { 79 {
75 MediaRow mediaRow = this.MediaRows.Get(facade.WixFile.DiskId); 80 var mediaTuple = mediaRows[facade.WixFile.DiskId];
76 string relativeFileLayoutPath = null; 81 string relativeFileLayoutPath = null;
77
78 WixMediaRow wixMediaRow = null;
79 string mediaLayoutFolder = null; 82 string mediaLayoutFolder = null;
80 83
81 if (wixMediaRows.TryGetValue(mediaRow.GetKey(), out wixMediaRow)) 84 if (wixMediaRows.TryGetValue(facade.WixFile.DiskId, out var wixMediaRow))
82 { 85 {
83 mediaLayoutFolder = wixMediaRow.Layout; 86 mediaLayoutFolder = wixMediaRow.Layout;
84 } 87 }
85 88
86 string mediaLayoutDirectory = this.ResolveMedia(mediaRow, mediaLayoutFolder, this.LayoutDirectory); 89 var mediaLayoutDirectory = this.ResolveMedia(mediaTuple, mediaLayoutFolder, this.LayoutDirectory);
87 90
88 // setup up the query record and find the appropriate file in the 91 // setup up the query record and find the appropriate file in the
89 // previously executed file view 92 // previously executed file view
@@ -102,8 +105,7 @@ namespace WixToolset.Core.WindowsInstaller.Databases
102 105
103 // finally put together the base media layout path and the relative file layout path 106 // finally put together the base media layout path and the relative file layout path
104 string fileLayoutPath = Path.Combine(mediaLayoutDirectory, relativeFileLayoutPath); 107 string fileLayoutPath = Path.Combine(mediaLayoutDirectory, relativeFileLayoutPath);
105 FileTransfer transfer; 108 if (FileTransfer.TryCreate(facade.WixFile.Source, fileLayoutPath, false, "File", facade.File.SourceLineNumbers, out var transfer))
106 if (FileTransfer.TryCreate(facade.WixFile.Source, fileLayoutPath, false, "File", facade.File.SourceLineNumbers, out transfer))
107 { 109 {
108 fileTransfers.Add(transfer); 110 fileTransfers.Add(transfer);
109 } 111 }