scripts
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.GZip
|
||||
{
|
||||
// Token: 0x02000027 RID: 39
|
||||
public sealed class GZipConstants
|
||||
{
|
||||
// Token: 0x0600010F RID: 271 RVA: 0x00008390 File Offset: 0x00007390
|
||||
private GZipConstants()
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x0400009F RID: 159
|
||||
public const int GZIP_MAGIC = 8075;
|
||||
|
||||
// Token: 0x040000A0 RID: 160
|
||||
public const int FTEXT = 1;
|
||||
|
||||
// Token: 0x040000A1 RID: 161
|
||||
public const int FHCRC = 2;
|
||||
|
||||
// Token: 0x040000A2 RID: 162
|
||||
public const int FEXTRA = 4;
|
||||
|
||||
// Token: 0x040000A3 RID: 163
|
||||
public const int FNAME = 8;
|
||||
|
||||
// Token: 0x040000A4 RID: 164
|
||||
public const int FCOMMENT = 16;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.GZip
|
||||
{
|
||||
// Token: 0x02000028 RID: 40
|
||||
[Serializable]
|
||||
public class GZipException : SharpZipBaseException
|
||||
{
|
||||
// Token: 0x06000110 RID: 272 RVA: 0x00008398 File Offset: 0x00007398
|
||||
protected GZipException(SerializationInfo info, StreamingContext context)
|
||||
: base(info, context)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x06000111 RID: 273 RVA: 0x000083A2 File Offset: 0x000073A2
|
||||
public GZipException()
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x06000112 RID: 274 RVA: 0x000083AA File Offset: 0x000073AA
|
||||
public GZipException(string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x06000113 RID: 275 RVA: 0x000083B3 File Offset: 0x000073B3
|
||||
public GZipException(string message, Exception innerException)
|
||||
: base(message, innerException)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,231 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using ICSharpCode.SharpZipLib.Checksums;
|
||||
using ICSharpCode.SharpZipLib.Zip.Compression;
|
||||
using ICSharpCode.SharpZipLib.Zip.Compression.Streams;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.GZip
|
||||
{
|
||||
// Token: 0x0200002A RID: 42
|
||||
public class GZipInputStream : InflaterInputStream
|
||||
{
|
||||
// Token: 0x0600012B RID: 299 RVA: 0x00008661 File Offset: 0x00007661
|
||||
public GZipInputStream(Stream baseInputStream)
|
||||
: this(baseInputStream, 4096)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x0600012C RID: 300 RVA: 0x0000866F File Offset: 0x0000766F
|
||||
public GZipInputStream(Stream baseInputStream, int size)
|
||||
: base(baseInputStream, new Inflater(true), size)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x0600012D RID: 301 RVA: 0x00008680 File Offset: 0x00007680
|
||||
public override int Read(byte[] buffer, int offset, int count)
|
||||
{
|
||||
while (this.readGZIPHeader || this.ReadHeader())
|
||||
{
|
||||
int num = base.Read(buffer, offset, count);
|
||||
if (num > 0)
|
||||
{
|
||||
this.crc.Update(buffer, offset, num);
|
||||
}
|
||||
if (this.inf.IsFinished)
|
||||
{
|
||||
this.ReadFooter();
|
||||
}
|
||||
if (num > 0)
|
||||
{
|
||||
return num;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Token: 0x0600012E RID: 302 RVA: 0x000086D4 File Offset: 0x000076D4
|
||||
private bool ReadHeader()
|
||||
{
|
||||
this.crc = new Crc32();
|
||||
if (this.inputBuffer.Available <= 0)
|
||||
{
|
||||
this.inputBuffer.Fill();
|
||||
if (this.inputBuffer.Available <= 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Crc32 crc = new Crc32();
|
||||
int num = this.inputBuffer.ReadLeByte();
|
||||
if (num < 0)
|
||||
{
|
||||
throw new EndOfStreamException("EOS reading GZIP header");
|
||||
}
|
||||
crc.Update(num);
|
||||
if (num != 31)
|
||||
{
|
||||
throw new GZipException("Error GZIP header, first magic byte doesn't match");
|
||||
}
|
||||
num = this.inputBuffer.ReadLeByte();
|
||||
if (num < 0)
|
||||
{
|
||||
throw new EndOfStreamException("EOS reading GZIP header");
|
||||
}
|
||||
if (num != 139)
|
||||
{
|
||||
throw new GZipException("Error GZIP header, second magic byte doesn't match");
|
||||
}
|
||||
crc.Update(num);
|
||||
int num2 = this.inputBuffer.ReadLeByte();
|
||||
if (num2 < 0)
|
||||
{
|
||||
throw new EndOfStreamException("EOS reading GZIP header");
|
||||
}
|
||||
if (num2 != 8)
|
||||
{
|
||||
throw new GZipException("Error GZIP header, data not in deflate format");
|
||||
}
|
||||
crc.Update(num2);
|
||||
int num3 = this.inputBuffer.ReadLeByte();
|
||||
if (num3 < 0)
|
||||
{
|
||||
throw new EndOfStreamException("EOS reading GZIP header");
|
||||
}
|
||||
crc.Update(num3);
|
||||
if ((num3 & 224) != 0)
|
||||
{
|
||||
throw new GZipException("Reserved flag bits in GZIP header != 0");
|
||||
}
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
int num4 = this.inputBuffer.ReadLeByte();
|
||||
if (num4 < 0)
|
||||
{
|
||||
throw new EndOfStreamException("EOS reading GZIP header");
|
||||
}
|
||||
crc.Update(num4);
|
||||
}
|
||||
if ((num3 & 4) != 0)
|
||||
{
|
||||
for (int j = 0; j < 2; j++)
|
||||
{
|
||||
int num5 = this.inputBuffer.ReadLeByte();
|
||||
if (num5 < 0)
|
||||
{
|
||||
throw new EndOfStreamException("EOS reading GZIP header");
|
||||
}
|
||||
crc.Update(num5);
|
||||
}
|
||||
if (this.inputBuffer.ReadLeByte() < 0 || this.inputBuffer.ReadLeByte() < 0)
|
||||
{
|
||||
throw new EndOfStreamException("EOS reading GZIP header");
|
||||
}
|
||||
int num6 = this.inputBuffer.ReadLeByte();
|
||||
int num7 = this.inputBuffer.ReadLeByte();
|
||||
if (num6 < 0 || num7 < 0)
|
||||
{
|
||||
throw new EndOfStreamException("EOS reading GZIP header");
|
||||
}
|
||||
crc.Update(num6);
|
||||
crc.Update(num7);
|
||||
int num8 = (num6 << 8) | num7;
|
||||
for (int k = 0; k < num8; k++)
|
||||
{
|
||||
int num9 = this.inputBuffer.ReadLeByte();
|
||||
if (num9 < 0)
|
||||
{
|
||||
throw new EndOfStreamException("EOS reading GZIP header");
|
||||
}
|
||||
crc.Update(num9);
|
||||
}
|
||||
}
|
||||
if ((num3 & 8) != 0)
|
||||
{
|
||||
int num10;
|
||||
while ((num10 = this.inputBuffer.ReadLeByte()) > 0)
|
||||
{
|
||||
crc.Update(num10);
|
||||
}
|
||||
if (num10 < 0)
|
||||
{
|
||||
throw new EndOfStreamException("EOS reading GZIP header");
|
||||
}
|
||||
crc.Update(num10);
|
||||
}
|
||||
if ((num3 & 16) != 0)
|
||||
{
|
||||
int num11;
|
||||
while ((num11 = this.inputBuffer.ReadLeByte()) > 0)
|
||||
{
|
||||
crc.Update(num11);
|
||||
}
|
||||
if (num11 < 0)
|
||||
{
|
||||
throw new EndOfStreamException("EOS reading GZIP header");
|
||||
}
|
||||
crc.Update(num11);
|
||||
}
|
||||
if ((num3 & 2) != 0)
|
||||
{
|
||||
int num12 = this.inputBuffer.ReadLeByte();
|
||||
if (num12 < 0)
|
||||
{
|
||||
throw new EndOfStreamException("EOS reading GZIP header");
|
||||
}
|
||||
int num13 = this.inputBuffer.ReadLeByte();
|
||||
if (num13 < 0)
|
||||
{
|
||||
throw new EndOfStreamException("EOS reading GZIP header");
|
||||
}
|
||||
num12 = (num12 << 8) | num13;
|
||||
if (num12 != ((int)crc.Value & 65535))
|
||||
{
|
||||
throw new GZipException("Header CRC value mismatch");
|
||||
}
|
||||
}
|
||||
this.readGZIPHeader = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Token: 0x0600012F RID: 303 RVA: 0x000089E0 File Offset: 0x000079E0
|
||||
private void ReadFooter()
|
||||
{
|
||||
byte[] array = new byte[8];
|
||||
long num = this.inf.TotalOut & (long)((ulong)(-1));
|
||||
this.inputBuffer.Available += this.inf.RemainingInput;
|
||||
this.inf.Reset();
|
||||
int num2;
|
||||
for (int i = 8; i > 0; i -= num2)
|
||||
{
|
||||
num2 = this.inputBuffer.ReadClearTextBuffer(array, 8 - i, i);
|
||||
if (num2 <= 0)
|
||||
{
|
||||
throw new EndOfStreamException("EOS reading GZIP footer");
|
||||
}
|
||||
}
|
||||
int num3 = (int)(array[0] & byte.MaxValue) | ((int)(array[1] & byte.MaxValue) << 8) | ((int)(array[2] & byte.MaxValue) << 16) | ((int)array[3] << 24);
|
||||
if (num3 != (int)this.crc.Value)
|
||||
{
|
||||
throw new GZipException(string.Concat(new object[]
|
||||
{
|
||||
"GZIP crc sum mismatch, theirs \"",
|
||||
num3,
|
||||
"\" and ours \"",
|
||||
(int)this.crc.Value
|
||||
}));
|
||||
}
|
||||
uint num4 = (uint)((int)(array[4] & byte.MaxValue) | ((int)(array[5] & byte.MaxValue) << 8) | ((int)(array[6] & byte.MaxValue) << 16) | ((int)array[7] << 24));
|
||||
if (num != (long)((ulong)num4))
|
||||
{
|
||||
throw new GZipException("Number of bytes mismatch in footer");
|
||||
}
|
||||
this.readGZIPHeader = false;
|
||||
}
|
||||
|
||||
// Token: 0x040000AB RID: 171
|
||||
protected Crc32 crc;
|
||||
|
||||
// Token: 0x040000AC RID: 172
|
||||
private bool readGZIPHeader;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using ICSharpCode.SharpZipLib.Checksums;
|
||||
using ICSharpCode.SharpZipLib.Zip.Compression;
|
||||
using ICSharpCode.SharpZipLib.Zip.Compression.Streams;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.GZip
|
||||
{
|
||||
// Token: 0x0200002C RID: 44
|
||||
public class GZipOutputStream : DeflaterOutputStream
|
||||
{
|
||||
// Token: 0x0600014E RID: 334 RVA: 0x00008F57 File Offset: 0x00007F57
|
||||
public GZipOutputStream(Stream baseOutputStream)
|
||||
: this(baseOutputStream, 4096)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x0600014F RID: 335 RVA: 0x00008F65 File Offset: 0x00007F65
|
||||
public GZipOutputStream(Stream baseOutputStream, int size)
|
||||
: base(baseOutputStream, new Deflater(-1, true), size)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x06000150 RID: 336 RVA: 0x00008F81 File Offset: 0x00007F81
|
||||
public void SetLevel(int level)
|
||||
{
|
||||
if (level < 1)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("level");
|
||||
}
|
||||
this.deflater_.SetLevel(level);
|
||||
}
|
||||
|
||||
// Token: 0x06000151 RID: 337 RVA: 0x00008F9E File Offset: 0x00007F9E
|
||||
public int GetLevel()
|
||||
{
|
||||
return this.deflater_.GetLevel();
|
||||
}
|
||||
|
||||
// Token: 0x06000152 RID: 338 RVA: 0x00008FAB File Offset: 0x00007FAB
|
||||
public override void Write(byte[] buffer, int offset, int count)
|
||||
{
|
||||
if (this.state_ == GZipOutputStream.OutputState.Header)
|
||||
{
|
||||
this.WriteHeader();
|
||||
}
|
||||
if (this.state_ != GZipOutputStream.OutputState.Footer)
|
||||
{
|
||||
throw new InvalidOperationException("Write not permitted in current state");
|
||||
}
|
||||
this.crc.Update(buffer, offset, count);
|
||||
base.Write(buffer, offset, count);
|
||||
}
|
||||
|
||||
// Token: 0x06000153 RID: 339 RVA: 0x00008FE8 File Offset: 0x00007FE8
|
||||
public override void Close()
|
||||
{
|
||||
try
|
||||
{
|
||||
this.Finish();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (this.state_ != GZipOutputStream.OutputState.Closed)
|
||||
{
|
||||
this.state_ = GZipOutputStream.OutputState.Closed;
|
||||
if (base.IsStreamOwner)
|
||||
{
|
||||
this.baseOutputStream_.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000154 RID: 340 RVA: 0x00009034 File Offset: 0x00008034
|
||||
public override void Finish()
|
||||
{
|
||||
if (this.state_ == GZipOutputStream.OutputState.Header)
|
||||
{
|
||||
this.WriteHeader();
|
||||
}
|
||||
if (this.state_ == GZipOutputStream.OutputState.Footer)
|
||||
{
|
||||
this.state_ = GZipOutputStream.OutputState.Finished;
|
||||
base.Finish();
|
||||
uint num = (uint)(this.deflater_.TotalIn & (long)((ulong)(-1)));
|
||||
uint num2 = (uint)(this.crc.Value & (long)((ulong)(-1)));
|
||||
byte[] array = new byte[]
|
||||
{
|
||||
(byte)num2,
|
||||
(byte)(num2 >> 8),
|
||||
(byte)(num2 >> 16),
|
||||
(byte)(num2 >> 24),
|
||||
(byte)num,
|
||||
(byte)(num >> 8),
|
||||
(byte)(num >> 16),
|
||||
(byte)(num >> 24)
|
||||
};
|
||||
this.baseOutputStream_.Write(array, 0, array.Length);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000155 RID: 341 RVA: 0x000090E4 File Offset: 0x000080E4
|
||||
private void WriteHeader()
|
||||
{
|
||||
if (this.state_ == GZipOutputStream.OutputState.Header)
|
||||
{
|
||||
this.state_ = GZipOutputStream.OutputState.Footer;
|
||||
int num = (int)((DateTime.Now.Ticks - new DateTime(1970, 1, 1).Ticks) / 10000000L);
|
||||
byte[] array = new byte[] { 31, 139, 8, 0, 0, 0, 0, 0, 0, byte.MaxValue };
|
||||
array[4] = (byte)num;
|
||||
array[5] = (byte)(num >> 8);
|
||||
array[6] = (byte)(num >> 16);
|
||||
array[7] = (byte)(num >> 24);
|
||||
byte[] array2 = array;
|
||||
this.baseOutputStream_.Write(array2, 0, array2.Length);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x040000B6 RID: 182
|
||||
protected Crc32 crc = new Crc32();
|
||||
|
||||
// Token: 0x040000B7 RID: 183
|
||||
private GZipOutputStream.OutputState state_;
|
||||
|
||||
// Token: 0x0200002D RID: 45
|
||||
private enum OutputState
|
||||
{
|
||||
// Token: 0x040000B9 RID: 185
|
||||
Header,
|
||||
// Token: 0x040000BA RID: 186
|
||||
Footer,
|
||||
// Token: 0x040000BB RID: 187
|
||||
Finished,
|
||||
// Token: 0x040000BC RID: 188
|
||||
Closed
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user