private void ExtractFileEntry()

in src/ICSharpCode.SharpZipLib/Zip/FastZip.cs [732:846]


		private void ExtractFileEntry(ZipEntry entry, string targetName)
		{
			bool proceed = true;
			if (overwrite_ != Overwrite.Always)
			{
				if (File.Exists(targetName))
				{
					if ((overwrite_ == Overwrite.Prompt) && (confirmDelegate_ != null))
					{
						proceed = confirmDelegate_(targetName);
					}
					else
					{
						proceed = false;
					}
				}
			}

			if (proceed)
			{
				if (events_ != null)
				{
					continueRunning_ = events_.OnProcessFile(entry.Name);
				}

				if (continueRunning_)
				{
					try
					{
						using (FileStream outputStream = File.Create(targetName))
						{
							if (buffer_ == null)
							{
								buffer_ = new byte[4096];
							}

							using (var inputStream = zipFile_.GetInputStream(entry))
							{
								if ((events_ != null) && (events_.Progress != null))
								{
									StreamUtils.Copy(inputStream, outputStream, buffer_,
										events_.Progress, events_.ProgressInterval, this, entry.Name, entry.Size);
								}
								else
								{
									StreamUtils.Copy(inputStream, outputStream, buffer_);
								}
							}

							if (events_ != null)
							{
								continueRunning_ = events_.OnCompletedFile(entry.Name);
							}
						}

						if (restoreDateTimeOnExtract_)
						{
							switch (entryFactory_.Setting)
							{
								case TimeSetting.CreateTime:
									File.SetCreationTime(targetName, entry.DateTime);
									break;

								case TimeSetting.CreateTimeUtc:
									File.SetCreationTimeUtc(targetName, entry.DateTime);
									break;

								case TimeSetting.LastAccessTime:
									File.SetLastAccessTime(targetName, entry.DateTime);
									break;

								case TimeSetting.LastAccessTimeUtc:
									File.SetLastAccessTimeUtc(targetName, entry.DateTime);
									break;

								case TimeSetting.LastWriteTime:
									File.SetLastWriteTime(targetName, entry.DateTime);
									break;

								case TimeSetting.LastWriteTimeUtc:
									File.SetLastWriteTimeUtc(targetName, entry.DateTime);
									break;

								case TimeSetting.Fixed:
									File.SetLastWriteTime(targetName, entryFactory_.FixedDateTime);
									break;

								default:
									throw new ZipException("Unhandled time setting in ExtractFileEntry");
							}
						}

						if (RestoreAttributesOnExtract && entry.IsDOSEntry && (entry.ExternalFileAttributes != -1))
						{
							var fileAttributes = (FileAttributes)entry.ExternalFileAttributes;
							// TODO: FastZip - Setting of other file attributes on extraction is a little trickier.
							fileAttributes &= (FileAttributes.Archive | FileAttributes.Normal | FileAttributes.ReadOnly | FileAttributes.Hidden);
							File.SetAttributes(targetName, fileAttributes);
						}
					}
					catch (Exception ex)
					{
						if (events_ != null)
						{
							continueRunning_ = events_.OnFileFailure(targetName, ex);
						}
						else
						{
							continueRunning_ = false;
							throw;
						}
					}
				}
			}
		}