adamhathcock / sharpcompress

SharpCompress is a fully managed C# library to deal with many compression types and formats.
MIT License
2.27k stars 480 forks source link

Add support for seeking with non-compressed RARs #57

Open ljani opened 9 years ago

ljani commented 9 years ago

It'd be nice if RARs with 0x30 (store) packing method could be seeked. That should work since that doesn't require any unpacking and can be read directly from disk. Some book keeping is needed though.

adamhathcock commented 9 years ago

If you open with RarArchive, can you not seek?

Or do you mean you want the Stream from RarArchive be seekable?

ljani commented 9 years ago

I mean that it would be nice if the Stream from RarArchiveEntry.OpenEntryStream() would be seekable. For non-compressed rars, that shouldn't be too hard since you can read the stream directly from the file.

I thought about writing a wrapper, but you had hid the implementation details in internal classes, so I couldn't access the data in eg FileParts ;)

adamhathcock commented 9 years ago

It should be easy enough to be an if statement here: https://github.com/adamhathcock/sharpcompress/blob/master/SharpCompress/Archive/Rar/RarArchiveEntry.cs#L74

I can't remember where the store flag is.

ljani commented 9 years ago

All the interesting information is hidden in FileHeader (eg. PackingMethod, CompressedSize and DataStartPosition) and is not accessible to outside. I could to reflection, but it gets a bit ugly, because everything is internal. Thus I decided against creating my own dirty wrapper and decided to ask if someone had interest to implement this properly in the library itself.

adamhathcock commented 9 years ago

It seems like you could :)

Just fork and adjust the code. It doesn't seem like it would be a big job.