ICSharpCode.SharpZipLib.Zip.FastZip.ExtractFileEntry C# (CSharp) Method

ExtractFileEntry() private method

private ExtractFileEntry ( ZipEntry entry, string targetName ) : void
entry ZipEntry
targetName string
return void
        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];
                            }
                            if ((events_ != null) && (events_.Progress != null)) {
                                StreamUtils.Copy(zipFile_.GetInputStream(entry), outputStream, buffer_,
                                    events_.Progress, events_.ProgressInterval, this, entry.Name, entry.Size);
                            } else {
                                StreamUtils.Copy(zipFile_.GetInputStream(entry), outputStream, buffer_);
                            }

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

                        if (restoreDateTimeOnExtract_) {
                            File.SetLastWriteTime(targetName, entry.DateTime);
                        }

                        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;
                        }
                    }
                }
            }
        }