aboutsummaryrefslogtreecommitdiff
path: root/src/WixToolset.Core.WindowsInstaller/Bind/CabinetBuilder.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/WixToolset.Core.WindowsInstaller/Bind/CabinetBuilder.cs')
-rw-r--r--src/WixToolset.Core.WindowsInstaller/Bind/CabinetBuilder.cs32
1 files changed, 20 insertions, 12 deletions
diff --git a/src/WixToolset.Core.WindowsInstaller/Bind/CabinetBuilder.cs b/src/WixToolset.Core.WindowsInstaller/Bind/CabinetBuilder.cs
index c25a497e..2cbcc8e1 100644
--- a/src/WixToolset.Core.WindowsInstaller/Bind/CabinetBuilder.cs
+++ b/src/WixToolset.Core.WindowsInstaller/Bind/CabinetBuilder.cs
@@ -4,11 +4,12 @@ namespace WixToolset.Core.WindowsInstaller.Bind
4{ 4{
5 using System; 5 using System;
6 using System.Collections; 6 using System.Collections;
7 using System.Collections.Generic;
7 using System.IO; 8 using System.IO;
8 using System.Linq; 9 using System.Linq;
9 using System.Threading; 10 using System.Threading;
10 using WixToolset.Core.Bind; 11 using WixToolset.Core.Bind;
11 using WixToolset.Core.Cab; 12 using WixToolset.Core.Native;
12 using WixToolset.Data; 13 using WixToolset.Data;
13 14
14 /// <summary> 15 /// <summary>
@@ -137,7 +138,7 @@ namespace WixToolset.Core.WindowsInstaller.Bind
137 int maxCabinetSize = 0; // The value of 0 corresponds to default of 2GB which means no cabinet splitting 138 int maxCabinetSize = 0; // The value of 0 corresponds to default of 2GB which means no cabinet splitting
138 ulong maxPreCompressedSizeInBytes = 0; 139 ulong maxPreCompressedSizeInBytes = 0;
139 140
140 if (MaximumCabinetSizeForLargeFileSplitting != 0) 141 if (this.MaximumCabinetSizeForLargeFileSplitting != 0)
141 { 142 {
142 // User Specified Max Cab Size for File Splitting, So Check if this cabinet has a single file larger than MaximumUncompressedFileSize 143 // User Specified Max Cab Size for File Splitting, So Check if this cabinet has a single file larger than MaximumUncompressedFileSize
143 // If a file is larger than MaximumUncompressedFileSize, then the cabinet containing it will have only this file 144 // If a file is larger than MaximumUncompressedFileSize, then the cabinet containing it will have only this file
@@ -152,26 +153,33 @@ namespace WixToolset.Core.WindowsInstaller.Bind
152 if ((ulong)facade.File.FileSize >= maxPreCompressedSizeInBytes) 153 if ((ulong)facade.File.FileSize >= maxPreCompressedSizeInBytes)
153 { 154 {
154 // If file is larger than MaximumUncompressedFileSize set Maximum Cabinet Size for Cabinet Splitting 155 // If file is larger than MaximumUncompressedFileSize set Maximum Cabinet Size for Cabinet Splitting
155 maxCabinetSize = MaximumCabinetSizeForLargeFileSplitting; 156 maxCabinetSize = this.MaximumCabinetSizeForLargeFileSplitting;
156 } 157 }
157 } 158 }
158 } 159 }
159 } 160 }
160 161
161 // create the cabinet file 162 // create the cabinet file
163 var cabinetPath = Path.GetFullPath(cabinetWorkItem.CabinetFile);
162 string cabinetFileName = Path.GetFileName(cabinetWorkItem.CabinetFile); 164 string cabinetFileName = Path.GetFileName(cabinetWorkItem.CabinetFile);
163 string cabinetDirectory = Path.GetDirectoryName(cabinetWorkItem.CabinetFile); 165 string cabinetDirectory = Path.GetDirectoryName(cabinetWorkItem.CabinetFile);
164 166
165 using (WixCreateCab cab = new WixCreateCab(cabinetFileName, cabinetDirectory, cabinetWorkItem.FileFacades.Count(), maxCabinetSize, cabinetWorkItem.MaxThreshold, cabinetWorkItem.CompressionLevel)) 167 //using (WixCreateCab cab = new WixCreateCab(cabinetFileName, cabinetDirectory, cabinetWorkItem.FileFacades.Count(), maxCabinetSize, cabinetWorkItem.MaxThreshold, cabinetWorkItem.CompressionLevel))
166 { 168 //{
167 foreach (FileFacade facade in cabinetWorkItem.FileFacades) 169 // foreach (FileFacade facade in cabinetWorkItem.FileFacades)
168 { 170 // {
169 cab.AddFile(facade); 171 // cab.AddFile(facade);
170 } 172 // }
171 173
172 cab.Complete(newCabNamesCallBackAddress); 174 // cab.Complete(newCabNamesCallBackAddress);
173 } 175 //}
176
177 var files = cabinetWorkItem.FileFacades.Select(facade => new CabinetCompressFile(facade.WixFile.Source.Path, facade.File.File, facade.Hash.HashPart1, facade.Hash.HashPart2, facade.Hash.HashPart3, facade.Hash.HashPart4)).ToList();
178
179 var cabinetCompressionLevel = (CabinetCompressionLevel)cabinetWorkItem.CompressionLevel;
180
181 var cab = new Cabinet(cabinetPath);
182 cab.Compress(files, cabinetCompressionLevel, maxCabinetSize, cabinetWorkItem.MaxThreshold);
174 } 183 }
175 } 184 }
176} 185}
177