This commit is contained in:
niko
2026-06-04 11:42:34 +02:00
parent f39ba70a9f
commit e720b98cd1
7488 changed files with 2493818 additions and 0 deletions
+377
View File
@@ -0,0 +1,377 @@
using System;
using System.IO;
namespace ICSharpCode.SharpZipLib.Zip
{
// Token: 0x02000061 RID: 97
public sealed class ZipExtraData : IDisposable
{
// Token: 0x060003A6 RID: 934 RVA: 0x00012BD3 File Offset: 0x00011BD3
public ZipExtraData()
{
this.Clear();
}
// Token: 0x060003A7 RID: 935 RVA: 0x00012BE1 File Offset: 0x00011BE1
public ZipExtraData(byte[] data)
{
if (data == null)
{
this._data = new byte[0];
return;
}
this._data = data;
}
// Token: 0x060003A8 RID: 936 RVA: 0x00012C00 File Offset: 0x00011C00
public byte[] GetEntryData()
{
if (this.Length > 65535)
{
throw new ZipException("Data exceeds maximum length");
}
return (byte[])this._data.Clone();
}
// Token: 0x060003A9 RID: 937 RVA: 0x00012C2A File Offset: 0x00011C2A
public void Clear()
{
if (this._data == null || this._data.Length != 0)
{
this._data = new byte[0];
}
}
// Token: 0x170000DB RID: 219
// (get) Token: 0x060003AA RID: 938 RVA: 0x00012C4A File Offset: 0x00011C4A
public int Length
{
get
{
return this._data.Length;
}
}
// Token: 0x060003AB RID: 939 RVA: 0x00012C54 File Offset: 0x00011C54
public Stream GetStreamForTag(int tag)
{
Stream stream = null;
if (this.Find(tag))
{
stream = new MemoryStream(this._data, this._index, this._readValueLength, false);
}
return stream;
}
// Token: 0x060003AC RID: 940 RVA: 0x00012C88 File Offset: 0x00011C88
private ITaggedData GetData(short tag)
{
ITaggedData taggedData = null;
if (this.Find((int)tag))
{
taggedData = ZipExtraData.Create(tag, this._data, this._readValueStart, this._readValueLength);
}
return taggedData;
}
// Token: 0x060003AD RID: 941 RVA: 0x00012CBC File Offset: 0x00011CBC
private static ITaggedData Create(short tag, byte[] data, int offset, int count)
{
ITaggedData taggedData;
if (tag != 10)
{
if (tag != 21589)
{
taggedData = new RawTaggedData(tag);
}
else
{
taggedData = new ExtendedUnixData();
}
}
else
{
taggedData = new NTTaggedData();
}
taggedData.SetData(data, offset, count);
return taggedData;
}
// Token: 0x170000DC RID: 220
// (get) Token: 0x060003AE RID: 942 RVA: 0x00012CFD File Offset: 0x00011CFD
public int ValueLength
{
get
{
return this._readValueLength;
}
}
// Token: 0x170000DD RID: 221
// (get) Token: 0x060003AF RID: 943 RVA: 0x00012D05 File Offset: 0x00011D05
public int CurrentReadIndex
{
get
{
return this._index;
}
}
// Token: 0x170000DE RID: 222
// (get) Token: 0x060003B0 RID: 944 RVA: 0x00012D0D File Offset: 0x00011D0D
public int UnreadCount
{
get
{
if (this._readValueStart > this._data.Length || this._readValueStart < 4)
{
throw new ZipException("Find must be called before calling a Read method");
}
return this._readValueStart + this._readValueLength - this._index;
}
}
// Token: 0x060003B1 RID: 945 RVA: 0x00012D48 File Offset: 0x00011D48
public bool Find(int headerID)
{
this._readValueStart = this._data.Length;
this._readValueLength = 0;
this._index = 0;
int num = this._readValueStart;
int num2 = headerID - 1;
while (num2 != headerID && this._index < this._data.Length - 3)
{
num2 = this.ReadShortInternal();
num = this.ReadShortInternal();
if (num2 != headerID)
{
this._index += num;
}
}
bool flag = num2 == headerID && this._index + num <= this._data.Length;
if (flag)
{
this._readValueStart = this._index;
this._readValueLength = num;
}
return flag;
}
// Token: 0x060003B2 RID: 946 RVA: 0x00012DE8 File Offset: 0x00011DE8
public void AddEntry(ITaggedData taggedData)
{
if (taggedData == null)
{
throw new ArgumentNullException("taggedData");
}
this.AddEntry((int)taggedData.TagID, taggedData.GetData());
}
// Token: 0x060003B3 RID: 947 RVA: 0x00012E0C File Offset: 0x00011E0C
public void AddEntry(int headerID, byte[] fieldData)
{
if (headerID > 65535 || headerID < 0)
{
throw new ArgumentOutOfRangeException("headerID");
}
int num = ((fieldData == null) ? 0 : fieldData.Length);
if (num > 65535)
{
throw new ArgumentOutOfRangeException("fieldData", "exceeds maximum length");
}
int num2 = this._data.Length + num + 4;
if (this.Find(headerID))
{
num2 -= this.ValueLength + 4;
}
if (num2 > 65535)
{
throw new ZipException("Data exceeds maximum length");
}
this.Delete(headerID);
byte[] array = new byte[num2];
this._data.CopyTo(array, 0);
int num3 = this._data.Length;
this._data = array;
this.SetShort(ref num3, headerID);
this.SetShort(ref num3, num);
if (fieldData != null)
{
fieldData.CopyTo(array, num3);
}
}
// Token: 0x060003B4 RID: 948 RVA: 0x00012ECF File Offset: 0x00011ECF
public void StartNewEntry()
{
this._newEntry = new MemoryStream();
}
// Token: 0x060003B5 RID: 949 RVA: 0x00012EDC File Offset: 0x00011EDC
public void AddNewEntry(int headerID)
{
byte[] array = this._newEntry.ToArray();
this._newEntry = null;
this.AddEntry(headerID, array);
}
// Token: 0x060003B6 RID: 950 RVA: 0x00012F04 File Offset: 0x00011F04
public void AddData(byte data)
{
this._newEntry.WriteByte(data);
}
// Token: 0x060003B7 RID: 951 RVA: 0x00012F12 File Offset: 0x00011F12
public void AddData(byte[] data)
{
if (data == null)
{
throw new ArgumentNullException("data");
}
this._newEntry.Write(data, 0, data.Length);
}
// Token: 0x060003B8 RID: 952 RVA: 0x00012F32 File Offset: 0x00011F32
public void AddLeShort(int toAdd)
{
this._newEntry.WriteByte((byte)toAdd);
this._newEntry.WriteByte((byte)(toAdd >> 8));
}
// Token: 0x060003B9 RID: 953 RVA: 0x00012F50 File Offset: 0x00011F50
public void AddLeInt(int toAdd)
{
this.AddLeShort((int)((short)toAdd));
this.AddLeShort((int)((short)(toAdd >> 16)));
}
// Token: 0x060003BA RID: 954 RVA: 0x00012F65 File Offset: 0x00011F65
public void AddLeLong(long toAdd)
{
this.AddLeInt((int)(toAdd & (long)((ulong)(-1))));
this.AddLeInt((int)(toAdd >> 32));
}
// Token: 0x060003BB RID: 955 RVA: 0x00012F80 File Offset: 0x00011F80
public bool Delete(int headerID)
{
bool flag = false;
if (this.Find(headerID))
{
flag = true;
int num = this._readValueStart - 4;
byte[] array = new byte[this._data.Length - (this.ValueLength + 4)];
Array.Copy(this._data, 0, array, 0, num);
int num2 = num + this.ValueLength + 4;
Array.Copy(this._data, num2, array, num, this._data.Length - num2);
this._data = array;
}
return flag;
}
// Token: 0x060003BC RID: 956 RVA: 0x00012FF4 File Offset: 0x00011FF4
public long ReadLong()
{
this.ReadCheck(8);
return ((long)this.ReadInt() & (long)((ulong)(-1))) | ((long)this.ReadInt() << 32);
}
// Token: 0x060003BD RID: 957 RVA: 0x00013014 File Offset: 0x00012014
public int ReadInt()
{
this.ReadCheck(4);
int num = (int)this._data[this._index] + ((int)this._data[this._index + 1] << 8) + ((int)this._data[this._index + 2] << 16) + ((int)this._data[this._index + 3] << 24);
this._index += 4;
return num;
}
// Token: 0x060003BE RID: 958 RVA: 0x00013080 File Offset: 0x00012080
public int ReadShort()
{
this.ReadCheck(2);
int num = (int)this._data[this._index] + ((int)this._data[this._index + 1] << 8);
this._index += 2;
return num;
}
// Token: 0x060003BF RID: 959 RVA: 0x000130C4 File Offset: 0x000120C4
public int ReadByte()
{
int num = -1;
if (this._index < this._data.Length && this._readValueStart + this._readValueLength > this._index)
{
num = (int)this._data[this._index];
this._index++;
}
return num;
}
// Token: 0x060003C0 RID: 960 RVA: 0x00013115 File Offset: 0x00012115
public void Skip(int amount)
{
this.ReadCheck(amount);
this._index += amount;
}
// Token: 0x060003C1 RID: 961 RVA: 0x0001312C File Offset: 0x0001212C
private void ReadCheck(int length)
{
if (this._readValueStart > this._data.Length || this._readValueStart < 4)
{
throw new ZipException("Find must be called before calling a Read method");
}
if (this._index > this._readValueStart + this._readValueLength - length)
{
throw new ZipException("End of extra data");
}
if (this._index + length < 4)
{
throw new ZipException("Cannot read before start of tag");
}
}
// Token: 0x060003C2 RID: 962 RVA: 0x00013198 File Offset: 0x00012198
private int ReadShortInternal()
{
if (this._index > this._data.Length - 2)
{
throw new ZipException("End of extra data");
}
int num = (int)this._data[this._index] + ((int)this._data[this._index + 1] << 8);
this._index += 2;
return num;
}
// Token: 0x060003C3 RID: 963 RVA: 0x000131F1 File Offset: 0x000121F1
private void SetShort(ref int index, int source)
{
this._data[index] = (byte)source;
this._data[index + 1] = (byte)(source >> 8);
index += 2;
}
// Token: 0x060003C4 RID: 964 RVA: 0x00013213 File Offset: 0x00012213
public void Dispose()
{
if (this._newEntry != null)
{
this._newEntry.Close();
}
}
// Token: 0x040002BB RID: 699
private int _index;
// Token: 0x040002BC RID: 700
private int _readValueStart;
// Token: 0x040002BD RID: 701
private int _readValueLength;
// Token: 0x040002BE RID: 702
private MemoryStream _newEntry;
// Token: 0x040002BF RID: 703
private byte[] _data;
}
}