|
1 | 1 | using System;
|
2 | 2 | using System.IO;
|
3 | 3 | using ICSharpCode.SharpZipLib.Core;
|
| 4 | +using ICSharpCode.SharpZipLib.Zip.Compression; |
| 5 | +using static ICSharpCode.SharpZipLib.Zip.Compression.Deflater; |
4 | 6 |
|
5 | 7 | namespace ICSharpCode.SharpZipLib.Zip
|
6 | 8 | {
|
@@ -170,6 +172,7 @@ public enum Overwrite
|
170 | 172 | /// </summary>
|
171 | 173 | Always
|
172 | 174 | }
|
| 175 | + |
173 | 176 | #endregion
|
174 | 177 |
|
175 | 178 | #region Constructors
|
@@ -263,13 +266,22 @@ public bool RestoreDateTimeOnExtract {
|
263 | 266 | }
|
264 | 267 |
|
265 | 268 | /// <summary>
|
266 |
| - /// Get/set a value indicating wether file attributes should |
| 269 | + /// Get/set a value indicating whether file attributes should |
267 | 270 | /// be restored during extract operations
|
268 | 271 | /// </summary>
|
269 | 272 | public bool RestoreAttributesOnExtract {
|
270 | 273 | get { return restoreAttributesOnExtract_; }
|
271 | 274 | set { restoreAttributesOnExtract_ = value; }
|
272 | 275 | }
|
| 276 | + |
| 277 | + /// <summary> |
| 278 | + /// Get/set the Compression Level that will be used |
| 279 | + /// when creating the zip |
| 280 | + /// </summary> |
| 281 | + public Deflater.CompressionLevel CompressionLevel{ |
| 282 | + get { return compressionLevel_; } |
| 283 | + set { compressionLevel_ = value; } |
| 284 | + } |
273 | 285 | #endregion
|
274 | 286 |
|
275 | 287 | #region Delegates
|
@@ -322,6 +334,8 @@ public void CreateZip(Stream outputStream, string sourceDirectory, bool recurse,
|
322 | 334 |
|
323 | 335 | using (outputStream_ = new ZipOutputStream(outputStream)) {
|
324 | 336 |
|
| 337 | + outputStream_.SetLevel((int)CompressionLevel); |
| 338 | + |
325 | 339 | if (password_ != null) {
|
326 | 340 | outputStream_.Password = password_;
|
327 | 341 | }
|
@@ -640,8 +654,9 @@ static bool NameIsValid(string name)
|
640 | 654 | IEntryFactory entryFactory_ = new ZipEntryFactory();
|
641 | 655 | INameTransform extractNameTransform_;
|
642 | 656 | UseZip64 useZip64_ = UseZip64.Dynamic;
|
| 657 | + CompressionLevel compressionLevel_ = CompressionLevel.DEFAULT_COMPRESSION; |
643 | 658 |
|
644 |
| - string password_; |
| 659 | + string password_; |
645 | 660 |
|
646 | 661 | #endregion
|
647 | 662 | }
|
|
0 commit comments