Skip to content

Commit 64486cc

Browse files
author
Juergen Tem
committed
Add ability to set thread count for multithreaded compression through CustomParameters
1 parent 120ae9b commit 64486cc

1 file changed

Lines changed: 28 additions & 1 deletion

File tree

SevenZip/SevenZipCompressor.cs

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,13 +323,40 @@ private void SetCompressionProperties()
323323
values.Add(pv);
324324
foreach (var pair in CustomParameters)
325325
{
326-
names.Add(Marshal.StringToBSTR(pair.Key));
326+
if (pair.Key == "mt")
327+
{
328+
if (_compressionMethod == CompressionMethod.Lzma2 ||
329+
_compressionMethod == CompressionMethod.Lzma ||
330+
_compressionMethod == CompressionMethod.BZip2)
331+
{
332+
names.Add(Marshal.StringToBSTR(pair.Key));
333+
}
334+
}
335+
else
336+
names.Add(Marshal.StringToBSTR(pair.Key));
337+
327338
pv = new PropVariant();
339+
328340
if (pair.Key == "fb" || pair.Key == "pass" || pair.Key == "d")
329341
{
330342
pv.VarType = VarEnum.VT_UI4;
331343
pv.UInt32Value = Convert.ToUInt32(pair.Value, CultureInfo.InvariantCulture);
332344
}
345+
else if (pair.Key == "mt" && (_compressionMethod == CompressionMethod.Lzma2 ||
346+
_compressionMethod == CompressionMethod.Lzma ||
347+
_compressionMethod == CompressionMethod.BZip2))
348+
{
349+
if (pair.Value == "on" || pair.Value == "off")
350+
{
351+
pv.VarType = VarEnum.VT_BSTR;
352+
pv.Value = Marshal.StringToBSTR(pair.Value);
353+
}
354+
else
355+
{
356+
pv.VarType = VarEnum.VT_UI4;
357+
pv.UInt32Value = Convert.ToUInt32(pair.Value, CultureInfo.InvariantCulture);
358+
}
359+
}
333360
else
334361
{
335362
pv.VarType = VarEnum.VT_BSTR;

0 commit comments

Comments
 (0)