Skip to content

Commit

Permalink
PR #201: Raise ProcessDirectory event for FastZip extract
Browse files Browse the repository at this point in the history
FastZip's ExtractZip method did not raise the ProcessDirectory event when
creating a directory.  There was no way to determine or control when
ExtractZip decided to create a new directory.

NOTE: The logic to raise the event only triggers when the target directory
doesn't already exist in the destination.
  • Loading branch information
Stevie-O authored Aug 15, 2020
1 parent 63e7e70 commit c557266
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/ICSharpCode.SharpZipLib/Zip/FastZip.cs
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,7 @@ private void ExtractEntry(ZipEntry entry)

// TODO: Fire delegate/throw exception were compression method not supported, or name is invalid?

string dirName = null;
string dirName = string.Empty;

if (doExtraction)
{
Expand All @@ -803,11 +803,18 @@ private void ExtractEntry(ZipEntry entry)
{
try
{
Directory.CreateDirectory(dirName);

if (entry.IsDirectory && restoreDateTimeOnExtract_)
continueRunning_ = events_?.OnProcessDirectory(dirName, true) ?? true;
if (continueRunning_)
{
Directory.CreateDirectory(dirName);
if (entry.IsDirectory && restoreDateTimeOnExtract_)
{
Directory.SetLastWriteTime(dirName, entry.DateTime);
}
}
else
{
Directory.SetLastWriteTime(dirName, entry.DateTime);
doExtraction = false;
}
}
catch (Exception ex)
Expand Down

0 comments on commit c557266

Please sign in to comment.