mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-09-22 23:15:20 +00:00
unrar5: unpack wip
This commit is contained in:
@@ -24,7 +24,11 @@ namespace SharpCompress.Archives.Rar
|
||||
internal RarArchive(FileInfo fileInfo, ReaderOptions options)
|
||||
: base(ArchiveType.Rar, fileInfo, options)
|
||||
{
|
||||
#if !RarV2017_USELEGACY
|
||||
Unpack = new SharpCompress.Compressors.Rar.UnpackV2017.Unpack();
|
||||
#else
|
||||
Unpack = new SharpCompress.Compressors.Rar.UnpackV1.Unpack();
|
||||
#endif
|
||||
}
|
||||
|
||||
protected override IEnumerable<RarVolume> LoadVolumes(FileInfo file)
|
||||
@@ -41,7 +45,11 @@ namespace SharpCompress.Archives.Rar
|
||||
internal RarArchive(IEnumerable<Stream> streams, ReaderOptions options)
|
||||
: base(ArchiveType.Rar, streams, options)
|
||||
{
|
||||
#if !RarV2017_USELEGACY
|
||||
Unpack = new SharpCompress.Compressors.Rar.UnpackV2017.Unpack();
|
||||
#else
|
||||
Unpack = new SharpCompress.Compressors.Rar.UnpackV1.Unpack();
|
||||
#endif
|
||||
}
|
||||
|
||||
protected override IEnumerable<RarArchiveEntry> LoadEntries(IEnumerable<RarVolume> volumes)
|
||||
|
||||
@@ -112,6 +112,21 @@ set {
|
||||
}
|
||||
}
|
||||
|
||||
// sharpcompress: added the following code
|
||||
public void GetBuffer(size_t Item, out byte[] buf, out uint offset) {
|
||||
if (Item<MemSize[0]) {
|
||||
//return Mem[0][Item];
|
||||
buf = Mem[0]; offset = Item; return;
|
||||
}
|
||||
for (uint I=1;I<MemSize.Length;I++) {
|
||||
if (Item<MemSize[I]) {
|
||||
//return Mem[I][Item-MemSize[I-1]];
|
||||
buf = Mem[I]; offset = Item-MemSize[I-1]; return;
|
||||
}
|
||||
}
|
||||
//return Mem[0][0]; // Must never happen;
|
||||
buf = Mem[0]; offset = 0; return; // Must never happen;
|
||||
}
|
||||
|
||||
public void CopyString(uint Length,uint Distance,ref size_t UnpPtr,size_t MaxWinMask)
|
||||
{
|
||||
|
||||
@@ -24,7 +24,6 @@ namespace SharpCompress.Compressors.Rar.UnpackV2017
|
||||
private Stream writeStream;
|
||||
|
||||
private void _UnpackCtor() {
|
||||
BlockTables.Init();
|
||||
for (int i = 0; i < this.AudV.Length; i++) {
|
||||
this.AudV[i] = new AudioVariables();
|
||||
}
|
||||
|
||||
@@ -404,7 +404,8 @@ void UnpWriteBuf()
|
||||
EmptyCount++;
|
||||
}
|
||||
if (EmptyCount>0)
|
||||
Filters.Alloc(Filters.Count-EmptyCount);
|
||||
//Filters.Alloc(Filters.Count-EmptyCount);
|
||||
throw new NotImplementedException();
|
||||
|
||||
if (!NotAllFiltersProcessed) // Only if all filters are processed.
|
||||
{
|
||||
@@ -428,6 +429,8 @@ void UnpWriteBuf()
|
||||
|
||||
byte[] ApplyFilter(byte[] Data,uint DataSize,UnpackFilter Flt)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
#if false
|
||||
byte[] SrcData=Data;
|
||||
switch(Flt.Type)
|
||||
{
|
||||
@@ -509,6 +512,7 @@ byte[] ApplyFilter(byte[] Data,uint DataSize,UnpackFilter Flt)
|
||||
|
||||
}
|
||||
return null;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -525,7 +529,9 @@ void UnpWriteArea(size_t StartPtr,size_t EndPtr)
|
||||
while (SizeToWrite>0)
|
||||
{
|
||||
size_t BlockSize=FragWindow.GetBlockSize(StartPtr,SizeToWrite);
|
||||
UnpWriteData(&FragWindow[StartPtr],BlockSize);
|
||||
//UnpWriteData(&FragWindow[StartPtr],BlockSize);
|
||||
FragWindow.GetBuffer(StartPtr, out var __buffer, out var __offset);
|
||||
UnpWriteData(__buffer, __offset, BlockSize);
|
||||
SizeToWrite-=BlockSize;
|
||||
StartPtr=(StartPtr+BlockSize) & MaxWinMask;
|
||||
}
|
||||
|
||||
@@ -205,6 +205,8 @@ void UnpInitData(bool Solid)
|
||||
// memset(Window,0,MaxWinSize);
|
||||
//memset(&BlockTables,0,sizeof(BlockTables));
|
||||
BlockTables = new UnpackBlockTables();
|
||||
// sharpcompress: no default ctor for struct
|
||||
BlockTables.Init();
|
||||
UnpPtr=WrPtr=0;
|
||||
WriteBorder=Math.Min(MaxWinSize,UNPACK_MAX_WRITE)&MaxWinMask;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,11 @@ namespace SharpCompress.Readers.Rar
|
||||
internal RarReader(ReaderOptions options)
|
||||
: base(options, ArchiveType.Rar)
|
||||
{
|
||||
#if !RarV2017_USELEGACY
|
||||
this.pack = new SharpCompress.Compressors.Rar.UnpackV2017.Unpack();
|
||||
#else
|
||||
this.pack = new SharpCompress.Compressors.Rar.UnpackV1.Unpack();
|
||||
#endif
|
||||
}
|
||||
|
||||
internal abstract void ValidateArchive(RarVolume archive);
|
||||
|
||||
Reference in New Issue
Block a user