Files
2026-06-04 11:42:34 +02:00

2984 lines
79 KiB
C#

using System;
using System.Collections;
using System.Globalization;
using System.IO;
using System.Runtime.CompilerServices;
using System.Security.Cryptography;
using System.Text;
using ICSharpCode.SharpZipLib.Checksums;
using ICSharpCode.SharpZipLib.Core;
using ICSharpCode.SharpZipLib.Encryption;
using ICSharpCode.SharpZipLib.Zip.Compression;
using ICSharpCode.SharpZipLib.Zip.Compression.Streams;
namespace ICSharpCode.SharpZipLib.Zip
{
// Token: 0x02000068 RID: 104
public class ZipFile : IEnumerable, IDisposable
{
// Token: 0x060003D9 RID: 985 RVA: 0x000132E8 File Offset: 0x000122E8
private void OnKeysRequired(string fileName)
{
if (this.KeysRequired != null)
{
KeysRequiredEventArgs keysRequiredEventArgs = new KeysRequiredEventArgs(fileName, this.key);
this.KeysRequired(this, keysRequiredEventArgs);
this.key = keysRequiredEventArgs.Key;
}
}
// Token: 0x170000E7 RID: 231
// (get) Token: 0x060003DA RID: 986 RVA: 0x00013323 File Offset: 0x00012323
// (set) Token: 0x060003DB RID: 987 RVA: 0x0001332B File Offset: 0x0001232B
private byte[] Key
{
get
{
return this.key;
}
set
{
this.key = value;
}
}
// Token: 0x170000E8 RID: 232
// (set) Token: 0x060003DC RID: 988 RVA: 0x00013334 File Offset: 0x00012334
public string Password
{
set
{
if (value == null || value.Length == 0)
{
this.key = null;
return;
}
this.rawPassword_ = value;
this.key = PkzipClassic.GenerateKeys(ZipConstants.ConvertToArray(value));
}
}
// Token: 0x170000E9 RID: 233
// (get) Token: 0x060003DD RID: 989 RVA: 0x00013361 File Offset: 0x00012361
private bool HaveKeys
{
get
{
return this.key != null;
}
}
// Token: 0x060003DE RID: 990 RVA: 0x00013370 File Offset: 0x00012370
public ZipFile(string name)
{
if (name == null)
{
throw new ArgumentNullException("name");
}
this.name_ = name;
this.baseStream_ = File.Open(name, FileMode.Open, FileAccess.Read, FileShare.Read);
this.isStreamOwner = true;
try
{
this.ReadEntries();
}
catch
{
this.DisposeInternal(true);
throw;
}
}
// Token: 0x060003DF RID: 991 RVA: 0x000133F0 File Offset: 0x000123F0
public ZipFile(FileStream file)
{
if (file == null)
{
throw new ArgumentNullException("file");
}
if (!file.CanSeek)
{
throw new ArgumentException("Stream is not seekable", "file");
}
this.baseStream_ = file;
this.name_ = file.Name;
this.isStreamOwner = true;
try
{
this.ReadEntries();
}
catch
{
this.DisposeInternal(true);
throw;
}
}
// Token: 0x060003E0 RID: 992 RVA: 0x00013484 File Offset: 0x00012484
public ZipFile(Stream stream)
{
if (stream == null)
{
throw new ArgumentNullException("stream");
}
if (!stream.CanSeek)
{
throw new ArgumentException("Stream is not seekable", "stream");
}
this.baseStream_ = stream;
this.isStreamOwner = true;
if (this.baseStream_.Length > 0L)
{
try
{
this.ReadEntries();
return;
}
catch
{
this.DisposeInternal(true);
throw;
}
}
this.entries_ = new ZipEntry[0];
this.isNewArchive_ = true;
}
// Token: 0x060003E1 RID: 993 RVA: 0x0001352C File Offset: 0x0001252C
internal ZipFile()
{
this.entries_ = new ZipEntry[0];
this.isNewArchive_ = true;
}
// Token: 0x060003E2 RID: 994 RVA: 0x00013564 File Offset: 0x00012564
~ZipFile()
{
this.Dispose(false);
}
// Token: 0x060003E3 RID: 995 RVA: 0x00013594 File Offset: 0x00012594
public void Close()
{
this.DisposeInternal(true);
GC.SuppressFinalize(this);
}
// Token: 0x060003E4 RID: 996 RVA: 0x000135A4 File Offset: 0x000125A4
public static ZipFile Create(string fileName)
{
if (fileName == null)
{
throw new ArgumentNullException("fileName");
}
FileStream fileStream = File.Create(fileName);
return new ZipFile
{
name_ = fileName,
baseStream_ = fileStream,
isStreamOwner = true
};
}
// Token: 0x060003E5 RID: 997 RVA: 0x000135E4 File Offset: 0x000125E4
public static ZipFile Create(Stream outStream)
{
if (outStream == null)
{
throw new ArgumentNullException("outStream");
}
if (!outStream.CanWrite)
{
throw new ArgumentException("Stream is not writeable", "outStream");
}
if (!outStream.CanSeek)
{
throw new ArgumentException("Stream is not seekable", "outStream");
}
return new ZipFile
{
baseStream_ = outStream
};
}
// Token: 0x170000EA RID: 234
// (get) Token: 0x060003E6 RID: 998 RVA: 0x0001363D File Offset: 0x0001263D
// (set) Token: 0x060003E7 RID: 999 RVA: 0x00013645 File Offset: 0x00012645
public bool IsStreamOwner
{
get
{
return this.isStreamOwner;
}
set
{
this.isStreamOwner = value;
}
}
// Token: 0x170000EB RID: 235
// (get) Token: 0x060003E8 RID: 1000 RVA: 0x0001364E File Offset: 0x0001264E
public bool IsEmbeddedArchive
{
get
{
return this.offsetOfFirstEntry > 0L;
}
}
// Token: 0x170000EC RID: 236
// (get) Token: 0x060003E9 RID: 1001 RVA: 0x0001365A File Offset: 0x0001265A
public bool IsNewArchive
{
get
{
return this.isNewArchive_;
}
}
// Token: 0x170000ED RID: 237
// (get) Token: 0x060003EA RID: 1002 RVA: 0x00013662 File Offset: 0x00012662
public string ZipFileComment
{
get
{
return this.comment_;
}
}
// Token: 0x170000EE RID: 238
// (get) Token: 0x060003EB RID: 1003 RVA: 0x0001366A File Offset: 0x0001266A
public string Name
{
get
{
return this.name_;
}
}
// Token: 0x170000EF RID: 239
// (get) Token: 0x060003EC RID: 1004 RVA: 0x00013672 File Offset: 0x00012672
[Obsolete("Use the Count property instead")]
public int Size
{
get
{
return this.entries_.Length;
}
}
// Token: 0x170000F0 RID: 240
// (get) Token: 0x060003ED RID: 1005 RVA: 0x0001367C File Offset: 0x0001267C
public long Count
{
get
{
return (long)this.entries_.Length;
}
}
// Token: 0x170000F1 RID: 241
[IndexerName("EntryByIndex")]
public ZipEntry this[int index]
{
get
{
return (ZipEntry)this.entries_[index].Clone();
}
}
// Token: 0x060003EF RID: 1007 RVA: 0x0001369B File Offset: 0x0001269B
public IEnumerator GetEnumerator()
{
if (this.isDisposed_)
{
throw new ObjectDisposedException("ZipFile");
}
return new ZipFile.ZipEntryEnumerator(this.entries_);
}
// Token: 0x060003F0 RID: 1008 RVA: 0x000136BC File Offset: 0x000126BC
public int FindEntry(string name, bool ignoreCase)
{
if (this.isDisposed_)
{
throw new ObjectDisposedException("ZipFile");
}
for (int i = 0; i < this.entries_.Length; i++)
{
if (string.Compare(name, this.entries_[i].Name, ignoreCase, CultureInfo.InvariantCulture) == 0)
{
return i;
}
}
return -1;
}
// Token: 0x060003F1 RID: 1009 RVA: 0x00013710 File Offset: 0x00012710
public ZipEntry GetEntry(string name)
{
if (this.isDisposed_)
{
throw new ObjectDisposedException("ZipFile");
}
int num = this.FindEntry(name, true);
if (num < 0)
{
return null;
}
return (ZipEntry)this.entries_[num].Clone();
}
// Token: 0x060003F2 RID: 1010 RVA: 0x00013754 File Offset: 0x00012754
public Stream GetInputStream(ZipEntry entry)
{
if (entry == null)
{
throw new ArgumentNullException("entry");
}
if (this.isDisposed_)
{
throw new ObjectDisposedException("ZipFile");
}
long num = entry.ZipFileIndex;
if (num < 0L || num >= (long)this.entries_.Length || this.entries_[(int)(checked((IntPtr)num))].Name != entry.Name)
{
num = (long)this.FindEntry(entry.Name, true);
if (num < 0L)
{
throw new ZipException("Entry cannot be found");
}
}
return this.GetInputStream(num);
}
// Token: 0x060003F3 RID: 1011 RVA: 0x000137DC File Offset: 0x000127DC
public Stream GetInputStream(long entryIndex)
{
if (this.isDisposed_)
{
throw new ObjectDisposedException("ZipFile");
}
checked
{
long num = this.LocateEntry(this.entries_[(int)((IntPtr)entryIndex)]);
CompressionMethod compressionMethod = this.entries_[(int)((IntPtr)entryIndex)].CompressionMethod;
Stream stream = new ZipFile.PartialInputStream(this, num, this.entries_[(int)((IntPtr)entryIndex)].CompressedSize);
if (this.entries_[(int)((IntPtr)entryIndex)].IsCrypted)
{
stream = this.CreateAndInitDecryptionStream(stream, this.entries_[(int)((IntPtr)entryIndex)]);
if (stream == null)
{
throw new ZipException("Unable to decrypt this entry");
}
}
CompressionMethod compressionMethod2 = compressionMethod;
if (compressionMethod2 != CompressionMethod.Stored)
{
if (compressionMethod2 != CompressionMethod.Deflated)
{
throw new ZipException("Unsupported compression method " + compressionMethod);
}
stream = new InflaterInputStream(stream, new Inflater(true));
}
return stream;
}
}
// Token: 0x060003F4 RID: 1012 RVA: 0x00013890 File Offset: 0x00012890
public bool TestArchive(bool testData)
{
return this.TestArchive(testData, TestStrategy.FindFirstError, null);
}
// Token: 0x060003F5 RID: 1013 RVA: 0x0001389C File Offset: 0x0001289C
public bool TestArchive(bool testData, TestStrategy strategy, ZipTestResultHandler resultHandler)
{
if (this.isDisposed_)
{
throw new ObjectDisposedException("ZipFile");
}
TestStatus testStatus = new TestStatus(this);
if (resultHandler != null)
{
resultHandler(testStatus, null);
}
ZipFile.HeaderTest headerTest = (testData ? (ZipFile.HeaderTest.Extract | ZipFile.HeaderTest.Header) : ZipFile.HeaderTest.Header);
bool flag = true;
try
{
int num = 0;
while (flag && (long)num < this.Count)
{
if (resultHandler != null)
{
testStatus.SetEntry(this[num]);
testStatus.SetOperation(TestOperation.EntryHeader);
resultHandler(testStatus, null);
}
try
{
this.TestLocalHeader(this[num], headerTest);
}
catch (ZipException ex)
{
testStatus.AddError();
if (resultHandler != null)
{
resultHandler(testStatus, string.Format("Exception during test - '{0}'", ex.Message));
}
if (strategy == TestStrategy.FindFirstError)
{
flag = false;
}
}
if (flag && testData && this[num].IsFile)
{
if (resultHandler != null)
{
testStatus.SetOperation(TestOperation.EntryData);
resultHandler(testStatus, null);
}
Crc32 crc = new Crc32();
using (Stream inputStream = this.GetInputStream(this[num]))
{
byte[] array = new byte[4096];
long num2 = 0L;
int num3;
while ((num3 = inputStream.Read(array, 0, array.Length)) > 0)
{
crc.Update(array, 0, num3);
if (resultHandler != null)
{
num2 += (long)num3;
testStatus.SetBytesTested(num2);
resultHandler(testStatus, null);
}
}
}
if (this[num].Crc != crc.Value)
{
testStatus.AddError();
if (resultHandler != null)
{
resultHandler(testStatus, "CRC mismatch");
}
if (strategy == TestStrategy.FindFirstError)
{
flag = false;
}
}
if ((this[num].Flags & 8) != 0)
{
ZipHelperStream zipHelperStream = new ZipHelperStream(this.baseStream_);
DescriptorData descriptorData = new DescriptorData();
zipHelperStream.ReadDataDescriptor(this[num].LocalHeaderRequiresZip64, descriptorData);
if (this[num].Crc != descriptorData.Crc)
{
testStatus.AddError();
}
if (this[num].CompressedSize != descriptorData.CompressedSize)
{
testStatus.AddError();
}
if (this[num].Size != descriptorData.Size)
{
testStatus.AddError();
}
}
}
if (resultHandler != null)
{
testStatus.SetOperation(TestOperation.EntryComplete);
resultHandler(testStatus, null);
}
num++;
}
if (resultHandler != null)
{
testStatus.SetOperation(TestOperation.MiscellaneousTests);
resultHandler(testStatus, null);
}
}
catch (Exception ex2)
{
testStatus.AddError();
if (resultHandler != null)
{
resultHandler(testStatus, string.Format("Exception during test - '{0}'", ex2.Message));
}
}
if (resultHandler != null)
{
testStatus.SetOperation(TestOperation.Complete);
testStatus.SetEntry(null);
resultHandler(testStatus, null);
}
return testStatus.ErrorCount == 0;
}
// Token: 0x060003F6 RID: 1014 RVA: 0x00013B60 File Offset: 0x00012B60
private long TestLocalHeader(ZipEntry entry, ZipFile.HeaderTest tests)
{
long num12;
lock (this.baseStream_)
{
bool flag = (tests & ZipFile.HeaderTest.Header) != (ZipFile.HeaderTest)0;
bool flag2 = (tests & ZipFile.HeaderTest.Extract) != (ZipFile.HeaderTest)0;
this.baseStream_.Seek(this.offsetOfFirstEntry + entry.Offset, SeekOrigin.Begin);
if (this.ReadLEUint() != 67324752U)
{
throw new ZipException(string.Format("Wrong local header signature @{0:X}", this.offsetOfFirstEntry + entry.Offset));
}
short num = (short)this.ReadLEUshort();
short num2 = (short)this.ReadLEUshort();
short num3 = (short)this.ReadLEUshort();
short num4 = (short)this.ReadLEUshort();
short num5 = (short)this.ReadLEUshort();
uint num6 = this.ReadLEUint();
long num7 = (long)((ulong)this.ReadLEUint());
long num8 = (long)((ulong)this.ReadLEUint());
int num9 = (int)this.ReadLEUshort();
int num10 = (int)this.ReadLEUshort();
byte[] array = new byte[num9];
StreamUtils.ReadFully(this.baseStream_, array);
byte[] array2 = new byte[num10];
StreamUtils.ReadFully(this.baseStream_, array2);
ZipExtraData zipExtraData = new ZipExtraData(array2);
if (zipExtraData.Find(1))
{
num8 = zipExtraData.ReadLong();
num7 = zipExtraData.ReadLong();
if ((num2 & 8) != 0)
{
if (num8 != -1L && num8 != entry.Size)
{
throw new ZipException("Size invalid for descriptor");
}
if (num7 != -1L && num7 != entry.CompressedSize)
{
throw new ZipException("Compressed size invalid for descriptor");
}
}
}
else if (num >= 45 && ((uint)num8 == 4294967295U || (uint)num7 == 4294967295U))
{
throw new ZipException("Required Zip64 extended information missing");
}
if (flag2 && entry.IsFile)
{
if (!entry.IsCompressionMethodSupported())
{
throw new ZipException("Compression method not supported");
}
if (num > 51 || (num > 20 && num < 45))
{
throw new ZipException(string.Format("Version required to extract this entry not supported ({0})", num));
}
if ((num2 & 12384) != 0)
{
throw new ZipException("The library does not support the zip version required to extract this entry");
}
}
if (flag)
{
if (num <= 63 && num != 10 && num != 11 && num != 20 && num != 21 && num != 25 && num != 27 && num != 45 && num != 46 && num != 50 && num != 51 && num != 52 && num != 61 && num != 62 && num != 63)
{
throw new ZipException(string.Format("Version required to extract this entry is invalid ({0})", num));
}
if (((int)num2 & 49168) != 0)
{
throw new ZipException("Reserved bit flags cannot be set.");
}
if ((num2 & 1) != 0 && num < 20)
{
throw new ZipException(string.Format("Version required to extract this entry is too low for encryption ({0})", num));
}
if ((num2 & 64) != 0)
{
if ((num2 & 1) == 0)
{
throw new ZipException("Strong encryption flag set but encryption flag is not set");
}
if (num < 50)
{
throw new ZipException(string.Format("Version required to extract this entry is too low for encryption ({0})", num));
}
}
if ((num2 & 32) != 0 && num < 27)
{
throw new ZipException(string.Format("Patched data requires higher version than ({0})", num));
}
if ((int)num2 != entry.Flags)
{
throw new ZipException("Central header/local header flags mismatch");
}
if (entry.CompressionMethod != (CompressionMethod)num3)
{
throw new ZipException("Central header/local header compression method mismatch");
}
if (entry.Version != (int)num)
{
throw new ZipException("Extract version mismatch");
}
if ((num2 & 64) != 0 && num < 62)
{
throw new ZipException("Strong encryption flag set but version not high enough");
}
if ((num2 & 8192) != 0 && (num4 != 0 || num5 != 0))
{
throw new ZipException("Header masked set but date/time values non-zero");
}
if ((num2 & 8) == 0 && num6 != (uint)entry.Crc)
{
throw new ZipException("Central header/local header crc mismatch");
}
if (num8 == 0L && num7 == 0L && num6 != 0U)
{
throw new ZipException("Invalid CRC for empty entry");
}
if (entry.Name.Length > num9)
{
throw new ZipException("File name length mismatch");
}
string text = ZipConstants.ConvertToStringExt((int)num2, array);
if (text != entry.Name)
{
throw new ZipException("Central header and local header file name mismatch");
}
if (entry.IsDirectory)
{
if (num8 > 0L)
{
throw new ZipException("Directory cannot have size");
}
if (entry.IsCrypted)
{
if (num7 > 14L)
{
throw new ZipException("Directory compressed size invalid");
}
}
else if (num7 > 2L)
{
throw new ZipException("Directory compressed size invalid");
}
}
if (!ZipNameTransform.IsValidName(text, true))
{
throw new ZipException("Name is invalid");
}
}
if ((num2 & 8) == 0 || num8 > 0L || num7 > 0L)
{
if (num8 != entry.Size)
{
throw new ZipException(string.Format("Size mismatch between central header({0}) and local header({1})", entry.Size, num8));
}
if (num7 != entry.CompressedSize && num7 != (long)((ulong)(-1)) && num7 != -1L)
{
throw new ZipException(string.Format("Compressed size mismatch between central header({0}) and local header({1})", entry.CompressedSize, num7));
}
}
int num11 = num9 + num10;
num12 = this.offsetOfFirstEntry + entry.Offset + 30L + (long)num11;
}
return num12;
}
// Token: 0x170000F2 RID: 242
// (get) Token: 0x060003F7 RID: 1015 RVA: 0x00014010 File Offset: 0x00013010
// (set) Token: 0x060003F8 RID: 1016 RVA: 0x0001401D File Offset: 0x0001301D
public INameTransform NameTransform
{
get
{
return this.updateEntryFactory_.NameTransform;
}
set
{
this.updateEntryFactory_.NameTransform = value;
}
}
// Token: 0x170000F3 RID: 243
// (get) Token: 0x060003F9 RID: 1017 RVA: 0x0001402B File Offset: 0x0001302B
// (set) Token: 0x060003FA RID: 1018 RVA: 0x00014033 File Offset: 0x00013033
public IEntryFactory EntryFactory
{
get
{
return this.updateEntryFactory_;
}
set
{
if (value == null)
{
this.updateEntryFactory_ = new ZipEntryFactory();
return;
}
this.updateEntryFactory_ = value;
}
}
// Token: 0x170000F4 RID: 244
// (get) Token: 0x060003FB RID: 1019 RVA: 0x0001404B File Offset: 0x0001304B
// (set) Token: 0x060003FC RID: 1020 RVA: 0x00014053 File Offset: 0x00013053
public int BufferSize
{
get
{
return this.bufferSize_;
}
set
{
if (value < 1024)
{
throw new ArgumentOutOfRangeException("value", "cannot be below 1024");
}
if (this.bufferSize_ != value)
{
this.bufferSize_ = value;
this.copyBuffer_ = null;
}
}
}
// Token: 0x170000F5 RID: 245
// (get) Token: 0x060003FD RID: 1021 RVA: 0x00014084 File Offset: 0x00013084
public bool IsUpdating
{
get
{
return this.updates_ != null;
}
}
// Token: 0x170000F6 RID: 246
// (get) Token: 0x060003FE RID: 1022 RVA: 0x00014092 File Offset: 0x00013092
// (set) Token: 0x060003FF RID: 1023 RVA: 0x0001409A File Offset: 0x0001309A
public UseZip64 UseZip64
{
get
{
return this.useZip64_;
}
set
{
this.useZip64_ = value;
}
}
// Token: 0x06000400 RID: 1024 RVA: 0x000140A4 File Offset: 0x000130A4
public void BeginUpdate(IArchiveStorage archiveStorage, IDynamicDataSource dataSource)
{
if (archiveStorage == null)
{
throw new ArgumentNullException("archiveStorage");
}
if (dataSource == null)
{
throw new ArgumentNullException("dataSource");
}
if (this.isDisposed_)
{
throw new ObjectDisposedException("ZipFile");
}
if (this.IsEmbeddedArchive)
{
throw new ZipException("Cannot update embedded/SFX archives");
}
this.archiveStorage_ = archiveStorage;
this.updateDataSource_ = dataSource;
this.updateIndex_ = new Hashtable();
this.updates_ = new ArrayList(this.entries_.Length);
foreach (ZipEntry zipEntry in this.entries_)
{
int num = this.updates_.Add(new ZipFile.ZipUpdate(zipEntry));
this.updateIndex_.Add(zipEntry.Name, num);
}
this.updates_.Sort(new ZipFile.UpdateComparer());
int num2 = 0;
foreach (object obj in this.updates_)
{
ZipFile.ZipUpdate zipUpdate = (ZipFile.ZipUpdate)obj;
if (num2 == this.updates_.Count - 1)
{
break;
}
zipUpdate.OffsetBasedSize = ((ZipFile.ZipUpdate)this.updates_[num2 + 1]).Entry.Offset - zipUpdate.Entry.Offset;
num2++;
}
this.updateCount_ = (long)this.updates_.Count;
this.contentsEdited_ = false;
this.commentEdited_ = false;
this.newComment_ = null;
}
// Token: 0x06000401 RID: 1025 RVA: 0x00014234 File Offset: 0x00013234
public void BeginUpdate(IArchiveStorage archiveStorage)
{
this.BeginUpdate(archiveStorage, new DynamicDiskDataSource());
}
// Token: 0x06000402 RID: 1026 RVA: 0x00014242 File Offset: 0x00013242
public void BeginUpdate()
{
if (this.Name == null)
{
this.BeginUpdate(new MemoryArchiveStorage(), new DynamicDiskDataSource());
return;
}
this.BeginUpdate(new DiskArchiveStorage(this), new DynamicDiskDataSource());
}
// Token: 0x06000403 RID: 1027 RVA: 0x00014270 File Offset: 0x00013270
public void CommitUpdate()
{
if (this.isDisposed_)
{
throw new ObjectDisposedException("ZipFile");
}
this.CheckUpdating();
try
{
this.updateIndex_.Clear();
this.updateIndex_ = null;
if (this.contentsEdited_)
{
this.RunUpdates();
}
else if (this.commentEdited_)
{
this.UpdateCommentOnly();
}
else if (this.entries_.Length == 0)
{
byte[] array = ((this.newComment_ != null) ? this.newComment_.RawComment : ZipConstants.ConvertToArray(this.comment_));
using (ZipHelperStream zipHelperStream = new ZipHelperStream(this.baseStream_))
{
zipHelperStream.WriteEndOfCentralDirectory(0L, 0L, 0L, array);
}
}
}
finally
{
this.PostUpdateCleanup();
}
}
// Token: 0x06000404 RID: 1028 RVA: 0x00014340 File Offset: 0x00013340
public void AbortUpdate()
{
this.PostUpdateCleanup();
}
// Token: 0x06000405 RID: 1029 RVA: 0x00014348 File Offset: 0x00013348
public void SetComment(string comment)
{
if (this.isDisposed_)
{
throw new ObjectDisposedException("ZipFile");
}
this.CheckUpdating();
this.newComment_ = new ZipFile.ZipString(comment);
if (this.newComment_.RawLength > 65535)
{
this.newComment_ = null;
throw new ZipException("Comment length exceeds maximum - 65535");
}
this.commentEdited_ = true;
}
// Token: 0x06000406 RID: 1030 RVA: 0x000143A8 File Offset: 0x000133A8
private void AddUpdate(ZipFile.ZipUpdate update)
{
this.contentsEdited_ = true;
int num = this.FindExistingUpdate(update.Entry.Name);
if (num >= 0)
{
if (this.updates_[num] == null)
{
this.updateCount_ += 1L;
}
this.updates_[num] = update;
return;
}
num = this.updates_.Add(update);
this.updateCount_ += 1L;
this.updateIndex_.Add(update.Entry.Name, num);
}
// Token: 0x06000407 RID: 1031 RVA: 0x00014438 File Offset: 0x00013438
public void Add(string fileName, CompressionMethod compressionMethod, bool useUnicodeText)
{
if (fileName == null)
{
throw new ArgumentNullException("fileName");
}
if (this.isDisposed_)
{
throw new ObjectDisposedException("ZipFile");
}
if (!ZipEntry.IsCompressionMethodSupported(compressionMethod))
{
throw new ArgumentOutOfRangeException("compressionMethod");
}
this.CheckUpdating();
this.contentsEdited_ = true;
ZipEntry zipEntry = this.EntryFactory.MakeFileEntry(fileName);
zipEntry.IsUnicodeText = useUnicodeText;
zipEntry.CompressionMethod = compressionMethod;
this.AddUpdate(new ZipFile.ZipUpdate(fileName, zipEntry));
}
// Token: 0x06000408 RID: 1032 RVA: 0x000144B0 File Offset: 0x000134B0
public void Add(string fileName, CompressionMethod compressionMethod)
{
if (fileName == null)
{
throw new ArgumentNullException("fileName");
}
if (!ZipEntry.IsCompressionMethodSupported(compressionMethod))
{
throw new ArgumentOutOfRangeException("compressionMethod");
}
this.CheckUpdating();
this.contentsEdited_ = true;
ZipEntry zipEntry = this.EntryFactory.MakeFileEntry(fileName);
zipEntry.CompressionMethod = compressionMethod;
this.AddUpdate(new ZipFile.ZipUpdate(fileName, zipEntry));
}
// Token: 0x06000409 RID: 1033 RVA: 0x0001450C File Offset: 0x0001350C
public void Add(string fileName)
{
if (fileName == null)
{
throw new ArgumentNullException("fileName");
}
this.CheckUpdating();
this.AddUpdate(new ZipFile.ZipUpdate(fileName, this.EntryFactory.MakeFileEntry(fileName)));
}
// Token: 0x0600040A RID: 1034 RVA: 0x0001453A File Offset: 0x0001353A
public void Add(string fileName, string entryName)
{
if (fileName == null)
{
throw new ArgumentNullException("fileName");
}
if (entryName == null)
{
throw new ArgumentNullException("entryName");
}
this.CheckUpdating();
this.AddUpdate(new ZipFile.ZipUpdate(fileName, this.EntryFactory.MakeFileEntry(entryName)));
}
// Token: 0x0600040B RID: 1035 RVA: 0x00014576 File Offset: 0x00013576
public void Add(IStaticDataSource dataSource, string entryName)
{
if (dataSource == null)
{
throw new ArgumentNullException("dataSource");
}
if (entryName == null)
{
throw new ArgumentNullException("entryName");
}
this.CheckUpdating();
this.AddUpdate(new ZipFile.ZipUpdate(dataSource, this.EntryFactory.MakeFileEntry(entryName, false)));
}
// Token: 0x0600040C RID: 1036 RVA: 0x000145B4 File Offset: 0x000135B4
public void Add(IStaticDataSource dataSource, string entryName, CompressionMethod compressionMethod)
{
if (dataSource == null)
{
throw new ArgumentNullException("dataSource");
}
if (entryName == null)
{
throw new ArgumentNullException("entryName");
}
this.CheckUpdating();
ZipEntry zipEntry = this.EntryFactory.MakeFileEntry(entryName, false);
zipEntry.CompressionMethod = compressionMethod;
this.AddUpdate(new ZipFile.ZipUpdate(dataSource, zipEntry));
}
// Token: 0x0600040D RID: 1037 RVA: 0x00014608 File Offset: 0x00013608
public void Add(IStaticDataSource dataSource, string entryName, CompressionMethod compressionMethod, bool useUnicodeText)
{
if (dataSource == null)
{
throw new ArgumentNullException("dataSource");
}
if (entryName == null)
{
throw new ArgumentNullException("entryName");
}
this.CheckUpdating();
ZipEntry zipEntry = this.EntryFactory.MakeFileEntry(entryName, false);
zipEntry.IsUnicodeText = useUnicodeText;
zipEntry.CompressionMethod = compressionMethod;
this.AddUpdate(new ZipFile.ZipUpdate(dataSource, zipEntry));
}
// Token: 0x0600040E RID: 1038 RVA: 0x00014664 File Offset: 0x00013664
public void Add(ZipEntry entry)
{
if (entry == null)
{
throw new ArgumentNullException("entry");
}
this.CheckUpdating();
if (entry.Size != 0L || entry.CompressedSize != 0L)
{
throw new ZipException("Entry cannot have any data");
}
this.AddUpdate(new ZipFile.ZipUpdate(ZipFile.UpdateCommand.Add, entry));
}
// Token: 0x0600040F RID: 1039 RVA: 0x000146B4 File Offset: 0x000136B4
public void AddDirectory(string directoryName)
{
if (directoryName == null)
{
throw new ArgumentNullException("directoryName");
}
this.CheckUpdating();
ZipEntry zipEntry = this.EntryFactory.MakeDirectoryEntry(directoryName);
this.AddUpdate(new ZipFile.ZipUpdate(ZipFile.UpdateCommand.Add, zipEntry));
}
// Token: 0x06000410 RID: 1040 RVA: 0x000146F0 File Offset: 0x000136F0
public bool Delete(string fileName)
{
if (fileName == null)
{
throw new ArgumentNullException("fileName");
}
this.CheckUpdating();
int num = this.FindExistingUpdate(fileName);
if (num >= 0 && this.updates_[num] != null)
{
bool flag = true;
this.contentsEdited_ = true;
this.updates_[num] = null;
this.updateCount_ -= 1L;
return flag;
}
throw new ZipException("Cannot find entry to delete");
}
// Token: 0x06000411 RID: 1041 RVA: 0x00014760 File Offset: 0x00013760
public void Delete(ZipEntry entry)
{
if (entry == null)
{
throw new ArgumentNullException("entry");
}
this.CheckUpdating();
int num = this.FindExistingUpdate(entry);
if (num >= 0)
{
this.contentsEdited_ = true;
this.updates_[num] = null;
this.updateCount_ -= 1L;
return;
}
throw new ZipException("Cannot find entry to delete");
}
// Token: 0x06000412 RID: 1042 RVA: 0x000147BB File Offset: 0x000137BB
private void WriteLEShort(int value)
{
this.baseStream_.WriteByte((byte)(value & 255));
this.baseStream_.WriteByte((byte)((value >> 8) & 255));
}
// Token: 0x06000413 RID: 1043 RVA: 0x000147E5 File Offset: 0x000137E5
private void WriteLEUshort(ushort value)
{
this.baseStream_.WriteByte((byte)(value & 255));
this.baseStream_.WriteByte((byte)(value >> 8));
}
// Token: 0x06000414 RID: 1044 RVA: 0x00014809 File Offset: 0x00013809
private void WriteLEInt(int value)
{
this.WriteLEShort(value & 65535);
this.WriteLEShort(value >> 16);
}
// Token: 0x06000415 RID: 1045 RVA: 0x00014822 File Offset: 0x00013822
private void WriteLEUint(uint value)
{
this.WriteLEUshort((ushort)(value & 65535U));
this.WriteLEUshort((ushort)(value >> 16));
}
// Token: 0x06000416 RID: 1046 RVA: 0x0001483D File Offset: 0x0001383D
private void WriteLeLong(long value)
{
this.WriteLEInt((int)(value & (long)((ulong)(-1))));
this.WriteLEInt((int)(value >> 32));
}
// Token: 0x06000417 RID: 1047 RVA: 0x00014855 File Offset: 0x00013855
private void WriteLEUlong(ulong value)
{
this.WriteLEUint((uint)(value & (ulong)(-1)));
this.WriteLEUint((uint)(value >> 32));
}
// Token: 0x06000418 RID: 1048 RVA: 0x00014870 File Offset: 0x00013870
private void WriteLocalEntryHeader(ZipFile.ZipUpdate update)
{
ZipEntry outEntry = update.OutEntry;
outEntry.Offset = this.baseStream_.Position;
if (update.Command != ZipFile.UpdateCommand.Copy)
{
if (outEntry.CompressionMethod == CompressionMethod.Deflated)
{
if (outEntry.Size == 0L)
{
outEntry.CompressedSize = outEntry.Size;
outEntry.Crc = 0L;
outEntry.CompressionMethod = CompressionMethod.Stored;
}
}
else if (outEntry.CompressionMethod == CompressionMethod.Stored)
{
outEntry.Flags &= -9;
}
if (this.HaveKeys)
{
outEntry.IsCrypted = true;
if (outEntry.Crc < 0L)
{
outEntry.Flags |= 8;
}
}
else
{
outEntry.IsCrypted = false;
}
switch (this.useZip64_)
{
case UseZip64.On:
outEntry.ForceZip64();
break;
case UseZip64.Dynamic:
if (outEntry.Size < 0L)
{
outEntry.ForceZip64();
}
break;
}
}
this.WriteLEInt(67324752);
this.WriteLEShort(outEntry.Version);
this.WriteLEShort(outEntry.Flags);
this.WriteLEShort((int)((byte)outEntry.CompressionMethod));
this.WriteLEInt((int)outEntry.DosTime);
if (!outEntry.HasCrc)
{
update.CrcPatchOffset = this.baseStream_.Position;
this.WriteLEInt(0);
}
else
{
this.WriteLEInt((int)outEntry.Crc);
}
if (outEntry.LocalHeaderRequiresZip64)
{
this.WriteLEInt(-1);
this.WriteLEInt(-1);
}
else
{
if (outEntry.CompressedSize < 0L || outEntry.Size < 0L)
{
update.SizePatchOffset = this.baseStream_.Position;
}
this.WriteLEInt((int)outEntry.CompressedSize);
this.WriteLEInt((int)outEntry.Size);
}
byte[] array = ZipConstants.ConvertToArray(outEntry.Flags, outEntry.Name);
if (array.Length > 65535)
{
throw new ZipException("Entry name too long.");
}
ZipExtraData zipExtraData = new ZipExtraData(outEntry.ExtraData);
if (outEntry.LocalHeaderRequiresZip64)
{
zipExtraData.StartNewEntry();
zipExtraData.AddLeLong(outEntry.Size);
zipExtraData.AddLeLong(outEntry.CompressedSize);
zipExtraData.AddNewEntry(1);
}
else
{
zipExtraData.Delete(1);
}
outEntry.ExtraData = zipExtraData.GetEntryData();
this.WriteLEShort(array.Length);
this.WriteLEShort(outEntry.ExtraData.Length);
if (array.Length > 0)
{
this.baseStream_.Write(array, 0, array.Length);
}
if (outEntry.LocalHeaderRequiresZip64)
{
if (!zipExtraData.Find(1))
{
throw new ZipException("Internal error cannot find extra data");
}
update.SizePatchOffset = this.baseStream_.Position + (long)zipExtraData.CurrentReadIndex;
}
if (outEntry.ExtraData.Length > 0)
{
this.baseStream_.Write(outEntry.ExtraData, 0, outEntry.ExtraData.Length);
}
}
// Token: 0x06000419 RID: 1049 RVA: 0x00014B0C File Offset: 0x00013B0C
private int WriteCentralDirectoryHeader(ZipEntry entry)
{
if (entry.CompressedSize < 0L)
{
throw new ZipException("Attempt to write central directory entry with unknown csize");
}
if (entry.Size < 0L)
{
throw new ZipException("Attempt to write central directory entry with unknown size");
}
if (entry.Crc < 0L)
{
throw new ZipException("Attempt to write central directory entry with unknown crc");
}
this.WriteLEInt(33639248);
this.WriteLEShort(51);
this.WriteLEShort(entry.Version);
this.WriteLEShort(entry.Flags);
this.WriteLEShort((int)((byte)entry.CompressionMethod));
this.WriteLEInt((int)entry.DosTime);
this.WriteLEInt((int)entry.Crc);
if (entry.IsZip64Forced() || entry.CompressedSize >= (long)((ulong)(-1)))
{
this.WriteLEInt(-1);
}
else
{
this.WriteLEInt((int)(entry.CompressedSize & (long)((ulong)(-1))));
}
if (entry.IsZip64Forced() || entry.Size >= (long)((ulong)(-1)))
{
this.WriteLEInt(-1);
}
else
{
this.WriteLEInt((int)entry.Size);
}
byte[] array = ZipConstants.ConvertToArray(entry.Flags, entry.Name);
if (array.Length > 65535)
{
throw new ZipException("Entry name is too long.");
}
this.WriteLEShort(array.Length);
ZipExtraData zipExtraData = new ZipExtraData(entry.ExtraData);
if (entry.CentralHeaderRequiresZip64)
{
zipExtraData.StartNewEntry();
if (entry.Size >= (long)((ulong)(-1)) || this.useZip64_ == UseZip64.On)
{
zipExtraData.AddLeLong(entry.Size);
}
if (entry.CompressedSize >= (long)((ulong)(-1)) || this.useZip64_ == UseZip64.On)
{
zipExtraData.AddLeLong(entry.CompressedSize);
}
if (entry.Offset >= (long)((ulong)(-1)))
{
zipExtraData.AddLeLong(entry.Offset);
}
zipExtraData.AddNewEntry(1);
}
else
{
zipExtraData.Delete(1);
}
byte[] entryData = zipExtraData.GetEntryData();
this.WriteLEShort(entryData.Length);
this.WriteLEShort((entry.Comment != null) ? entry.Comment.Length : 0);
this.WriteLEShort(0);
this.WriteLEShort(0);
if (entry.ExternalFileAttributes != -1)
{
this.WriteLEInt(entry.ExternalFileAttributes);
}
else if (entry.IsDirectory)
{
this.WriteLEUint(16U);
}
else
{
this.WriteLEUint(0U);
}
if (entry.Offset >= (long)((ulong)(-1)))
{
this.WriteLEUint(uint.MaxValue);
}
else
{
this.WriteLEUint((uint)((int)entry.Offset));
}
if (array.Length > 0)
{
this.baseStream_.Write(array, 0, array.Length);
}
if (entryData.Length > 0)
{
this.baseStream_.Write(entryData, 0, entryData.Length);
}
byte[] array2 = ((entry.Comment != null) ? Encoding.ASCII.GetBytes(entry.Comment) : new byte[0]);
if (array2.Length > 0)
{
this.baseStream_.Write(array2, 0, array2.Length);
}
return 46 + array.Length + entryData.Length + array2.Length;
}
// Token: 0x0600041A RID: 1050 RVA: 0x00014DA7 File Offset: 0x00013DA7
private void PostUpdateCleanup()
{
this.updateDataSource_ = null;
this.updates_ = null;
this.updateIndex_ = null;
if (this.archiveStorage_ != null)
{
this.archiveStorage_.Dispose();
this.archiveStorage_ = null;
}
}
// Token: 0x0600041B RID: 1051 RVA: 0x00014DD8 File Offset: 0x00013DD8
private string GetTransformedFileName(string name)
{
INameTransform nameTransform = this.NameTransform;
if (nameTransform == null)
{
return name;
}
return nameTransform.TransformFile(name);
}
// Token: 0x0600041C RID: 1052 RVA: 0x00014DF8 File Offset: 0x00013DF8
private string GetTransformedDirectoryName(string name)
{
INameTransform nameTransform = this.NameTransform;
if (nameTransform == null)
{
return name;
}
return nameTransform.TransformDirectory(name);
}
// Token: 0x0600041D RID: 1053 RVA: 0x00014E18 File Offset: 0x00013E18
private byte[] GetBuffer()
{
if (this.copyBuffer_ == null)
{
this.copyBuffer_ = new byte[this.bufferSize_];
}
return this.copyBuffer_;
}
// Token: 0x0600041E RID: 1054 RVA: 0x00014E3C File Offset: 0x00013E3C
private void CopyDescriptorBytes(ZipFile.ZipUpdate update, Stream dest, Stream source)
{
int i = this.GetDescriptorSize(update);
if (i > 0)
{
byte[] buffer = this.GetBuffer();
while (i > 0)
{
int num = Math.Min(buffer.Length, i);
int num2 = source.Read(buffer, 0, num);
if (num2 <= 0)
{
throw new ZipException("Unxpected end of stream");
}
dest.Write(buffer, 0, num2);
i -= num2;
}
}
}
// Token: 0x0600041F RID: 1055 RVA: 0x00014E94 File Offset: 0x00013E94
private void CopyBytes(ZipFile.ZipUpdate update, Stream destination, Stream source, long bytesToCopy, bool updateCrc)
{
if (destination == source)
{
throw new InvalidOperationException("Destination and source are the same");
}
Crc32 crc = new Crc32();
byte[] buffer = this.GetBuffer();
long num = bytesToCopy;
long num2 = 0L;
int num4;
do
{
int num3 = buffer.Length;
if (bytesToCopy < (long)num3)
{
num3 = (int)bytesToCopy;
}
num4 = source.Read(buffer, 0, num3);
if (num4 > 0)
{
if (updateCrc)
{
crc.Update(buffer, 0, num4);
}
destination.Write(buffer, 0, num4);
bytesToCopy -= (long)num4;
num2 += (long)num4;
}
}
while (num4 > 0 && bytesToCopy > 0L);
if (num2 != num)
{
throw new ZipException(string.Format("Failed to copy bytes expected {0} read {1}", num, num2));
}
if (updateCrc)
{
update.OutEntry.Crc = crc.Value;
}
}
// Token: 0x06000420 RID: 1056 RVA: 0x00014F4C File Offset: 0x00013F4C
private int GetDescriptorSize(ZipFile.ZipUpdate update)
{
int num = 0;
if ((update.Entry.Flags & 8) != 0)
{
num = 12;
if (update.Entry.LocalHeaderRequiresZip64)
{
num = 20;
}
}
return num;
}
// Token: 0x06000421 RID: 1057 RVA: 0x00014F80 File Offset: 0x00013F80
private void CopyDescriptorBytesDirect(ZipFile.ZipUpdate update, Stream stream, ref long destinationPosition, long sourcePosition)
{
int i = this.GetDescriptorSize(update);
while (i > 0)
{
int num = i;
byte[] buffer = this.GetBuffer();
stream.Position = sourcePosition;
int num2 = stream.Read(buffer, 0, num);
if (num2 <= 0)
{
throw new ZipException("Unxpected end of stream");
}
stream.Position = destinationPosition;
stream.Write(buffer, 0, num2);
i -= num2;
destinationPosition += (long)num2;
sourcePosition += (long)num2;
}
}
// Token: 0x06000422 RID: 1058 RVA: 0x00014FEC File Offset: 0x00013FEC
private void CopyEntryDataDirect(ZipFile.ZipUpdate update, Stream stream, bool updateCrc, ref long destinationPosition, ref long sourcePosition)
{
long num = update.Entry.CompressedSize;
Crc32 crc = new Crc32();
byte[] buffer = this.GetBuffer();
long num2 = num;
long num3 = 0L;
int num5;
do
{
int num4 = buffer.Length;
if (num < (long)num4)
{
num4 = (int)num;
}
stream.Position = sourcePosition;
num5 = stream.Read(buffer, 0, num4);
if (num5 > 0)
{
if (updateCrc)
{
crc.Update(buffer, 0, num5);
}
stream.Position = destinationPosition;
stream.Write(buffer, 0, num5);
destinationPosition += (long)num5;
sourcePosition += (long)num5;
num -= (long)num5;
num3 += (long)num5;
}
}
while (num5 > 0 && num > 0L);
if (num3 != num2)
{
throw new ZipException(string.Format("Failed to copy bytes expected {0} read {1}", num2, num3));
}
if (updateCrc)
{
update.OutEntry.Crc = crc.Value;
}
}
// Token: 0x06000423 RID: 1059 RVA: 0x000150C4 File Offset: 0x000140C4
private int FindExistingUpdate(ZipEntry entry)
{
int num = -1;
string transformedFileName = this.GetTransformedFileName(entry.Name);
if (this.updateIndex_.ContainsKey(transformedFileName))
{
num = (int)this.updateIndex_[transformedFileName];
}
return num;
}
// Token: 0x06000424 RID: 1060 RVA: 0x00015104 File Offset: 0x00014104
private int FindExistingUpdate(string fileName)
{
int num = -1;
string transformedFileName = this.GetTransformedFileName(fileName);
if (this.updateIndex_.ContainsKey(transformedFileName))
{
num = (int)this.updateIndex_[transformedFileName];
}
return num;
}
// Token: 0x06000425 RID: 1061 RVA: 0x0001513C File Offset: 0x0001413C
private Stream GetOutputStream(ZipEntry entry)
{
Stream stream = this.baseStream_;
if (entry.IsCrypted)
{
stream = this.CreateAndInitEncryptionStream(stream, entry);
}
CompressionMethod compressionMethod = entry.CompressionMethod;
if (compressionMethod != CompressionMethod.Stored)
{
if (compressionMethod != CompressionMethod.Deflated)
{
throw new ZipException("Unknown compression method " + entry.CompressionMethod);
}
stream = new DeflaterOutputStream(stream, new Deflater(9, true))
{
IsStreamOwner = false
};
}
else
{
stream = new ZipFile.UncompressedStream(stream);
}
return stream;
}
// Token: 0x06000426 RID: 1062 RVA: 0x000151B4 File Offset: 0x000141B4
private void AddEntry(ZipFile workFile, ZipFile.ZipUpdate update)
{
Stream stream = null;
if (update.Entry.IsFile)
{
stream = update.GetSource();
if (stream == null)
{
stream = this.updateDataSource_.GetSource(update.Entry, update.Filename);
}
}
if (stream != null)
{
using (stream)
{
long length = stream.Length;
if (update.OutEntry.Size < 0L)
{
update.OutEntry.Size = length;
}
else if (update.OutEntry.Size != length)
{
throw new ZipException("Entry size/stream size mismatch");
}
workFile.WriteLocalEntryHeader(update);
long position = workFile.baseStream_.Position;
using (Stream outputStream = workFile.GetOutputStream(update.OutEntry))
{
this.CopyBytes(update, outputStream, stream, length, true);
}
long position2 = workFile.baseStream_.Position;
update.OutEntry.CompressedSize = position2 - position;
if ((update.OutEntry.Flags & 8) == 8)
{
ZipHelperStream zipHelperStream = new ZipHelperStream(workFile.baseStream_);
zipHelperStream.WriteDataDescriptor(update.OutEntry);
}
return;
}
}
workFile.WriteLocalEntryHeader(update);
update.OutEntry.CompressedSize = 0L;
}
// Token: 0x06000427 RID: 1063 RVA: 0x000152F4 File Offset: 0x000142F4
private void ModifyEntry(ZipFile workFile, ZipFile.ZipUpdate update)
{
workFile.WriteLocalEntryHeader(update);
long position = workFile.baseStream_.Position;
if (update.Entry.IsFile && update.Filename != null)
{
using (Stream outputStream = workFile.GetOutputStream(update.OutEntry))
{
using (Stream inputStream = this.GetInputStream(update.Entry))
{
this.CopyBytes(update, outputStream, inputStream, inputStream.Length, true);
}
}
}
long position2 = workFile.baseStream_.Position;
update.Entry.CompressedSize = position2 - position;
}
// Token: 0x06000428 RID: 1064 RVA: 0x000153A4 File Offset: 0x000143A4
private void CopyEntryDirect(ZipFile workFile, ZipFile.ZipUpdate update, ref long destinationPosition)
{
bool flag = false;
if (update.Entry.Offset == destinationPosition)
{
flag = true;
}
if (!flag)
{
this.baseStream_.Position = destinationPosition;
workFile.WriteLocalEntryHeader(update);
destinationPosition = this.baseStream_.Position;
}
long num = 0L;
long num2 = update.Entry.Offset + 26L;
this.baseStream_.Seek(num2, SeekOrigin.Begin);
uint num3 = (uint)this.ReadLEUshort();
uint num4 = (uint)this.ReadLEUshort();
num = this.baseStream_.Position + (long)((ulong)num3) + (long)((ulong)num4);
if (!flag)
{
if (update.Entry.CompressedSize > 0L)
{
this.CopyEntryDataDirect(update, this.baseStream_, false, ref destinationPosition, ref num);
}
this.CopyDescriptorBytesDirect(update, this.baseStream_, ref destinationPosition, num);
return;
}
if (update.OffsetBasedSize != -1L)
{
destinationPosition += update.OffsetBasedSize;
return;
}
destinationPosition += num - num2 + 26L + update.Entry.CompressedSize + (long)this.GetDescriptorSize(update);
}
// Token: 0x06000429 RID: 1065 RVA: 0x00015498 File Offset: 0x00014498
private void CopyEntry(ZipFile workFile, ZipFile.ZipUpdate update)
{
workFile.WriteLocalEntryHeader(update);
if (update.Entry.CompressedSize > 0L)
{
long num = update.Entry.Offset + 26L;
this.baseStream_.Seek(num, SeekOrigin.Begin);
uint num2 = (uint)this.ReadLEUshort();
uint num3 = (uint)this.ReadLEUshort();
this.baseStream_.Seek((long)((ulong)(num2 + num3)), SeekOrigin.Current);
this.CopyBytes(update, workFile.baseStream_, this.baseStream_, update.Entry.CompressedSize, false);
}
this.CopyDescriptorBytes(update, workFile.baseStream_, this.baseStream_);
}
// Token: 0x0600042A RID: 1066 RVA: 0x0001552A File Offset: 0x0001452A
private void Reopen(Stream source)
{
if (source == null)
{
throw new ZipException("Failed to reopen archive - no source");
}
this.isNewArchive_ = false;
this.baseStream_ = source;
this.ReadEntries();
}
// Token: 0x0600042B RID: 1067 RVA: 0x0001554E File Offset: 0x0001454E
private void Reopen()
{
if (this.Name == null)
{
throw new InvalidOperationException("Name is not known cannot Reopen");
}
this.Reopen(File.Open(this.Name, FileMode.Open, FileAccess.Read, FileShare.Read));
}
// Token: 0x0600042C RID: 1068 RVA: 0x00015578 File Offset: 0x00014578
private void UpdateCommentOnly()
{
long length = this.baseStream_.Length;
ZipHelperStream zipHelperStream;
if (this.archiveStorage_.UpdateMode == FileUpdateMode.Safe)
{
Stream stream = this.archiveStorage_.MakeTemporaryCopy(this.baseStream_);
zipHelperStream = new ZipHelperStream(stream);
zipHelperStream.IsStreamOwner = true;
this.baseStream_.Close();
this.baseStream_ = null;
}
else if (this.archiveStorage_.UpdateMode == FileUpdateMode.Direct)
{
this.baseStream_ = this.archiveStorage_.OpenForDirectUpdate(this.baseStream_);
zipHelperStream = new ZipHelperStream(this.baseStream_);
}
else
{
this.baseStream_.Close();
this.baseStream_ = null;
zipHelperStream = new ZipHelperStream(this.Name);
}
using (zipHelperStream)
{
long num = zipHelperStream.LocateBlockWithSignature(101010256, length, 22, 65535);
if (num < 0L)
{
throw new ZipException("Cannot find central directory");
}
zipHelperStream.Position += 16L;
byte[] rawComment = this.newComment_.RawComment;
zipHelperStream.WriteLEShort(rawComment.Length);
zipHelperStream.Write(rawComment, 0, rawComment.Length);
zipHelperStream.SetLength(zipHelperStream.Position);
}
if (this.archiveStorage_.UpdateMode == FileUpdateMode.Safe)
{
this.Reopen(this.archiveStorage_.ConvertTemporaryToFinal());
return;
}
this.ReadEntries();
}
// Token: 0x0600042D RID: 1069 RVA: 0x000156D0 File Offset: 0x000146D0
private void RunUpdates()
{
long num = 0L;
long num2 = 0L;
bool flag = false;
long num3 = 0L;
ZipFile zipFile;
if (this.IsNewArchive)
{
zipFile = this;
zipFile.baseStream_.Position = 0L;
flag = true;
}
else if (this.archiveStorage_.UpdateMode == FileUpdateMode.Direct)
{
zipFile = this;
zipFile.baseStream_.Position = 0L;
flag = true;
this.updates_.Sort(new ZipFile.UpdateComparer());
}
else
{
zipFile = ZipFile.Create(this.archiveStorage_.GetTemporaryOutput());
zipFile.UseZip64 = this.UseZip64;
if (this.key != null)
{
zipFile.key = (byte[])this.key.Clone();
}
}
try
{
foreach (object obj in this.updates_)
{
ZipFile.ZipUpdate zipUpdate = (ZipFile.ZipUpdate)obj;
if (zipUpdate != null)
{
switch (zipUpdate.Command)
{
case ZipFile.UpdateCommand.Copy:
if (flag)
{
this.CopyEntryDirect(zipFile, zipUpdate, ref num3);
}
else
{
this.CopyEntry(zipFile, zipUpdate);
}
break;
case ZipFile.UpdateCommand.Modify:
this.ModifyEntry(zipFile, zipUpdate);
break;
case ZipFile.UpdateCommand.Add:
if (!this.IsNewArchive && flag)
{
zipFile.baseStream_.Position = num3;
}
this.AddEntry(zipFile, zipUpdate);
if (flag)
{
num3 = zipFile.baseStream_.Position;
}
break;
}
}
}
if (!this.IsNewArchive && flag)
{
zipFile.baseStream_.Position = num3;
}
long position = zipFile.baseStream_.Position;
foreach (object obj2 in this.updates_)
{
ZipFile.ZipUpdate zipUpdate2 = (ZipFile.ZipUpdate)obj2;
if (zipUpdate2 != null)
{
num += (long)zipFile.WriteCentralDirectoryHeader(zipUpdate2.OutEntry);
}
}
byte[] array = ((this.newComment_ != null) ? this.newComment_.RawComment : ZipConstants.ConvertToArray(this.comment_));
using (ZipHelperStream zipHelperStream = new ZipHelperStream(zipFile.baseStream_))
{
zipHelperStream.WriteEndOfCentralDirectory(this.updateCount_, num, position, array);
}
num2 = zipFile.baseStream_.Position;
foreach (object obj3 in this.updates_)
{
ZipFile.ZipUpdate zipUpdate3 = (ZipFile.ZipUpdate)obj3;
if (zipUpdate3 != null)
{
if (zipUpdate3.CrcPatchOffset > 0L && zipUpdate3.OutEntry.CompressedSize > 0L)
{
zipFile.baseStream_.Position = zipUpdate3.CrcPatchOffset;
zipFile.WriteLEInt((int)zipUpdate3.OutEntry.Crc);
}
if (zipUpdate3.SizePatchOffset > 0L)
{
zipFile.baseStream_.Position = zipUpdate3.SizePatchOffset;
if (zipUpdate3.OutEntry.LocalHeaderRequiresZip64)
{
zipFile.WriteLeLong(zipUpdate3.OutEntry.Size);
zipFile.WriteLeLong(zipUpdate3.OutEntry.CompressedSize);
}
else
{
zipFile.WriteLEInt((int)zipUpdate3.OutEntry.CompressedSize);
zipFile.WriteLEInt((int)zipUpdate3.OutEntry.Size);
}
}
}
}
}
catch
{
zipFile.Close();
if (!flag && zipFile.Name != null)
{
File.Delete(zipFile.Name);
}
throw;
}
if (flag)
{
zipFile.baseStream_.SetLength(num2);
zipFile.baseStream_.Flush();
this.isNewArchive_ = false;
this.ReadEntries();
return;
}
this.baseStream_.Close();
this.Reopen(this.archiveStorage_.ConvertTemporaryToFinal());
}
// Token: 0x0600042E RID: 1070 RVA: 0x00015AFC File Offset: 0x00014AFC
private void CheckUpdating()
{
if (this.updates_ == null)
{
throw new InvalidOperationException("BeginUpdate has not been called");
}
}
// Token: 0x0600042F RID: 1071 RVA: 0x00015B11 File Offset: 0x00014B11
void IDisposable.Dispose()
{
this.Close();
}
// Token: 0x06000430 RID: 1072 RVA: 0x00015B1C File Offset: 0x00014B1C
private void DisposeInternal(bool disposing)
{
if (!this.isDisposed_)
{
this.isDisposed_ = true;
this.entries_ = new ZipEntry[0];
if (this.IsStreamOwner && this.baseStream_ != null)
{
lock (this.baseStream_)
{
this.baseStream_.Close();
}
}
this.PostUpdateCleanup();
}
}
// Token: 0x06000431 RID: 1073 RVA: 0x00015B8C File Offset: 0x00014B8C
protected virtual void Dispose(bool disposing)
{
this.DisposeInternal(disposing);
}
// Token: 0x06000432 RID: 1074 RVA: 0x00015B98 File Offset: 0x00014B98
private ushort ReadLEUshort()
{
int num = this.baseStream_.ReadByte();
if (num < 0)
{
throw new EndOfStreamException("End of stream");
}
int num2 = this.baseStream_.ReadByte();
if (num2 < 0)
{
throw new EndOfStreamException("End of stream");
}
return (ushort)num | (ushort)(num2 << 8);
}
// Token: 0x06000433 RID: 1075 RVA: 0x00015BE3 File Offset: 0x00014BE3
private uint ReadLEUint()
{
return (uint)((int)this.ReadLEUshort() | ((int)this.ReadLEUshort() << 16));
}
// Token: 0x06000434 RID: 1076 RVA: 0x00015BF5 File Offset: 0x00014BF5
private ulong ReadLEUlong()
{
return (ulong)this.ReadLEUint() | ((ulong)this.ReadLEUint() << 32);
}
// Token: 0x06000435 RID: 1077 RVA: 0x00015C0C File Offset: 0x00014C0C
private long LocateBlockWithSignature(int signature, long endLocation, int minimumBlockSize, int maximumVariableData)
{
long num;
using (ZipHelperStream zipHelperStream = new ZipHelperStream(this.baseStream_))
{
num = zipHelperStream.LocateBlockWithSignature(signature, endLocation, minimumBlockSize, maximumVariableData);
}
return num;
}
// Token: 0x06000436 RID: 1078 RVA: 0x00015C50 File Offset: 0x00014C50
private void ReadEntries()
{
if (!this.baseStream_.CanSeek)
{
throw new ZipException("ZipFile stream must be seekable");
}
long num = this.LocateBlockWithSignature(101010256, this.baseStream_.Length, 22, 65535);
if (num < 0L)
{
throw new ZipException("Cannot find central directory");
}
ushort num2 = this.ReadLEUshort();
ushort num3 = this.ReadLEUshort();
ulong num4 = (ulong)this.ReadLEUshort();
ulong num5 = (ulong)this.ReadLEUshort();
ulong num6 = (ulong)this.ReadLEUint();
long num7 = (long)((ulong)this.ReadLEUint());
uint num8 = (uint)this.ReadLEUshort();
if (num8 > 0U)
{
byte[] array = new byte[num8];
StreamUtils.ReadFully(this.baseStream_, array);
this.comment_ = ZipConstants.ConvertToString(array);
}
else
{
this.comment_ = string.Empty;
}
bool flag = false;
if (num2 == 65535 || num3 == 65535 || num4 == 65535UL || num5 == 65535UL || num6 == (ulong)(-1) || num7 == (long)((ulong)(-1)))
{
flag = true;
long num9 = this.LocateBlockWithSignature(117853008, num, 0, 4096);
if (num9 < 0L)
{
throw new ZipException("Cannot find Zip64 locator");
}
this.ReadLEUint();
ulong num10 = this.ReadLEUlong();
this.ReadLEUint();
this.baseStream_.Position = (long)num10;
long num11 = (long)((ulong)this.ReadLEUint());
if (num11 != 101075792L)
{
throw new ZipException(string.Format("Invalid Zip64 Central directory signature at {0:X}", num10));
}
this.ReadLEUlong();
this.ReadLEUshort();
this.ReadLEUshort();
this.ReadLEUint();
this.ReadLEUint();
num4 = this.ReadLEUlong();
num5 = this.ReadLEUlong();
num6 = this.ReadLEUlong();
num7 = (long)this.ReadLEUlong();
}
this.entries_ = new ZipEntry[num4];
if (!flag && num7 < num - (long)(4UL + num6))
{
this.offsetOfFirstEntry = num - (long)(4UL + num6 + (ulong)num7);
if (this.offsetOfFirstEntry <= 0L)
{
throw new ZipException("Invalid embedded zip archive");
}
}
this.baseStream_.Seek(this.offsetOfFirstEntry + num7, SeekOrigin.Begin);
for (ulong num12 = 0UL; num12 < num4; num12 += 1UL)
{
if (this.ReadLEUint() != 33639248U)
{
throw new ZipException("Wrong Central Directory signature");
}
int num13 = (int)this.ReadLEUshort();
int num14 = (int)this.ReadLEUshort();
int num15 = (int)this.ReadLEUshort();
int num16 = (int)this.ReadLEUshort();
uint num17 = this.ReadLEUint();
uint num18 = this.ReadLEUint();
long num19 = (long)((ulong)this.ReadLEUint());
long num20 = (long)((ulong)this.ReadLEUint());
int num21 = (int)this.ReadLEUshort();
int num22 = (int)this.ReadLEUshort();
int num23 = (int)this.ReadLEUshort();
this.ReadLEUshort();
this.ReadLEUshort();
uint num24 = this.ReadLEUint();
long num25 = (long)((ulong)this.ReadLEUint());
byte[] array2 = new byte[Math.Max(num21, num23)];
StreamUtils.ReadFully(this.baseStream_, array2, 0, num21);
string text = ZipConstants.ConvertToStringExt(num15, array2, num21);
ZipEntry zipEntry = new ZipEntry(text, num14, num13, (CompressionMethod)num16);
zipEntry.Crc = (long)((ulong)num18 & (ulong)(-1));
zipEntry.Size = num20 & (long)((ulong)(-1));
zipEntry.CompressedSize = num19 & (long)((ulong)(-1));
zipEntry.Flags = num15;
zipEntry.DosTime = (long)((ulong)num17);
zipEntry.ZipFileIndex = (long)num12;
zipEntry.Offset = num25;
zipEntry.ExternalFileAttributes = (int)num24;
if ((num15 & 8) == 0)
{
zipEntry.CryptoCheckValue = (byte)(num18 >> 24);
}
else
{
zipEntry.CryptoCheckValue = (byte)((num17 >> 8) & 255U);
}
if (num22 > 0)
{
byte[] array3 = new byte[num22];
StreamUtils.ReadFully(this.baseStream_, array3);
zipEntry.ExtraData = array3;
}
zipEntry.ProcessExtraData(false);
if (num23 > 0)
{
StreamUtils.ReadFully(this.baseStream_, array2, 0, num23);
zipEntry.Comment = ZipConstants.ConvertToStringExt(num15, array2, num23);
}
this.entries_[(int)(checked((IntPtr)num12))] = zipEntry;
}
}
// Token: 0x06000437 RID: 1079 RVA: 0x00016013 File Offset: 0x00015013
private long LocateEntry(ZipEntry entry)
{
return this.TestLocalHeader(entry, ZipFile.HeaderTest.Extract);
}
// Token: 0x06000438 RID: 1080 RVA: 0x00016020 File Offset: 0x00015020
private Stream CreateAndInitDecryptionStream(Stream baseStream, ZipEntry entry)
{
CryptoStream cryptoStream;
if (entry.Version < 50 || (entry.Flags & 64) == 0)
{
PkzipClassicManaged pkzipClassicManaged = new PkzipClassicManaged();
this.OnKeysRequired(entry.Name);
if (!this.HaveKeys)
{
throw new ZipException("No password available for encrypted stream");
}
cryptoStream = new CryptoStream(baseStream, pkzipClassicManaged.CreateDecryptor(this.key, null), CryptoStreamMode.Read);
ZipFile.CheckClassicPassword(cryptoStream, entry);
}
else
{
if (entry.Version != 51)
{
throw new ZipException("Decryption method not supported");
}
this.OnKeysRequired(entry.Name);
if (!this.HaveKeys)
{
throw new ZipException("No password available for AES encrypted stream");
}
int aessaltLen = entry.AESSaltLen;
byte[] array = new byte[aessaltLen];
int num = baseStream.Read(array, 0, aessaltLen);
if (num != aessaltLen)
{
throw new ZipException(string.Concat(new object[] { "AES Salt expected ", aessaltLen, " got ", num }));
}
byte[] array2 = new byte[2];
baseStream.Read(array2, 0, 2);
int num2 = entry.AESKeySize / 8;
ZipAESTransform zipAESTransform = new ZipAESTransform(this.rawPassword_, array, num2, false);
byte[] pwdVerifier = zipAESTransform.PwdVerifier;
if (pwdVerifier[0] != array2[0] || pwdVerifier[1] != array2[1])
{
throw new Exception("Invalid password for AES");
}
cryptoStream = new ZipAESStream(baseStream, zipAESTransform, CryptoStreamMode.Read);
}
return cryptoStream;
}
// Token: 0x06000439 RID: 1081 RVA: 0x00016180 File Offset: 0x00015180
private Stream CreateAndInitEncryptionStream(Stream baseStream, ZipEntry entry)
{
CryptoStream cryptoStream = null;
if (entry.Version < 50 || (entry.Flags & 64) == 0)
{
PkzipClassicManaged pkzipClassicManaged = new PkzipClassicManaged();
this.OnKeysRequired(entry.Name);
if (!this.HaveKeys)
{
throw new ZipException("No password available for encrypted stream");
}
cryptoStream = new CryptoStream(new ZipFile.UncompressedStream(baseStream), pkzipClassicManaged.CreateEncryptor(this.key, null), CryptoStreamMode.Write);
if (entry.Crc < 0L || (entry.Flags & 8) != 0)
{
ZipFile.WriteEncryptionHeader(cryptoStream, entry.DosTime << 16);
}
else
{
ZipFile.WriteEncryptionHeader(cryptoStream, entry.Crc);
}
}
return cryptoStream;
}
// Token: 0x0600043A RID: 1082 RVA: 0x00016218 File Offset: 0x00015218
private static void CheckClassicPassword(CryptoStream classicCryptoStream, ZipEntry entry)
{
byte[] array = new byte[12];
StreamUtils.ReadFully(classicCryptoStream, array);
if (array[11] != entry.CryptoCheckValue)
{
throw new ZipException("Invalid password");
}
}
// Token: 0x0600043B RID: 1083 RVA: 0x0001624C File Offset: 0x0001524C
private static void WriteEncryptionHeader(Stream stream, long crcValue)
{
byte[] array = new byte[12];
Random random = new Random();
random.NextBytes(array);
array[11] = (byte)(crcValue >> 24);
stream.Write(array, 0, array.Length);
}
// Token: 0x040002D5 RID: 725
private const int DefaultBufferSize = 4096;
// Token: 0x040002D6 RID: 726
public ZipFile.KeysRequiredEventHandler KeysRequired;
// Token: 0x040002D7 RID: 727
private bool isDisposed_;
// Token: 0x040002D8 RID: 728
private string name_;
// Token: 0x040002D9 RID: 729
private string comment_;
// Token: 0x040002DA RID: 730
private string rawPassword_;
// Token: 0x040002DB RID: 731
private Stream baseStream_;
// Token: 0x040002DC RID: 732
private bool isStreamOwner;
// Token: 0x040002DD RID: 733
private long offsetOfFirstEntry;
// Token: 0x040002DE RID: 734
private ZipEntry[] entries_;
// Token: 0x040002DF RID: 735
private byte[] key;
// Token: 0x040002E0 RID: 736
private bool isNewArchive_;
// Token: 0x040002E1 RID: 737
private UseZip64 useZip64_ = UseZip64.Dynamic;
// Token: 0x040002E2 RID: 738
private ArrayList updates_;
// Token: 0x040002E3 RID: 739
private long updateCount_;
// Token: 0x040002E4 RID: 740
private Hashtable updateIndex_;
// Token: 0x040002E5 RID: 741
private IArchiveStorage archiveStorage_;
// Token: 0x040002E6 RID: 742
private IDynamicDataSource updateDataSource_;
// Token: 0x040002E7 RID: 743
private bool contentsEdited_;
// Token: 0x040002E8 RID: 744
private int bufferSize_ = 4096;
// Token: 0x040002E9 RID: 745
private byte[] copyBuffer_;
// Token: 0x040002EA RID: 746
private ZipFile.ZipString newComment_;
// Token: 0x040002EB RID: 747
private bool commentEdited_;
// Token: 0x040002EC RID: 748
private IEntryFactory updateEntryFactory_ = new ZipEntryFactory();
// Token: 0x02000069 RID: 105
// (Invoke) Token: 0x0600043D RID: 1085
public delegate void KeysRequiredEventHandler(object sender, KeysRequiredEventArgs e);
// Token: 0x0200006A RID: 106
[Flags]
private enum HeaderTest
{
// Token: 0x040002EE RID: 750
Extract = 1,
// Token: 0x040002EF RID: 751
Header = 2
}
// Token: 0x0200006B RID: 107
private enum UpdateCommand
{
// Token: 0x040002F1 RID: 753
Copy,
// Token: 0x040002F2 RID: 754
Modify,
// Token: 0x040002F3 RID: 755
Add
}
// Token: 0x0200006C RID: 108
private class UpdateComparer : IComparer
{
// Token: 0x06000440 RID: 1088 RVA: 0x00016284 File Offset: 0x00015284
public int Compare(object x, object y)
{
ZipFile.ZipUpdate zipUpdate = x as ZipFile.ZipUpdate;
ZipFile.ZipUpdate zipUpdate2 = y as ZipFile.ZipUpdate;
int num;
if (zipUpdate == null)
{
if (zipUpdate2 == null)
{
num = 0;
}
else
{
num = -1;
}
}
else if (zipUpdate2 == null)
{
num = 1;
}
else
{
int num2 = ((zipUpdate.Command == ZipFile.UpdateCommand.Copy || zipUpdate.Command == ZipFile.UpdateCommand.Modify) ? 0 : 1);
int num3 = ((zipUpdate2.Command == ZipFile.UpdateCommand.Copy || zipUpdate2.Command == ZipFile.UpdateCommand.Modify) ? 0 : 1);
num = num2 - num3;
if (num == 0)
{
long num4 = zipUpdate.Entry.Offset - zipUpdate2.Entry.Offset;
if (num4 < 0L)
{
num = -1;
}
else if (num4 == 0L)
{
num = 0;
}
else
{
num = 1;
}
}
}
return num;
}
}
// Token: 0x0200006D RID: 109
private class ZipUpdate
{
// Token: 0x06000442 RID: 1090 RVA: 0x00016321 File Offset: 0x00015321
public ZipUpdate(string fileName, ZipEntry entry)
{
this.command_ = ZipFile.UpdateCommand.Add;
this.entry_ = entry;
this.filename_ = fileName;
}
// Token: 0x06000443 RID: 1091 RVA: 0x00016358 File Offset: 0x00015358
[Obsolete]
public ZipUpdate(string fileName, string entryName, CompressionMethod compressionMethod)
{
this.command_ = ZipFile.UpdateCommand.Add;
this.entry_ = new ZipEntry(entryName);
this.entry_.CompressionMethod = compressionMethod;
this.filename_ = fileName;
}
// Token: 0x06000444 RID: 1092 RVA: 0x000163A9 File Offset: 0x000153A9
[Obsolete]
public ZipUpdate(string fileName, string entryName)
: this(fileName, entryName, CompressionMethod.Deflated)
{
}
// Token: 0x06000445 RID: 1093 RVA: 0x000163B4 File Offset: 0x000153B4
[Obsolete]
public ZipUpdate(IStaticDataSource dataSource, string entryName, CompressionMethod compressionMethod)
{
this.command_ = ZipFile.UpdateCommand.Add;
this.entry_ = new ZipEntry(entryName);
this.entry_.CompressionMethod = compressionMethod;
this.dataSource_ = dataSource;
}
// Token: 0x06000446 RID: 1094 RVA: 0x00016405 File Offset: 0x00015405
public ZipUpdate(IStaticDataSource dataSource, ZipEntry entry)
{
this.command_ = ZipFile.UpdateCommand.Add;
this.entry_ = entry;
this.dataSource_ = dataSource;
}
// Token: 0x06000447 RID: 1095 RVA: 0x0001643A File Offset: 0x0001543A
public ZipUpdate(ZipEntry original, ZipEntry updated)
{
throw new ZipException("Modify not currently supported");
}
// Token: 0x06000448 RID: 1096 RVA: 0x00016464 File Offset: 0x00015464
public ZipUpdate(ZipFile.UpdateCommand command, ZipEntry entry)
{
this.command_ = command;
this.entry_ = (ZipEntry)entry.Clone();
}
// Token: 0x06000449 RID: 1097 RVA: 0x0001649C File Offset: 0x0001549C
public ZipUpdate(ZipEntry entry)
: this(ZipFile.UpdateCommand.Copy, entry)
{
}
// Token: 0x170000F7 RID: 247
// (get) Token: 0x0600044A RID: 1098 RVA: 0x000164A6 File Offset: 0x000154A6
public ZipEntry Entry
{
get
{
return this.entry_;
}
}
// Token: 0x170000F8 RID: 248
// (get) Token: 0x0600044B RID: 1099 RVA: 0x000164AE File Offset: 0x000154AE
public ZipEntry OutEntry
{
get
{
if (this.outEntry_ == null)
{
this.outEntry_ = (ZipEntry)this.entry_.Clone();
}
return this.outEntry_;
}
}
// Token: 0x170000F9 RID: 249
// (get) Token: 0x0600044C RID: 1100 RVA: 0x000164D4 File Offset: 0x000154D4
public ZipFile.UpdateCommand Command
{
get
{
return this.command_;
}
}
// Token: 0x170000FA RID: 250
// (get) Token: 0x0600044D RID: 1101 RVA: 0x000164DC File Offset: 0x000154DC
public string Filename
{
get
{
return this.filename_;
}
}
// Token: 0x170000FB RID: 251
// (get) Token: 0x0600044E RID: 1102 RVA: 0x000164E4 File Offset: 0x000154E4
// (set) Token: 0x0600044F RID: 1103 RVA: 0x000164EC File Offset: 0x000154EC
public long SizePatchOffset
{
get
{
return this.sizePatchOffset_;
}
set
{
this.sizePatchOffset_ = value;
}
}
// Token: 0x170000FC RID: 252
// (get) Token: 0x06000450 RID: 1104 RVA: 0x000164F5 File Offset: 0x000154F5
// (set) Token: 0x06000451 RID: 1105 RVA: 0x000164FD File Offset: 0x000154FD
public long CrcPatchOffset
{
get
{
return this.crcPatchOffset_;
}
set
{
this.crcPatchOffset_ = value;
}
}
// Token: 0x170000FD RID: 253
// (get) Token: 0x06000452 RID: 1106 RVA: 0x00016506 File Offset: 0x00015506
// (set) Token: 0x06000453 RID: 1107 RVA: 0x0001650E File Offset: 0x0001550E
public long OffsetBasedSize
{
get
{
return this._offsetBasedSize;
}
set
{
this._offsetBasedSize = value;
}
}
// Token: 0x06000454 RID: 1108 RVA: 0x00016518 File Offset: 0x00015518
public Stream GetSource()
{
Stream stream = null;
if (this.dataSource_ != null)
{
stream = this.dataSource_.GetSource();
}
return stream;
}
// Token: 0x040002F4 RID: 756
private ZipEntry entry_;
// Token: 0x040002F5 RID: 757
private ZipEntry outEntry_;
// Token: 0x040002F6 RID: 758
private ZipFile.UpdateCommand command_;
// Token: 0x040002F7 RID: 759
private IStaticDataSource dataSource_;
// Token: 0x040002F8 RID: 760
private string filename_;
// Token: 0x040002F9 RID: 761
private long sizePatchOffset_ = -1L;
// Token: 0x040002FA RID: 762
private long crcPatchOffset_ = -1L;
// Token: 0x040002FB RID: 763
private long _offsetBasedSize = -1L;
}
// Token: 0x0200006E RID: 110
private class ZipString
{
// Token: 0x06000455 RID: 1109 RVA: 0x0001653C File Offset: 0x0001553C
public ZipString(string comment)
{
this.comment_ = comment;
this.isSourceString_ = true;
}
// Token: 0x06000456 RID: 1110 RVA: 0x00016552 File Offset: 0x00015552
public ZipString(byte[] rawString)
{
this.rawComment_ = rawString;
}
// Token: 0x170000FE RID: 254
// (get) Token: 0x06000457 RID: 1111 RVA: 0x00016561 File Offset: 0x00015561
public bool IsSourceString
{
get
{
return this.isSourceString_;
}
}
// Token: 0x170000FF RID: 255
// (get) Token: 0x06000458 RID: 1112 RVA: 0x00016569 File Offset: 0x00015569
public int RawLength
{
get
{
this.MakeBytesAvailable();
return this.rawComment_.Length;
}
}
// Token: 0x17000100 RID: 256
// (get) Token: 0x06000459 RID: 1113 RVA: 0x00016579 File Offset: 0x00015579
public byte[] RawComment
{
get
{
this.MakeBytesAvailable();
return (byte[])this.rawComment_.Clone();
}
}
// Token: 0x0600045A RID: 1114 RVA: 0x00016591 File Offset: 0x00015591
public void Reset()
{
if (this.isSourceString_)
{
this.rawComment_ = null;
return;
}
this.comment_ = null;
}
// Token: 0x0600045B RID: 1115 RVA: 0x000165AA File Offset: 0x000155AA
private void MakeTextAvailable()
{
if (this.comment_ == null)
{
this.comment_ = ZipConstants.ConvertToString(this.rawComment_);
}
}
// Token: 0x0600045C RID: 1116 RVA: 0x000165C5 File Offset: 0x000155C5
private void MakeBytesAvailable()
{
if (this.rawComment_ == null)
{
this.rawComment_ = ZipConstants.ConvertToArray(this.comment_);
}
}
// Token: 0x0600045D RID: 1117 RVA: 0x000165E0 File Offset: 0x000155E0
public static implicit operator string(ZipFile.ZipString zipString)
{
zipString.MakeTextAvailable();
return zipString.comment_;
}
// Token: 0x040002FC RID: 764
private string comment_;
// Token: 0x040002FD RID: 765
private byte[] rawComment_;
// Token: 0x040002FE RID: 766
private bool isSourceString_;
}
// Token: 0x0200006F RID: 111
private class ZipEntryEnumerator : IEnumerator
{
// Token: 0x0600045E RID: 1118 RVA: 0x000165EE File Offset: 0x000155EE
public ZipEntryEnumerator(ZipEntry[] entries)
{
this.array = entries;
}
// Token: 0x17000101 RID: 257
// (get) Token: 0x0600045F RID: 1119 RVA: 0x00016604 File Offset: 0x00015604
public object Current
{
get
{
return this.array[this.index];
}
}
// Token: 0x06000460 RID: 1120 RVA: 0x00016613 File Offset: 0x00015613
public void Reset()
{
this.index = -1;
}
// Token: 0x06000461 RID: 1121 RVA: 0x0001661C File Offset: 0x0001561C
public bool MoveNext()
{
return ++this.index < this.array.Length;
}
// Token: 0x040002FF RID: 767
private ZipEntry[] array;
// Token: 0x04000300 RID: 768
private int index = -1;
}
// Token: 0x02000070 RID: 112
private class UncompressedStream : Stream
{
// Token: 0x06000462 RID: 1122 RVA: 0x00016644 File Offset: 0x00015644
public UncompressedStream(Stream baseStream)
{
this.baseStream_ = baseStream;
}
// Token: 0x06000463 RID: 1123 RVA: 0x00016653 File Offset: 0x00015653
public override void Close()
{
}
// Token: 0x17000102 RID: 258
// (get) Token: 0x06000464 RID: 1124 RVA: 0x00016655 File Offset: 0x00015655
public override bool CanRead
{
get
{
return false;
}
}
// Token: 0x06000465 RID: 1125 RVA: 0x00016658 File Offset: 0x00015658
public override void Flush()
{
this.baseStream_.Flush();
}
// Token: 0x17000103 RID: 259
// (get) Token: 0x06000466 RID: 1126 RVA: 0x00016665 File Offset: 0x00015665
public override bool CanWrite
{
get
{
return this.baseStream_.CanWrite;
}
}
// Token: 0x17000104 RID: 260
// (get) Token: 0x06000467 RID: 1127 RVA: 0x00016672 File Offset: 0x00015672
public override bool CanSeek
{
get
{
return false;
}
}
// Token: 0x17000105 RID: 261
// (get) Token: 0x06000468 RID: 1128 RVA: 0x00016675 File Offset: 0x00015675
public override long Length
{
get
{
return 0L;
}
}
// Token: 0x17000106 RID: 262
// (get) Token: 0x06000469 RID: 1129 RVA: 0x00016679 File Offset: 0x00015679
// (set) Token: 0x0600046A RID: 1130 RVA: 0x00016686 File Offset: 0x00015686
public override long Position
{
get
{
return this.baseStream_.Position;
}
set
{
}
}
// Token: 0x0600046B RID: 1131 RVA: 0x00016688 File Offset: 0x00015688
public override int Read(byte[] buffer, int offset, int count)
{
return 0;
}
// Token: 0x0600046C RID: 1132 RVA: 0x0001668B File Offset: 0x0001568B
public override long Seek(long offset, SeekOrigin origin)
{
return 0L;
}
// Token: 0x0600046D RID: 1133 RVA: 0x0001668F File Offset: 0x0001568F
public override void SetLength(long value)
{
}
// Token: 0x0600046E RID: 1134 RVA: 0x00016691 File Offset: 0x00015691
public override void Write(byte[] buffer, int offset, int count)
{
this.baseStream_.Write(buffer, offset, count);
}
// Token: 0x04000301 RID: 769
private Stream baseStream_;
}
// Token: 0x02000071 RID: 113
private class PartialInputStream : Stream
{
// Token: 0x0600046F RID: 1135 RVA: 0x000166A1 File Offset: 0x000156A1
public PartialInputStream(ZipFile zipFile, long start, long length)
{
this.start_ = start;
this.length_ = length;
this.zipFile_ = zipFile;
this.baseStream_ = this.zipFile_.baseStream_;
this.readPos_ = start;
this.end_ = start + length;
}
// Token: 0x06000470 RID: 1136 RVA: 0x000166E0 File Offset: 0x000156E0
public override int ReadByte()
{
if (this.readPos_ >= this.end_)
{
return -1;
}
int num2;
lock (this.baseStream_)
{
Stream stream2 = this.baseStream_;
long num;
this.readPos_ = (num = this.readPos_) + 1L;
stream2.Seek(num, SeekOrigin.Begin);
num2 = this.baseStream_.ReadByte();
}
return num2;
}
// Token: 0x06000471 RID: 1137 RVA: 0x00016750 File Offset: 0x00015750
public override void Close()
{
}
// Token: 0x06000472 RID: 1138 RVA: 0x00016754 File Offset: 0x00015754
public override int Read(byte[] buffer, int offset, int count)
{
int num2;
lock (this.baseStream_)
{
if ((long)count > this.end_ - this.readPos_)
{
count = (int)(this.end_ - this.readPos_);
if (count == 0)
{
return 0;
}
}
this.baseStream_.Seek(this.readPos_, SeekOrigin.Begin);
int num = this.baseStream_.Read(buffer, offset, count);
if (num > 0)
{
this.readPos_ += (long)num;
}
num2 = num;
}
return num2;
}
// Token: 0x06000473 RID: 1139 RVA: 0x000167E8 File Offset: 0x000157E8
public override void Write(byte[] buffer, int offset, int count)
{
throw new NotSupportedException();
}
// Token: 0x06000474 RID: 1140 RVA: 0x000167EF File Offset: 0x000157EF
public override void SetLength(long value)
{
throw new NotSupportedException();
}
// Token: 0x06000475 RID: 1141 RVA: 0x000167F8 File Offset: 0x000157F8
public override long Seek(long offset, SeekOrigin origin)
{
long num = this.readPos_;
switch (origin)
{
case SeekOrigin.Begin:
num = this.start_ + offset;
break;
case SeekOrigin.Current:
num = this.readPos_ + offset;
break;
case SeekOrigin.End:
num = this.end_ + offset;
break;
}
if (num < this.start_)
{
throw new ArgumentException("Negative position is invalid");
}
if (num >= this.end_)
{
throw new IOException("Cannot seek past end");
}
this.readPos_ = num;
return this.readPos_;
}
// Token: 0x06000476 RID: 1142 RVA: 0x00016876 File Offset: 0x00015876
public override void Flush()
{
}
// Token: 0x17000107 RID: 263
// (get) Token: 0x06000477 RID: 1143 RVA: 0x00016878 File Offset: 0x00015878
// (set) Token: 0x06000478 RID: 1144 RVA: 0x00016888 File Offset: 0x00015888
public override long Position
{
get
{
return this.readPos_ - this.start_;
}
set
{
long num = this.start_ + value;
if (num < this.start_)
{
throw new ArgumentException("Negative position is invalid");
}
if (num >= this.end_)
{
throw new InvalidOperationException("Cannot seek past end");
}
this.readPos_ = num;
}
}
// Token: 0x17000108 RID: 264
// (get) Token: 0x06000479 RID: 1145 RVA: 0x000168CD File Offset: 0x000158CD
public override long Length
{
get
{
return this.length_;
}
}
// Token: 0x17000109 RID: 265
// (get) Token: 0x0600047A RID: 1146 RVA: 0x000168D5 File Offset: 0x000158D5
public override bool CanWrite
{
get
{
return false;
}
}
// Token: 0x1700010A RID: 266
// (get) Token: 0x0600047B RID: 1147 RVA: 0x000168D8 File Offset: 0x000158D8
public override bool CanSeek
{
get
{
return true;
}
}
// Token: 0x1700010B RID: 267
// (get) Token: 0x0600047C RID: 1148 RVA: 0x000168DB File Offset: 0x000158DB
public override bool CanRead
{
get
{
return true;
}
}
// Token: 0x1700010C RID: 268
// (get) Token: 0x0600047D RID: 1149 RVA: 0x000168DE File Offset: 0x000158DE
public override bool CanTimeout
{
get
{
return this.baseStream_.CanTimeout;
}
}
// Token: 0x04000302 RID: 770
private ZipFile zipFile_;
// Token: 0x04000303 RID: 771
private Stream baseStream_;
// Token: 0x04000304 RID: 772
private long start_;
// Token: 0x04000305 RID: 773
private long length_;
// Token: 0x04000306 RID: 774
private long readPos_;
// Token: 0x04000307 RID: 775
private long end_;
}
}
}