private void ExtractFileEntry(ZipEntry entry, string targetName)
{
bool flag = true;
if (overwrite_ != Overwrite.Always && File.Exists(targetName))
{
flag = (overwrite_ == Overwrite.Prompt && confirmDelegate_ != null && confirmDelegate_(targetName));
}
if (flag)
{
if (events_ != null)
{
continueRunning_ = events_.OnProcessFile(entry.Name);
}
if (continueRunning_)
{
try
{
using (FileStream destination = File.Create(targetName))
{
if (buffer_ == null)
{
buffer_ = new byte[4096];
}
if (events_ != null && events_.Progress != null)
{
StreamUtils.Copy(zipFile_.GetInputStream(entry), destination, buffer_, events_.Progress, events_.ProgressInterval, this, entry.Name, entry.Size);
}
else
{
StreamUtils.Copy(zipFile_.GetInputStream(entry), destination, buffer_);
}
if (events_ != null)
{
continueRunning_ = events_.OnCompletedFile(entry.Name);
}
}
if (restoreDateTimeOnExtract_)
{
File.SetLastWriteTime(targetName, entry.DateTime);
}
if (RestoreAttributesOnExtract && entry.IsDOSEntry && entry.ExternalFileAttributes != -1)
{
FileAttributes externalFileAttributes = (FileAttributes)entry.ExternalFileAttributes;
externalFileAttributes &= (FileAttributes.ReadOnly | FileAttributes.Hidden | FileAttributes.Archive | FileAttributes.Normal);
File.SetAttributes(targetName, externalFileAttributes);
}
}
catch (Exception e)
{
if (events_ == null)
{
continueRunning_ = false;
throw;
}
continueRunning_ = events_.OnFileFailure(targetName, e);
}
}
}
}