@@ -375,6 +375,49 @@ public void CreateZip(Stream outputStream, string sourceDirectory, bool recurse,
375375 /// <param name="directoryFilter">The <see cref="PathFilter">directory filter</see> to apply.</param>
376376 /// <param name="leaveOpen">true to leave <paramref name="outputStream"/> open after the zip has been created, false to dispose it.</param>
377377 public void CreateZip ( Stream outputStream , string sourceDirectory , bool recurse , string fileFilter , string directoryFilter , bool leaveOpen )
378+ {
379+ var scanner = new FileSystemScanner ( fileFilter , directoryFilter ) ;
380+ CreateZip ( outputStream , sourceDirectory , recurse , scanner , leaveOpen ) ;
381+ }
382+
383+ /// <summary>
384+ /// Create a zip file.
385+ /// </summary>
386+ /// <param name="zipFileName">The name of the zip file to create.</param>
387+ /// <param name="sourceDirectory">The directory to source files from.</param>
388+ /// <param name="recurse">True to recurse directories, false for no recursion.</param>
389+ /// <param name="fileFilter">The <see cref="IScanFilter">file filter</see> to apply.</param>
390+ /// <param name="directoryFilter">The <see cref="IScanFilter">directory filter</see> to apply.</param>
391+ public void CreateZip ( string zipFileName , string sourceDirectory ,
392+ bool recurse , IScanFilter fileFilter , IScanFilter directoryFilter )
393+ {
394+ CreateZip ( File . Create ( zipFileName ) , sourceDirectory , recurse , fileFilter , directoryFilter , false ) ;
395+ }
396+
397+ /// <summary>
398+ /// Create a zip archive sending output to the <paramref name="outputStream"/> passed.
399+ /// </summary>
400+ /// <param name="outputStream">The stream to write archive data to.</param>
401+ /// <param name="sourceDirectory">The directory to source files from.</param>
402+ /// <param name="recurse">True to recurse directories, false for no recursion.</param>
403+ /// <param name="fileFilter">The <see cref="IScanFilter">file filter</see> to apply.</param>
404+ /// <param name="directoryFilter">The <see cref="IScanFilter">directory filter</see> to apply.</param>
405+ /// <param name="leaveOpen">true to leave <paramref name="outputStream"/> open after the zip has been created, false to dispose it.</param>
406+ public void CreateZip ( Stream outputStream , string sourceDirectory , bool recurse , IScanFilter fileFilter , IScanFilter directoryFilter , bool leaveOpen = false )
407+ {
408+ var scanner = new FileSystemScanner ( fileFilter , directoryFilter ) ;
409+ CreateZip ( outputStream , sourceDirectory , recurse , scanner , leaveOpen ) ;
410+ }
411+
412+ /// <summary>
413+ /// Create a zip archive sending output to the <paramref name="outputStream"/> passed.
414+ /// </summary>
415+ /// <param name="outputStream">The stream to write archive data to.</param>
416+ /// <param name="sourceDirectory">The directory to source files from.</param>
417+ /// <param name="recurse">True to recurse directories, false for no recursion.</param>
418+ /// <param name="scanner">For performing the actual file system scan</param>
419+ /// <remarks>The <paramref name="outputStream"/> is closed after creation.</remarks>
420+ private void CreateZip ( Stream outputStream , string sourceDirectory , bool recurse , FileSystemScanner scanner , bool leaveOpen )
378421 {
379422 NameTransform = new ZipNameTransform ( sourceDirectory ) ;
380423 sourceDirectory_ = sourceDirectory ;
@@ -390,7 +433,6 @@ public void CreateZip(Stream outputStream, string sourceDirectory, bool recurse,
390433 }
391434
392435 outputStream_ . UseZip64 = UseZip64 ;
393- var scanner = new FileSystemScanner ( fileFilter , directoryFilter ) ;
394436 scanner . ProcessFile += ProcessFile ;
395437 if ( this . CreateEmptyDirectories )
396438 {
0 commit comments