scripts
This commit is contained in:
@@ -0,0 +1,455 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Zip
|
||||
{
|
||||
// Token: 0x0200007C RID: 124
|
||||
internal class ZipHelperStream : Stream
|
||||
{
|
||||
// Token: 0x060004AD RID: 1197 RVA: 0x00016D16 File Offset: 0x00015D16
|
||||
public ZipHelperStream(string name)
|
||||
{
|
||||
this.stream_ = new FileStream(name, FileMode.Open, FileAccess.ReadWrite);
|
||||
this.isOwner_ = true;
|
||||
}
|
||||
|
||||
// Token: 0x060004AE RID: 1198 RVA: 0x00016D33 File Offset: 0x00015D33
|
||||
public ZipHelperStream(Stream stream)
|
||||
{
|
||||
this.stream_ = stream;
|
||||
}
|
||||
|
||||
// Token: 0x17000115 RID: 277
|
||||
// (get) Token: 0x060004AF RID: 1199 RVA: 0x00016D42 File Offset: 0x00015D42
|
||||
// (set) Token: 0x060004B0 RID: 1200 RVA: 0x00016D4A File Offset: 0x00015D4A
|
||||
public bool IsStreamOwner
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.isOwner_;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.isOwner_ = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000116 RID: 278
|
||||
// (get) Token: 0x060004B1 RID: 1201 RVA: 0x00016D53 File Offset: 0x00015D53
|
||||
public override bool CanRead
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.stream_.CanRead;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000117 RID: 279
|
||||
// (get) Token: 0x060004B2 RID: 1202 RVA: 0x00016D60 File Offset: 0x00015D60
|
||||
public override bool CanSeek
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.stream_.CanSeek;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000118 RID: 280
|
||||
// (get) Token: 0x060004B3 RID: 1203 RVA: 0x00016D6D File Offset: 0x00015D6D
|
||||
public override bool CanTimeout
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.stream_.CanTimeout;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000119 RID: 281
|
||||
// (get) Token: 0x060004B4 RID: 1204 RVA: 0x00016D7A File Offset: 0x00015D7A
|
||||
public override long Length
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.stream_.Length;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700011A RID: 282
|
||||
// (get) Token: 0x060004B5 RID: 1205 RVA: 0x00016D87 File Offset: 0x00015D87
|
||||
// (set) Token: 0x060004B6 RID: 1206 RVA: 0x00016D94 File Offset: 0x00015D94
|
||||
public override long Position
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.stream_.Position;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.stream_.Position = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700011B RID: 283
|
||||
// (get) Token: 0x060004B7 RID: 1207 RVA: 0x00016DA2 File Offset: 0x00015DA2
|
||||
public override bool CanWrite
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.stream_.CanWrite;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060004B8 RID: 1208 RVA: 0x00016DAF File Offset: 0x00015DAF
|
||||
public override void Flush()
|
||||
{
|
||||
this.stream_.Flush();
|
||||
}
|
||||
|
||||
// Token: 0x060004B9 RID: 1209 RVA: 0x00016DBC File Offset: 0x00015DBC
|
||||
public override long Seek(long offset, SeekOrigin origin)
|
||||
{
|
||||
return this.stream_.Seek(offset, origin);
|
||||
}
|
||||
|
||||
// Token: 0x060004BA RID: 1210 RVA: 0x00016DCB File Offset: 0x00015DCB
|
||||
public override void SetLength(long value)
|
||||
{
|
||||
this.stream_.SetLength(value);
|
||||
}
|
||||
|
||||
// Token: 0x060004BB RID: 1211 RVA: 0x00016DD9 File Offset: 0x00015DD9
|
||||
public override int Read(byte[] buffer, int offset, int count)
|
||||
{
|
||||
return this.stream_.Read(buffer, offset, count);
|
||||
}
|
||||
|
||||
// Token: 0x060004BC RID: 1212 RVA: 0x00016DE9 File Offset: 0x00015DE9
|
||||
public override void Write(byte[] buffer, int offset, int count)
|
||||
{
|
||||
this.stream_.Write(buffer, offset, count);
|
||||
}
|
||||
|
||||
// Token: 0x060004BD RID: 1213 RVA: 0x00016DFC File Offset: 0x00015DFC
|
||||
public override void Close()
|
||||
{
|
||||
Stream stream = this.stream_;
|
||||
this.stream_ = null;
|
||||
if (this.isOwner_ && stream != null)
|
||||
{
|
||||
this.isOwner_ = false;
|
||||
stream.Close();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060004BE RID: 1214 RVA: 0x00016E30 File Offset: 0x00015E30
|
||||
private void WriteLocalHeader(ZipEntry entry, EntryPatchData patchData)
|
||||
{
|
||||
CompressionMethod compressionMethod = entry.CompressionMethod;
|
||||
bool flag = true;
|
||||
bool flag2 = false;
|
||||
this.WriteLEInt(67324752);
|
||||
this.WriteLEShort(entry.Version);
|
||||
this.WriteLEShort(entry.Flags);
|
||||
this.WriteLEShort((int)((byte)compressionMethod));
|
||||
this.WriteLEInt((int)entry.DosTime);
|
||||
if (flag)
|
||||
{
|
||||
this.WriteLEInt((int)entry.Crc);
|
||||
if (entry.LocalHeaderRequiresZip64)
|
||||
{
|
||||
this.WriteLEInt(-1);
|
||||
this.WriteLEInt(-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.WriteLEInt(entry.IsCrypted ? ((int)entry.CompressedSize + 12) : ((int)entry.CompressedSize));
|
||||
this.WriteLEInt((int)entry.Size);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (patchData != null)
|
||||
{
|
||||
patchData.CrcPatchOffset = this.stream_.Position;
|
||||
}
|
||||
this.WriteLEInt(0);
|
||||
if (patchData != null)
|
||||
{
|
||||
patchData.SizePatchOffset = this.stream_.Position;
|
||||
}
|
||||
if (entry.LocalHeaderRequiresZip64 && flag2)
|
||||
{
|
||||
this.WriteLEInt(-1);
|
||||
this.WriteLEInt(-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.WriteLEInt(0);
|
||||
this.WriteLEInt(0);
|
||||
}
|
||||
}
|
||||
byte[] array = ZipConstants.ConvertToArray(entry.Flags, entry.Name);
|
||||
if (array.Length > 65535)
|
||||
{
|
||||
throw new ZipException("Entry name too long.");
|
||||
}
|
||||
ZipExtraData zipExtraData = new ZipExtraData(entry.ExtraData);
|
||||
if (entry.LocalHeaderRequiresZip64 && (flag || flag2))
|
||||
{
|
||||
zipExtraData.StartNewEntry();
|
||||
if (flag)
|
||||
{
|
||||
zipExtraData.AddLeLong(entry.Size);
|
||||
zipExtraData.AddLeLong(entry.CompressedSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
zipExtraData.AddLeLong(-1L);
|
||||
zipExtraData.AddLeLong(-1L);
|
||||
}
|
||||
zipExtraData.AddNewEntry(1);
|
||||
if (!zipExtraData.Find(1))
|
||||
{
|
||||
throw new ZipException("Internal error cant find extra data");
|
||||
}
|
||||
if (patchData != null)
|
||||
{
|
||||
patchData.SizePatchOffset = (long)zipExtraData.CurrentReadIndex;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
zipExtraData.Delete(1);
|
||||
}
|
||||
byte[] entryData = zipExtraData.GetEntryData();
|
||||
this.WriteLEShort(array.Length);
|
||||
this.WriteLEShort(entryData.Length);
|
||||
if (array.Length > 0)
|
||||
{
|
||||
this.stream_.Write(array, 0, array.Length);
|
||||
}
|
||||
if (entry.LocalHeaderRequiresZip64 && flag2)
|
||||
{
|
||||
patchData.SizePatchOffset += this.stream_.Position;
|
||||
}
|
||||
if (entryData.Length > 0)
|
||||
{
|
||||
this.stream_.Write(entryData, 0, entryData.Length);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060004BF RID: 1215 RVA: 0x00017054 File Offset: 0x00016054
|
||||
public long LocateBlockWithSignature(int signature, long endLocation, int minimumBlockSize, int maximumVariableData)
|
||||
{
|
||||
long num = endLocation - (long)minimumBlockSize;
|
||||
if (num < 0L)
|
||||
{
|
||||
return -1L;
|
||||
}
|
||||
long num2 = Math.Max(num - (long)maximumVariableData, 0L);
|
||||
while (num >= num2)
|
||||
{
|
||||
long num3 = num;
|
||||
num = num3 - 1L;
|
||||
this.Seek(num3, SeekOrigin.Begin);
|
||||
if (this.ReadLEInt() == signature)
|
||||
{
|
||||
return this.Position;
|
||||
}
|
||||
}
|
||||
return -1L;
|
||||
}
|
||||
|
||||
// Token: 0x060004C0 RID: 1216 RVA: 0x000170A0 File Offset: 0x000160A0
|
||||
public void WriteZip64EndOfCentralDirectory(long noOfEntries, long sizeEntries, long centralDirOffset)
|
||||
{
|
||||
long position = this.stream_.Position;
|
||||
this.WriteLEInt(101075792);
|
||||
this.WriteLELong(44L);
|
||||
this.WriteLEShort(51);
|
||||
this.WriteLEShort(45);
|
||||
this.WriteLEInt(0);
|
||||
this.WriteLEInt(0);
|
||||
this.WriteLELong(noOfEntries);
|
||||
this.WriteLELong(noOfEntries);
|
||||
this.WriteLELong(sizeEntries);
|
||||
this.WriteLELong(centralDirOffset);
|
||||
this.WriteLEInt(117853008);
|
||||
this.WriteLEInt(0);
|
||||
this.WriteLELong(position);
|
||||
this.WriteLEInt(1);
|
||||
}
|
||||
|
||||
// Token: 0x060004C1 RID: 1217 RVA: 0x00017128 File Offset: 0x00016128
|
||||
public void WriteEndOfCentralDirectory(long noOfEntries, long sizeEntries, long startOfCentralDirectory, byte[] comment)
|
||||
{
|
||||
if (noOfEntries >= 65535L || startOfCentralDirectory >= (long)((ulong)(-1)) || sizeEntries >= (long)((ulong)(-1)))
|
||||
{
|
||||
this.WriteZip64EndOfCentralDirectory(noOfEntries, sizeEntries, startOfCentralDirectory);
|
||||
}
|
||||
this.WriteLEInt(101010256);
|
||||
this.WriteLEShort(0);
|
||||
this.WriteLEShort(0);
|
||||
if (noOfEntries >= 65535L)
|
||||
{
|
||||
this.WriteLEUshort(ushort.MaxValue);
|
||||
this.WriteLEUshort(ushort.MaxValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.WriteLEShort((int)((short)noOfEntries));
|
||||
this.WriteLEShort((int)((short)noOfEntries));
|
||||
}
|
||||
if (sizeEntries >= (long)((ulong)(-1)))
|
||||
{
|
||||
this.WriteLEUint(uint.MaxValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.WriteLEInt((int)sizeEntries);
|
||||
}
|
||||
if (startOfCentralDirectory >= (long)((ulong)(-1)))
|
||||
{
|
||||
this.WriteLEUint(uint.MaxValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.WriteLEInt((int)startOfCentralDirectory);
|
||||
}
|
||||
int num = ((comment != null) ? comment.Length : 0);
|
||||
if (num > 65535)
|
||||
{
|
||||
throw new ZipException(string.Format("Comment length({0}) is too long can only be 64K", num));
|
||||
}
|
||||
this.WriteLEShort(num);
|
||||
if (num > 0)
|
||||
{
|
||||
this.Write(comment, 0, comment.Length);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x060004C2 RID: 1218 RVA: 0x0001720C File Offset: 0x0001620C
|
||||
public int ReadLEShort()
|
||||
{
|
||||
int num = this.stream_.ReadByte();
|
||||
if (num < 0)
|
||||
{
|
||||
throw new EndOfStreamException();
|
||||
}
|
||||
int num2 = this.stream_.ReadByte();
|
||||
if (num2 < 0)
|
||||
{
|
||||
throw new EndOfStreamException();
|
||||
}
|
||||
return num | (num2 << 8);
|
||||
}
|
||||
|
||||
// Token: 0x060004C3 RID: 1219 RVA: 0x0001724A File Offset: 0x0001624A
|
||||
public int ReadLEInt()
|
||||
{
|
||||
return this.ReadLEShort() | (this.ReadLEShort() << 16);
|
||||
}
|
||||
|
||||
// Token: 0x060004C4 RID: 1220 RVA: 0x0001725C File Offset: 0x0001625C
|
||||
public long ReadLELong()
|
||||
{
|
||||
return (long)((ulong)this.ReadLEInt() | (ulong)((ulong)((long)this.ReadLEInt()) << 32));
|
||||
}
|
||||
|
||||
// Token: 0x060004C5 RID: 1221 RVA: 0x00017270 File Offset: 0x00016270
|
||||
public void WriteLEShort(int value)
|
||||
{
|
||||
this.stream_.WriteByte((byte)(value & 255));
|
||||
this.stream_.WriteByte((byte)((value >> 8) & 255));
|
||||
}
|
||||
|
||||
// Token: 0x060004C6 RID: 1222 RVA: 0x0001729A File Offset: 0x0001629A
|
||||
public void WriteLEUshort(ushort value)
|
||||
{
|
||||
this.stream_.WriteByte((byte)(value & 255));
|
||||
this.stream_.WriteByte((byte)(value >> 8));
|
||||
}
|
||||
|
||||
// Token: 0x060004C7 RID: 1223 RVA: 0x000172BE File Offset: 0x000162BE
|
||||
public void WriteLEInt(int value)
|
||||
{
|
||||
this.WriteLEShort(value);
|
||||
this.WriteLEShort(value >> 16);
|
||||
}
|
||||
|
||||
// Token: 0x060004C8 RID: 1224 RVA: 0x000172D1 File Offset: 0x000162D1
|
||||
public void WriteLEUint(uint value)
|
||||
{
|
||||
this.WriteLEUshort((ushort)(value & 65535U));
|
||||
this.WriteLEUshort((ushort)(value >> 16));
|
||||
}
|
||||
|
||||
// Token: 0x060004C9 RID: 1225 RVA: 0x000172EC File Offset: 0x000162EC
|
||||
public void WriteLELong(long value)
|
||||
{
|
||||
this.WriteLEInt((int)value);
|
||||
this.WriteLEInt((int)(value >> 32));
|
||||
}
|
||||
|
||||
// Token: 0x060004CA RID: 1226 RVA: 0x00017301 File Offset: 0x00016301
|
||||
public void WriteLEUlong(ulong value)
|
||||
{
|
||||
this.WriteLEUint((uint)(value & (ulong)(-1)));
|
||||
this.WriteLEUint((uint)(value >> 32));
|
||||
}
|
||||
|
||||
// Token: 0x060004CB RID: 1227 RVA: 0x0001731C File Offset: 0x0001631C
|
||||
public int WriteDataDescriptor(ZipEntry entry)
|
||||
{
|
||||
if (entry == null)
|
||||
{
|
||||
throw new ArgumentNullException("entry");
|
||||
}
|
||||
int num = 0;
|
||||
if ((entry.Flags & 8) != 0)
|
||||
{
|
||||
this.WriteLEInt(134695760);
|
||||
this.WriteLEInt((int)entry.Crc);
|
||||
num += 8;
|
||||
if (entry.LocalHeaderRequiresZip64)
|
||||
{
|
||||
this.WriteLELong(entry.CompressedSize);
|
||||
this.WriteLELong(entry.Size);
|
||||
num += 16;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.WriteLEInt((int)entry.CompressedSize);
|
||||
this.WriteLEInt((int)entry.Size);
|
||||
num += 8;
|
||||
}
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
// Token: 0x060004CC RID: 1228 RVA: 0x000173A8 File Offset: 0x000163A8
|
||||
public void ReadDataDescriptor(bool zip64, DescriptorData data)
|
||||
{
|
||||
int num = this.ReadLEInt();
|
||||
if (num != 134695760)
|
||||
{
|
||||
throw new ZipException("Data descriptor signature not found");
|
||||
}
|
||||
data.Crc = (long)this.ReadLEInt();
|
||||
if (zip64)
|
||||
{
|
||||
data.CompressedSize = this.ReadLELong();
|
||||
data.Size = this.ReadLELong();
|
||||
return;
|
||||
}
|
||||
data.CompressedSize = (long)this.ReadLEInt();
|
||||
data.Size = (long)this.ReadLEInt();
|
||||
}
|
||||
|
||||
// Token: 0x04000314 RID: 788
|
||||
private bool isOwner_;
|
||||
|
||||
// Token: 0x04000315 RID: 789
|
||||
private Stream stream_;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user