scripts
This commit is contained in:
@@ -0,0 +1,512 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using ICSharpCode.SharpZipLib.Core;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Zip
|
||||
{
|
||||
// Token: 0x0200004B RID: 75
|
||||
public class FastZip
|
||||
{
|
||||
// Token: 0x060002F0 RID: 752 RVA: 0x0001094A File Offset: 0x0000F94A
|
||||
public FastZip()
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x060002F1 RID: 753 RVA: 0x00010964 File Offset: 0x0000F964
|
||||
public FastZip(FastZipEvents events)
|
||||
{
|
||||
this.events_ = events;
|
||||
}
|
||||
|
||||
// Token: 0x1700009E RID: 158
|
||||
// (get) Token: 0x060002F2 RID: 754 RVA: 0x00010985 File Offset: 0x0000F985
|
||||
// (set) Token: 0x060002F3 RID: 755 RVA: 0x0001098D File Offset: 0x0000F98D
|
||||
public bool CreateEmptyDirectories
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.createEmptyDirectories_;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.createEmptyDirectories_ = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700009F RID: 159
|
||||
// (get) Token: 0x060002F4 RID: 756 RVA: 0x00010996 File Offset: 0x0000F996
|
||||
// (set) Token: 0x060002F5 RID: 757 RVA: 0x0001099E File Offset: 0x0000F99E
|
||||
public string Password
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.password_;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.password_ = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170000A0 RID: 160
|
||||
// (get) Token: 0x060002F6 RID: 758 RVA: 0x000109A7 File Offset: 0x0000F9A7
|
||||
// (set) Token: 0x060002F7 RID: 759 RVA: 0x000109B4 File Offset: 0x0000F9B4
|
||||
public INameTransform NameTransform
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.entryFactory_.NameTransform;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.entryFactory_.NameTransform = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170000A1 RID: 161
|
||||
// (get) Token: 0x060002F8 RID: 760 RVA: 0x000109C2 File Offset: 0x0000F9C2
|
||||
// (set) Token: 0x060002F9 RID: 761 RVA: 0x000109CA File Offset: 0x0000F9CA
|
||||
public IEntryFactory EntryFactory
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.entryFactory_;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
this.entryFactory_ = new ZipEntryFactory();
|
||||
return;
|
||||
}
|
||||
this.entryFactory_ = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170000A2 RID: 162
|
||||
// (get) Token: 0x060002FA RID: 762 RVA: 0x000109E2 File Offset: 0x0000F9E2
|
||||
// (set) Token: 0x060002FB RID: 763 RVA: 0x000109EA File Offset: 0x0000F9EA
|
||||
public UseZip64 UseZip64
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.useZip64_;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.useZip64_ = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170000A3 RID: 163
|
||||
// (get) Token: 0x060002FC RID: 764 RVA: 0x000109F3 File Offset: 0x0000F9F3
|
||||
// (set) Token: 0x060002FD RID: 765 RVA: 0x000109FB File Offset: 0x0000F9FB
|
||||
public bool RestoreDateTimeOnExtract
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.restoreDateTimeOnExtract_;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.restoreDateTimeOnExtract_ = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x170000A4 RID: 164
|
||||
// (get) Token: 0x060002FE RID: 766 RVA: 0x00010A04 File Offset: 0x0000FA04
|
||||
// (set) Token: 0x060002FF RID: 767 RVA: 0x00010A0C File Offset: 0x0000FA0C
|
||||
public bool RestoreAttributesOnExtract
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.restoreAttributesOnExtract_;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.restoreAttributesOnExtract_ = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000300 RID: 768 RVA: 0x00010A15 File Offset: 0x0000FA15
|
||||
public void CreateZip(string zipFileName, string sourceDirectory, bool recurse, string fileFilter, string directoryFilter)
|
||||
{
|
||||
this.CreateZip(File.Create(zipFileName), sourceDirectory, recurse, fileFilter, directoryFilter);
|
||||
}
|
||||
|
||||
// Token: 0x06000301 RID: 769 RVA: 0x00010A29 File Offset: 0x0000FA29
|
||||
public void CreateZip(string zipFileName, string sourceDirectory, bool recurse, string fileFilter)
|
||||
{
|
||||
this.CreateZip(File.Create(zipFileName), sourceDirectory, recurse, fileFilter, null);
|
||||
}
|
||||
|
||||
// Token: 0x06000302 RID: 770 RVA: 0x00010A3C File Offset: 0x0000FA3C
|
||||
public void CreateZip(Stream outputStream, string sourceDirectory, bool recurse, string fileFilter, string directoryFilter)
|
||||
{
|
||||
this.NameTransform = new ZipNameTransform(sourceDirectory);
|
||||
this.sourceDirectory_ = sourceDirectory;
|
||||
using (this.outputStream_ = new ZipOutputStream(outputStream))
|
||||
{
|
||||
if (this.password_ != null)
|
||||
{
|
||||
this.outputStream_.Password = this.password_;
|
||||
}
|
||||
this.outputStream_.UseZip64 = this.UseZip64;
|
||||
FileSystemScanner fileSystemScanner = new FileSystemScanner(fileFilter, directoryFilter);
|
||||
FileSystemScanner fileSystemScanner2 = fileSystemScanner;
|
||||
fileSystemScanner2.ProcessFile = (ProcessFileHandler)Delegate.Combine(fileSystemScanner2.ProcessFile, new ProcessFileHandler(this.ProcessFile));
|
||||
if (this.CreateEmptyDirectories)
|
||||
{
|
||||
FileSystemScanner fileSystemScanner3 = fileSystemScanner;
|
||||
fileSystemScanner3.ProcessDirectory = (ProcessDirectoryHandler)Delegate.Combine(fileSystemScanner3.ProcessDirectory, new ProcessDirectoryHandler(this.ProcessDirectory));
|
||||
}
|
||||
if (this.events_ != null)
|
||||
{
|
||||
if (this.events_.FileFailure != null)
|
||||
{
|
||||
FileSystemScanner fileSystemScanner4 = fileSystemScanner;
|
||||
fileSystemScanner4.FileFailure = (FileFailureHandler)Delegate.Combine(fileSystemScanner4.FileFailure, this.events_.FileFailure);
|
||||
}
|
||||
if (this.events_.DirectoryFailure != null)
|
||||
{
|
||||
FileSystemScanner fileSystemScanner5 = fileSystemScanner;
|
||||
fileSystemScanner5.DirectoryFailure = (DirectoryFailureHandler)Delegate.Combine(fileSystemScanner5.DirectoryFailure, this.events_.DirectoryFailure);
|
||||
}
|
||||
}
|
||||
fileSystemScanner.Scan(sourceDirectory, recurse);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000303 RID: 771 RVA: 0x00010B74 File Offset: 0x0000FB74
|
||||
public void ExtractZip(string zipFileName, string targetDirectory, string fileFilter)
|
||||
{
|
||||
this.ExtractZip(zipFileName, targetDirectory, FastZip.Overwrite.Always, null, fileFilter, null, this.restoreDateTimeOnExtract_);
|
||||
}
|
||||
|
||||
// Token: 0x06000304 RID: 772 RVA: 0x00010B88 File Offset: 0x0000FB88
|
||||
public void ExtractZip(string zipFileName, string targetDirectory, FastZip.Overwrite overwrite, FastZip.ConfirmOverwriteDelegate confirmDelegate, string fileFilter, string directoryFilter, bool restoreDateTime)
|
||||
{
|
||||
Stream stream = File.Open(zipFileName, FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||
this.ExtractZip(stream, targetDirectory, overwrite, confirmDelegate, fileFilter, directoryFilter, restoreDateTime, true);
|
||||
}
|
||||
|
||||
// Token: 0x06000305 RID: 773 RVA: 0x00010BB4 File Offset: 0x0000FBB4
|
||||
public void ExtractZip(Stream inputStream, string targetDirectory, FastZip.Overwrite overwrite, FastZip.ConfirmOverwriteDelegate confirmDelegate, string fileFilter, string directoryFilter, bool restoreDateTime, bool isStreamOwner)
|
||||
{
|
||||
if (overwrite == FastZip.Overwrite.Prompt && confirmDelegate == null)
|
||||
{
|
||||
throw new ArgumentNullException("confirmDelegate");
|
||||
}
|
||||
this.continueRunning_ = true;
|
||||
this.overwrite_ = overwrite;
|
||||
this.confirmDelegate_ = confirmDelegate;
|
||||
this.extractNameTransform_ = new WindowsNameTransform(targetDirectory);
|
||||
this.fileFilter_ = new NameFilter(fileFilter);
|
||||
this.directoryFilter_ = new NameFilter(directoryFilter);
|
||||
this.restoreDateTimeOnExtract_ = restoreDateTime;
|
||||
using (this.zipFile_ = new ZipFile(inputStream))
|
||||
{
|
||||
if (this.password_ != null)
|
||||
{
|
||||
this.zipFile_.Password = this.password_;
|
||||
}
|
||||
this.zipFile_.IsStreamOwner = isStreamOwner;
|
||||
IEnumerator enumerator = this.zipFile_.GetEnumerator();
|
||||
while (this.continueRunning_ && enumerator.MoveNext())
|
||||
{
|
||||
ZipEntry zipEntry = (ZipEntry)enumerator.Current;
|
||||
if (zipEntry.IsFile)
|
||||
{
|
||||
if (this.directoryFilter_.IsMatch(Path.GetDirectoryName(zipEntry.Name)) && this.fileFilter_.IsMatch(zipEntry.Name))
|
||||
{
|
||||
this.ExtractEntry(zipEntry);
|
||||
}
|
||||
}
|
||||
else if (zipEntry.IsDirectory && this.directoryFilter_.IsMatch(zipEntry.Name) && this.CreateEmptyDirectories)
|
||||
{
|
||||
this.ExtractEntry(zipEntry);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000306 RID: 774 RVA: 0x00010CFC File Offset: 0x0000FCFC
|
||||
private void ProcessDirectory(object sender, DirectoryEventArgs e)
|
||||
{
|
||||
if (!e.HasMatchingFiles && this.CreateEmptyDirectories)
|
||||
{
|
||||
if (this.events_ != null)
|
||||
{
|
||||
this.events_.OnProcessDirectory(e.Name, e.HasMatchingFiles);
|
||||
}
|
||||
if (e.ContinueRunning && e.Name != this.sourceDirectory_)
|
||||
{
|
||||
ZipEntry zipEntry = this.entryFactory_.MakeDirectoryEntry(e.Name);
|
||||
this.outputStream_.PutNextEntry(zipEntry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000307 RID: 775 RVA: 0x00010D74 File Offset: 0x0000FD74
|
||||
private void ProcessFile(object sender, ScanEventArgs e)
|
||||
{
|
||||
if (this.events_ != null && this.events_.ProcessFile != null)
|
||||
{
|
||||
this.events_.ProcessFile(sender, e);
|
||||
}
|
||||
if (e.ContinueRunning)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (FileStream fileStream = File.Open(e.Name, FileMode.Open, FileAccess.Read, FileShare.Read))
|
||||
{
|
||||
ZipEntry zipEntry = this.entryFactory_.MakeFileEntry(e.Name);
|
||||
this.outputStream_.PutNextEntry(zipEntry);
|
||||
this.AddFileContents(e.Name, fileStream);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (this.events_ == null)
|
||||
{
|
||||
this.continueRunning_ = false;
|
||||
throw;
|
||||
}
|
||||
this.continueRunning_ = this.events_.OnFileFailure(e.Name, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000308 RID: 776 RVA: 0x00010E44 File Offset: 0x0000FE44
|
||||
private void AddFileContents(string name, Stream stream)
|
||||
{
|
||||
if (stream == null)
|
||||
{
|
||||
throw new ArgumentNullException("stream");
|
||||
}
|
||||
if (this.buffer_ == null)
|
||||
{
|
||||
this.buffer_ = new byte[4096];
|
||||
}
|
||||
if (this.events_ != null && this.events_.Progress != null)
|
||||
{
|
||||
StreamUtils.Copy(stream, this.outputStream_, this.buffer_, this.events_.Progress, this.events_.ProgressInterval, this, name);
|
||||
}
|
||||
else
|
||||
{
|
||||
StreamUtils.Copy(stream, this.outputStream_, this.buffer_);
|
||||
}
|
||||
if (this.events_ != null)
|
||||
{
|
||||
this.continueRunning_ = this.events_.OnCompletedFile(name);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000309 RID: 777 RVA: 0x00010EE4 File Offset: 0x0000FEE4
|
||||
private void ExtractFileEntry(ZipEntry entry, string targetName)
|
||||
{
|
||||
bool flag = true;
|
||||
if (this.overwrite_ != FastZip.Overwrite.Always && File.Exists(targetName))
|
||||
{
|
||||
flag = this.overwrite_ == FastZip.Overwrite.Prompt && this.confirmDelegate_ != null && this.confirmDelegate_(targetName);
|
||||
}
|
||||
if (flag)
|
||||
{
|
||||
if (this.events_ != null)
|
||||
{
|
||||
this.continueRunning_ = this.events_.OnProcessFile(entry.Name);
|
||||
}
|
||||
if (this.continueRunning_)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (FileStream fileStream = File.Create(targetName))
|
||||
{
|
||||
if (this.buffer_ == null)
|
||||
{
|
||||
this.buffer_ = new byte[4096];
|
||||
}
|
||||
if (this.events_ != null && this.events_.Progress != null)
|
||||
{
|
||||
StreamUtils.Copy(this.zipFile_.GetInputStream(entry), fileStream, this.buffer_, this.events_.Progress, this.events_.ProgressInterval, this, entry.Name, entry.Size);
|
||||
}
|
||||
else
|
||||
{
|
||||
StreamUtils.Copy(this.zipFile_.GetInputStream(entry), fileStream, this.buffer_);
|
||||
}
|
||||
if (this.events_ != null)
|
||||
{
|
||||
this.continueRunning_ = this.events_.OnCompletedFile(entry.Name);
|
||||
}
|
||||
}
|
||||
if (this.restoreDateTimeOnExtract_)
|
||||
{
|
||||
File.SetLastWriteTime(targetName, entry.DateTime);
|
||||
}
|
||||
if (this.RestoreAttributesOnExtract && entry.IsDOSEntry && entry.ExternalFileAttributes != -1)
|
||||
{
|
||||
FileAttributes fileAttributes = (FileAttributes)entry.ExternalFileAttributes;
|
||||
fileAttributes &= FileAttributes.Archive | FileAttributes.Hidden | FileAttributes.Normal | FileAttributes.ReadOnly;
|
||||
File.SetAttributes(targetName, fileAttributes);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (this.events_ == null)
|
||||
{
|
||||
this.continueRunning_ = false;
|
||||
throw;
|
||||
}
|
||||
this.continueRunning_ = this.events_.OnFileFailure(targetName, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600030A RID: 778 RVA: 0x00011094 File Offset: 0x00010094
|
||||
private void ExtractEntry(ZipEntry entry)
|
||||
{
|
||||
bool flag = entry.IsCompressionMethodSupported();
|
||||
string text = entry.Name;
|
||||
if (flag)
|
||||
{
|
||||
if (entry.IsFile)
|
||||
{
|
||||
text = this.extractNameTransform_.TransformFile(text);
|
||||
}
|
||||
else if (entry.IsDirectory)
|
||||
{
|
||||
text = this.extractNameTransform_.TransformDirectory(text);
|
||||
}
|
||||
flag = text != null && text.Length != 0;
|
||||
}
|
||||
string text2 = null;
|
||||
if (flag)
|
||||
{
|
||||
if (entry.IsDirectory)
|
||||
{
|
||||
text2 = text;
|
||||
}
|
||||
else
|
||||
{
|
||||
text2 = Path.GetDirectoryName(Path.GetFullPath(text));
|
||||
}
|
||||
}
|
||||
if (flag && !Directory.Exists(text2))
|
||||
{
|
||||
if (entry.IsDirectory)
|
||||
{
|
||||
if (!this.CreateEmptyDirectories)
|
||||
{
|
||||
goto IL_D9;
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
Directory.CreateDirectory(text2);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
flag = false;
|
||||
if (this.events_ == null)
|
||||
{
|
||||
this.continueRunning_ = false;
|
||||
throw;
|
||||
}
|
||||
if (entry.IsDirectory)
|
||||
{
|
||||
this.continueRunning_ = this.events_.OnDirectoryFailure(text, ex);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.continueRunning_ = this.events_.OnFileFailure(text, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
IL_D9:
|
||||
if (flag && entry.IsFile)
|
||||
{
|
||||
this.ExtractFileEntry(entry, text);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600030B RID: 779 RVA: 0x000111A0 File Offset: 0x000101A0
|
||||
private static int MakeExternalAttributes(FileInfo info)
|
||||
{
|
||||
return (int)info.Attributes;
|
||||
}
|
||||
|
||||
// Token: 0x0600030C RID: 780 RVA: 0x000111A8 File Offset: 0x000101A8
|
||||
private static bool NameIsValid(string name)
|
||||
{
|
||||
return name != null && name.Length > 0 && name.IndexOfAny(Path.GetInvalidPathChars()) < 0;
|
||||
}
|
||||
|
||||
// Token: 0x04000209 RID: 521
|
||||
private bool continueRunning_;
|
||||
|
||||
// Token: 0x0400020A RID: 522
|
||||
private byte[] buffer_;
|
||||
|
||||
// Token: 0x0400020B RID: 523
|
||||
private ZipOutputStream outputStream_;
|
||||
|
||||
// Token: 0x0400020C RID: 524
|
||||
private ZipFile zipFile_;
|
||||
|
||||
// Token: 0x0400020D RID: 525
|
||||
private string sourceDirectory_;
|
||||
|
||||
// Token: 0x0400020E RID: 526
|
||||
private NameFilter fileFilter_;
|
||||
|
||||
// Token: 0x0400020F RID: 527
|
||||
private NameFilter directoryFilter_;
|
||||
|
||||
// Token: 0x04000210 RID: 528
|
||||
private FastZip.Overwrite overwrite_;
|
||||
|
||||
// Token: 0x04000211 RID: 529
|
||||
private FastZip.ConfirmOverwriteDelegate confirmDelegate_;
|
||||
|
||||
// Token: 0x04000212 RID: 530
|
||||
private bool restoreDateTimeOnExtract_;
|
||||
|
||||
// Token: 0x04000213 RID: 531
|
||||
private bool restoreAttributesOnExtract_;
|
||||
|
||||
// Token: 0x04000214 RID: 532
|
||||
private bool createEmptyDirectories_;
|
||||
|
||||
// Token: 0x04000215 RID: 533
|
||||
private FastZipEvents events_;
|
||||
|
||||
// Token: 0x04000216 RID: 534
|
||||
private IEntryFactory entryFactory_ = new ZipEntryFactory();
|
||||
|
||||
// Token: 0x04000217 RID: 535
|
||||
private INameTransform extractNameTransform_;
|
||||
|
||||
// Token: 0x04000218 RID: 536
|
||||
private UseZip64 useZip64_ = UseZip64.Dynamic;
|
||||
|
||||
// Token: 0x04000219 RID: 537
|
||||
private string password_;
|
||||
|
||||
// Token: 0x0200004C RID: 76
|
||||
public enum Overwrite
|
||||
{
|
||||
// Token: 0x0400021B RID: 539
|
||||
Prompt,
|
||||
// Token: 0x0400021C RID: 540
|
||||
Never,
|
||||
// Token: 0x0400021D RID: 541
|
||||
Always
|
||||
}
|
||||
|
||||
// Token: 0x0200004D RID: 77
|
||||
// (Invoke) Token: 0x0600030E RID: 782
|
||||
public delegate bool ConfirmOverwriteDelegate(string fileName);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user