scripts
This commit is contained in:
@@ -0,0 +1,461 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace ICSharpCode.SharpZipLib.Tar
|
||||
{
|
||||
// Token: 0x02000038 RID: 56
|
||||
public class TarInputStream : Stream
|
||||
{
|
||||
// Token: 0x06000214 RID: 532 RVA: 0x0000B8DF File Offset: 0x0000A8DF
|
||||
public TarInputStream(Stream inputStream)
|
||||
: this(inputStream, 20)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x06000215 RID: 533 RVA: 0x0000B8EA File Offset: 0x0000A8EA
|
||||
public TarInputStream(Stream inputStream, int blockFactor)
|
||||
{
|
||||
this.inputStream = inputStream;
|
||||
this.tarBuffer = TarBuffer.CreateInputTarBuffer(inputStream, blockFactor);
|
||||
}
|
||||
|
||||
// Token: 0x17000072 RID: 114
|
||||
// (get) Token: 0x06000216 RID: 534 RVA: 0x0000B906 File Offset: 0x0000A906
|
||||
// (set) Token: 0x06000217 RID: 535 RVA: 0x0000B913 File Offset: 0x0000A913
|
||||
public bool IsStreamOwner
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.tarBuffer.IsStreamOwner;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.tarBuffer.IsStreamOwner = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000073 RID: 115
|
||||
// (get) Token: 0x06000218 RID: 536 RVA: 0x0000B921 File Offset: 0x0000A921
|
||||
public override bool CanRead
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.inputStream.CanRead;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000074 RID: 116
|
||||
// (get) Token: 0x06000219 RID: 537 RVA: 0x0000B92E File Offset: 0x0000A92E
|
||||
public override bool CanSeek
|
||||
{
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000075 RID: 117
|
||||
// (get) Token: 0x0600021A RID: 538 RVA: 0x0000B931 File Offset: 0x0000A931
|
||||
public override bool CanWrite
|
||||
{
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000076 RID: 118
|
||||
// (get) Token: 0x0600021B RID: 539 RVA: 0x0000B934 File Offset: 0x0000A934
|
||||
public override long Length
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.inputStream.Length;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000077 RID: 119
|
||||
// (get) Token: 0x0600021C RID: 540 RVA: 0x0000B941 File Offset: 0x0000A941
|
||||
// (set) Token: 0x0600021D RID: 541 RVA: 0x0000B94E File Offset: 0x0000A94E
|
||||
public override long Position
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.inputStream.Position;
|
||||
}
|
||||
set
|
||||
{
|
||||
throw new NotSupportedException("TarInputStream Seek not supported");
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600021E RID: 542 RVA: 0x0000B95A File Offset: 0x0000A95A
|
||||
public override void Flush()
|
||||
{
|
||||
this.inputStream.Flush();
|
||||
}
|
||||
|
||||
// Token: 0x0600021F RID: 543 RVA: 0x0000B967 File Offset: 0x0000A967
|
||||
public override long Seek(long offset, SeekOrigin origin)
|
||||
{
|
||||
throw new NotSupportedException("TarInputStream Seek not supported");
|
||||
}
|
||||
|
||||
// Token: 0x06000220 RID: 544 RVA: 0x0000B973 File Offset: 0x0000A973
|
||||
public override void SetLength(long value)
|
||||
{
|
||||
throw new NotSupportedException("TarInputStream SetLength not supported");
|
||||
}
|
||||
|
||||
// Token: 0x06000221 RID: 545 RVA: 0x0000B97F File Offset: 0x0000A97F
|
||||
public override void Write(byte[] buffer, int offset, int count)
|
||||
{
|
||||
throw new NotSupportedException("TarInputStream Write not supported");
|
||||
}
|
||||
|
||||
// Token: 0x06000222 RID: 546 RVA: 0x0000B98B File Offset: 0x0000A98B
|
||||
public override void WriteByte(byte value)
|
||||
{
|
||||
throw new NotSupportedException("TarInputStream WriteByte not supported");
|
||||
}
|
||||
|
||||
// Token: 0x06000223 RID: 547 RVA: 0x0000B998 File Offset: 0x0000A998
|
||||
public override int ReadByte()
|
||||
{
|
||||
byte[] array = new byte[1];
|
||||
int num = this.Read(array, 0, 1);
|
||||
if (num <= 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
return (int)array[0];
|
||||
}
|
||||
|
||||
// Token: 0x06000224 RID: 548 RVA: 0x0000B9C0 File Offset: 0x0000A9C0
|
||||
public override int Read(byte[] buffer, int offset, int count)
|
||||
{
|
||||
if (buffer == null)
|
||||
{
|
||||
throw new ArgumentNullException("buffer");
|
||||
}
|
||||
int num = 0;
|
||||
if (this.entryOffset >= this.entrySize)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
long num2 = (long)count;
|
||||
if (num2 + this.entryOffset > this.entrySize)
|
||||
{
|
||||
num2 = this.entrySize - this.entryOffset;
|
||||
}
|
||||
if (this.readBuffer != null)
|
||||
{
|
||||
int num3 = ((num2 > (long)this.readBuffer.Length) ? this.readBuffer.Length : ((int)num2));
|
||||
Array.Copy(this.readBuffer, 0, buffer, offset, num3);
|
||||
if (num3 >= this.readBuffer.Length)
|
||||
{
|
||||
this.readBuffer = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
int num4 = this.readBuffer.Length - num3;
|
||||
byte[] array = new byte[num4];
|
||||
Array.Copy(this.readBuffer, num3, array, 0, num4);
|
||||
this.readBuffer = array;
|
||||
}
|
||||
num += num3;
|
||||
num2 -= (long)num3;
|
||||
offset += num3;
|
||||
}
|
||||
while (num2 > 0L)
|
||||
{
|
||||
byte[] array2 = this.tarBuffer.ReadBlock();
|
||||
if (array2 == null)
|
||||
{
|
||||
throw new TarException("unexpected EOF with " + num2 + " bytes unread");
|
||||
}
|
||||
int num5 = (int)num2;
|
||||
int num6 = array2.Length;
|
||||
if (num6 > num5)
|
||||
{
|
||||
Array.Copy(array2, 0, buffer, offset, num5);
|
||||
this.readBuffer = new byte[num6 - num5];
|
||||
Array.Copy(array2, num5, this.readBuffer, 0, num6 - num5);
|
||||
}
|
||||
else
|
||||
{
|
||||
num5 = num6;
|
||||
Array.Copy(array2, 0, buffer, offset, num6);
|
||||
}
|
||||
num += num5;
|
||||
num2 -= (long)num5;
|
||||
offset += num5;
|
||||
}
|
||||
this.entryOffset += (long)num;
|
||||
return num;
|
||||
}
|
||||
|
||||
// Token: 0x06000225 RID: 549 RVA: 0x0000BB3B File Offset: 0x0000AB3B
|
||||
public override void Close()
|
||||
{
|
||||
this.tarBuffer.Close();
|
||||
}
|
||||
|
||||
// Token: 0x06000226 RID: 550 RVA: 0x0000BB48 File Offset: 0x0000AB48
|
||||
public void SetEntryFactory(TarInputStream.IEntryFactory factory)
|
||||
{
|
||||
this.entryFactory = factory;
|
||||
}
|
||||
|
||||
// Token: 0x17000078 RID: 120
|
||||
// (get) Token: 0x06000227 RID: 551 RVA: 0x0000BB51 File Offset: 0x0000AB51
|
||||
public int RecordSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.tarBuffer.RecordSize;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000228 RID: 552 RVA: 0x0000BB5E File Offset: 0x0000AB5E
|
||||
[Obsolete("Use RecordSize property instead")]
|
||||
public int GetRecordSize()
|
||||
{
|
||||
return this.tarBuffer.RecordSize;
|
||||
}
|
||||
|
||||
// Token: 0x17000079 RID: 121
|
||||
// (get) Token: 0x06000229 RID: 553 RVA: 0x0000BB6B File Offset: 0x0000AB6B
|
||||
public long Available
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.entrySize - this.entryOffset;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600022A RID: 554 RVA: 0x0000BB7C File Offset: 0x0000AB7C
|
||||
public void Skip(long skipCount)
|
||||
{
|
||||
byte[] array = new byte[8192];
|
||||
int num3;
|
||||
for (long num = skipCount; num > 0L; num -= (long)num3)
|
||||
{
|
||||
int num2 = ((num > (long)array.Length) ? array.Length : ((int)num));
|
||||
num3 = this.Read(array, 0, num2);
|
||||
if (num3 == -1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x1700007A RID: 122
|
||||
// (get) Token: 0x0600022B RID: 555 RVA: 0x0000BBC0 File Offset: 0x0000ABC0
|
||||
public bool IsMarkSupported
|
||||
{
|
||||
get
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600022C RID: 556 RVA: 0x0000BBC3 File Offset: 0x0000ABC3
|
||||
public void Mark(int markLimit)
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x0600022D RID: 557 RVA: 0x0000BBC5 File Offset: 0x0000ABC5
|
||||
public void Reset()
|
||||
{
|
||||
}
|
||||
|
||||
// Token: 0x0600022E RID: 558 RVA: 0x0000BBC8 File Offset: 0x0000ABC8
|
||||
public TarEntry GetNextEntry()
|
||||
{
|
||||
if (this.hasHitEOF)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (this.currentEntry != null)
|
||||
{
|
||||
this.SkipToNextEntry();
|
||||
}
|
||||
byte[] array = this.tarBuffer.ReadBlock();
|
||||
if (array == null)
|
||||
{
|
||||
this.hasHitEOF = true;
|
||||
}
|
||||
else if (TarBuffer.IsEndOfArchiveBlock(array))
|
||||
{
|
||||
this.hasHitEOF = true;
|
||||
}
|
||||
if (this.hasHitEOF)
|
||||
{
|
||||
this.currentEntry = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
TarHeader tarHeader = new TarHeader();
|
||||
tarHeader.ParseBuffer(array);
|
||||
if (!tarHeader.IsChecksumValid)
|
||||
{
|
||||
throw new TarException("Header checksum is invalid");
|
||||
}
|
||||
this.entryOffset = 0L;
|
||||
this.entrySize = tarHeader.Size;
|
||||
StringBuilder stringBuilder = null;
|
||||
if (tarHeader.TypeFlag == 76)
|
||||
{
|
||||
byte[] array2 = new byte[512];
|
||||
long num = this.entrySize;
|
||||
stringBuilder = new StringBuilder();
|
||||
while (num > 0L)
|
||||
{
|
||||
int num2 = this.Read(array2, 0, (num > (long)array2.Length) ? array2.Length : ((int)num));
|
||||
if (num2 == -1)
|
||||
{
|
||||
throw new InvalidHeaderException("Failed to read long name entry");
|
||||
}
|
||||
stringBuilder.Append(TarHeader.ParseName(array2, 0, num2).ToString());
|
||||
num -= (long)num2;
|
||||
}
|
||||
this.SkipToNextEntry();
|
||||
array = this.tarBuffer.ReadBlock();
|
||||
}
|
||||
else if (tarHeader.TypeFlag == 103)
|
||||
{
|
||||
this.SkipToNextEntry();
|
||||
array = this.tarBuffer.ReadBlock();
|
||||
}
|
||||
else if (tarHeader.TypeFlag == 120)
|
||||
{
|
||||
this.SkipToNextEntry();
|
||||
array = this.tarBuffer.ReadBlock();
|
||||
}
|
||||
else if (tarHeader.TypeFlag == 86)
|
||||
{
|
||||
this.SkipToNextEntry();
|
||||
array = this.tarBuffer.ReadBlock();
|
||||
}
|
||||
else if (tarHeader.TypeFlag != 48 && tarHeader.TypeFlag != 0 && tarHeader.TypeFlag != 53)
|
||||
{
|
||||
this.SkipToNextEntry();
|
||||
array = this.tarBuffer.ReadBlock();
|
||||
}
|
||||
if (this.entryFactory == null)
|
||||
{
|
||||
this.currentEntry = new TarEntry(array);
|
||||
if (stringBuilder != null)
|
||||
{
|
||||
this.currentEntry.Name = stringBuilder.ToString();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.currentEntry = this.entryFactory.CreateEntry(array);
|
||||
}
|
||||
this.entryOffset = 0L;
|
||||
this.entrySize = this.currentEntry.Size;
|
||||
}
|
||||
catch (InvalidHeaderException ex)
|
||||
{
|
||||
this.entrySize = 0L;
|
||||
this.entryOffset = 0L;
|
||||
this.currentEntry = null;
|
||||
string text = string.Format("Bad header in record {0} block {1} {2}", this.tarBuffer.CurrentRecord, this.tarBuffer.CurrentBlock, ex.Message);
|
||||
throw new InvalidHeaderException(text);
|
||||
}
|
||||
}
|
||||
return this.currentEntry;
|
||||
}
|
||||
|
||||
// Token: 0x0600022F RID: 559 RVA: 0x0000BE3C File Offset: 0x0000AE3C
|
||||
public void CopyEntryContents(Stream outputStream)
|
||||
{
|
||||
byte[] array = new byte[32768];
|
||||
for (;;)
|
||||
{
|
||||
int num = this.Read(array, 0, array.Length);
|
||||
if (num <= 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
outputStream.Write(array, 0, num);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000230 RID: 560 RVA: 0x0000BE70 File Offset: 0x0000AE70
|
||||
private void SkipToNextEntry()
|
||||
{
|
||||
long num = this.entrySize - this.entryOffset;
|
||||
if (num > 0L)
|
||||
{
|
||||
this.Skip(num);
|
||||
}
|
||||
this.readBuffer = null;
|
||||
}
|
||||
|
||||
// Token: 0x04000138 RID: 312
|
||||
protected bool hasHitEOF;
|
||||
|
||||
// Token: 0x04000139 RID: 313
|
||||
protected long entrySize;
|
||||
|
||||
// Token: 0x0400013A RID: 314
|
||||
protected long entryOffset;
|
||||
|
||||
// Token: 0x0400013B RID: 315
|
||||
protected byte[] readBuffer;
|
||||
|
||||
// Token: 0x0400013C RID: 316
|
||||
protected TarBuffer tarBuffer;
|
||||
|
||||
// Token: 0x0400013D RID: 317
|
||||
private TarEntry currentEntry;
|
||||
|
||||
// Token: 0x0400013E RID: 318
|
||||
protected TarInputStream.IEntryFactory entryFactory;
|
||||
|
||||
// Token: 0x0400013F RID: 319
|
||||
private readonly Stream inputStream;
|
||||
|
||||
// Token: 0x02000039 RID: 57
|
||||
public interface IEntryFactory
|
||||
{
|
||||
// Token: 0x06000231 RID: 561
|
||||
TarEntry CreateEntry(string name);
|
||||
|
||||
// Token: 0x06000232 RID: 562
|
||||
TarEntry CreateEntryFromFile(string fileName);
|
||||
|
||||
// Token: 0x06000233 RID: 563
|
||||
TarEntry CreateEntry(byte[] headerBuffer);
|
||||
}
|
||||
|
||||
// Token: 0x0200003A RID: 58
|
||||
public class EntryFactoryAdapter : TarInputStream.IEntryFactory
|
||||
{
|
||||
// Token: 0x06000234 RID: 564 RVA: 0x0000BE9E File Offset: 0x0000AE9E
|
||||
public TarEntry CreateEntry(string name)
|
||||
{
|
||||
return TarEntry.CreateTarEntry(name);
|
||||
}
|
||||
|
||||
// Token: 0x06000235 RID: 565 RVA: 0x0000BEA6 File Offset: 0x0000AEA6
|
||||
public TarEntry CreateEntryFromFile(string fileName)
|
||||
{
|
||||
return TarEntry.CreateEntryFromFile(fileName);
|
||||
}
|
||||
|
||||
// Token: 0x06000236 RID: 566 RVA: 0x0000BEAE File Offset: 0x0000AEAE
|
||||
public TarEntry CreateEntry(byte[] headerBuffer)
|
||||
{
|
||||
return new TarEntry(headerBuffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user