mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-09-22 06:54:40 +00:00
unrar5: unpack wip
This commit is contained in:
@@ -30,6 +30,15 @@ namespace SharpCompress.Compressors.Rar.UnpackV2017
|
||||
}
|
||||
}
|
||||
|
||||
private int UnpIO_UnpRead(byte[] buf, int offset, int count) {
|
||||
// NOTE: caller has logic to check for -1 for error we throw instead.
|
||||
return this.readStream.Read(buf, offset, count);
|
||||
}
|
||||
|
||||
private void UnpIO_UnpWrite(byte[] buf, size_t offset, uint count) {
|
||||
this.writeStream.Write(buf, checked((int)offset), checked((int)count));
|
||||
}
|
||||
|
||||
public void DoUnpack(FileHeader fileHeader, Stream readStream, Stream writeStream)
|
||||
{
|
||||
// as of 12/2017 .NET limits array indexing to using a signed integer
|
||||
@@ -95,6 +104,7 @@ namespace SharpCompress.Compressors.Rar.UnpackV2017
|
||||
public static byte[] EnsureCapacity(byte[] array, int length) {
|
||||
return array.Length < length ? new byte[length] : array;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -258,7 +258,7 @@ bool UnpReadBuf()
|
||||
DataSize=ReadTop;
|
||||
int ReadCode=0;
|
||||
if (BitInput.MAX_SIZE!=DataSize)
|
||||
ReadCode=UnpIO->UnpRead(Inp.InBuf+DataSize,BitInput.MAX_SIZE-DataSize);
|
||||
ReadCode=UnpIO_UnpRead(Inp.InBuf,DataSize,BitInput.MAX_SIZE-DataSize);
|
||||
if (ReadCode>0) // Can be also -1.
|
||||
ReadTop+=ReadCode;
|
||||
ReadBorder=ReadTop-30;
|
||||
@@ -359,7 +359,7 @@ void UnpWriteBuf()
|
||||
Filters[I].Type=FILTER_NONE;
|
||||
|
||||
if (OutMem!=null)
|
||||
UnpIO->UnpWrite(OutMem,BlockLength);
|
||||
UnpIO_UnpWrite(OutMem,0,BlockLength);
|
||||
|
||||
UnpSomeRead=true;
|
||||
WrittenFileSize+=BlockLength;
|
||||
@@ -549,7 +549,7 @@ void UnpWriteData(byte[] Data, size_t offset, size_t Size)
|
||||
int64 LeftToWrite=DestUnpSize-WrittenFileSize;
|
||||
if ((int64)WriteSize>LeftToWrite)
|
||||
WriteSize=(size_t)LeftToWrite;
|
||||
UnpIO->UnpWrite(Data, offset, WriteSize);
|
||||
UnpIO_UnpWrite(Data, offset, WriteSize);
|
||||
WrittenFileSize+=Size;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user