Skip to content

Commit c557266

Browse files
authored
PR #201: Raise ProcessDirectory event for FastZip extract
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.
1 parent 63e7e70 commit c557266

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/ICSharpCode.SharpZipLib/Zip/FastZip.cs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,7 @@ private void ExtractEntry(ZipEntry entry)
783783

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

786-
string dirName = null;
786+
string dirName = string.Empty;
787787

788788
if (doExtraction)
789789
{
@@ -803,11 +803,18 @@ private void ExtractEntry(ZipEntry entry)
803803
{
804804
try
805805
{
806-
Directory.CreateDirectory(dirName);
807-
808-
if (entry.IsDirectory && restoreDateTimeOnExtract_)
806+
continueRunning_ = events_?.OnProcessDirectory(dirName, true) ?? true;
807+
if (continueRunning_)
808+
{
809+
Directory.CreateDirectory(dirName);
810+
if (entry.IsDirectory && restoreDateTimeOnExtract_)
811+
{
812+
Directory.SetLastWriteTime(dirName, entry.DateTime);
813+
}
814+
}
815+
else
809816
{
810-
Directory.SetLastWriteTime(dirName, entry.DateTime);
817+
doExtraction = false;
811818
}
812819
}
813820
catch (Exception ex)

0 commit comments

Comments
 (0)