sharpcompress icon indicating copy to clipboard operation
sharpcompress copied to clipboard

Added Seeking feature for BufferedSubStream and ReadOnlySubStream.

Open vovgou opened this issue 3 years ago • 5 comments

Added the seeking feature for BufferedSubStream and ReadOnlySubStream. When the compression type of an entry is Store (uncompressed) in the Zip or APK file, a seekable stream will be obtained by entry.OpenEntryStream(). In game development on the Android platform, it avoids having to decompress files to disk due to a seekable stream being required.

vovgou avatar Mar 30 '21 04:03 vovgou

Hi,@adamhathcock My submission failed to pass the test case, but this does not seem to be my problem. I tested some cases in which errors were reported on my computer, and it worked.

vovgou avatar Mar 30 '21 08:03 vovgou

Not sure how these pass locally for you as some of the code looks at the CanSeek flags to do different things. That's why the test is failing because ReadOnlySubStream was never seekable and now RewindableStream blows up because it's trying to seek.

I believe entry.OpenEntryStream() should always return a non-seekable stream as it's directly linked to decompression and inheritly shouldn't be seekable. If you want to buffer it for your app, do so, but I don't think this is something that should be part of SharpCompress.

adamhathcock avatar Mar 30 '21 09:03 adamhathcock

Not sure how these pass locally for you as some of the code looks at the CanSeek flags to do different things. That's why the test is failing because ReadOnlySubStream was never seekable and now RewindableStream blows up because it's trying to seek.

I believe entry.OpenEntryStream() should always return a non-seekable stream as it's directly linked to decompression and inheritly shouldn't be seekable. If you want to buffer it for your app, do so, but I don't think this is something that should be part of SharpCompress.

Usually, entry.OpenEntryStream() gets a compressed stream that cannot be seeked, but in the zip file, if the Entry is a "Store" type, it is not compressed. In the game developed with Unity3d (Android APK), The files in the StreamingAssets directory are game resource files. They are all "Store" types and are not compressed. It is necessary to support a seekable stream. And when using SharpZipLib, it works.So could you support this feature? Thanks you.

vovgou avatar Mar 31 '21 03:03 vovgou

I guess if there's no decompression stream, then it could be a seekable stream when using OpenEntryStream. Just need to complete the thread and check for uncompressed streams in zips

adamhathcock avatar Mar 31 '21 14:03 adamhathcock

I guess if there's no decompression stream, then it could be a seekable stream when using OpenEntryStream. Just need to complete the thread and check for uncompressed streams in zips

Yes, it is seekable, but it is wrapped by ReadOnlySubStream in sharpcompress, so i added the seeking feature to ReadOnlySubStream

vovgou avatar Apr 01 '21 02:04 vovgou