mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-02-03 21:23:38 +00:00
Bookshare zip files don't uncompress #222
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @ghost on GitHub (Jul 24, 2017).
Bookshare is a service that distribute books in .zip files (DAISY format). Those files aren't recognized as the proper zip archive by the current version of Sharpcompress. Interesting enough, this related project reads them properly on Windows: https://github.com/p3root/sharpcompress
I can send you a sample for testing on email, or you can get it by registering to: http://developer.bookshare.org, then find test credentials and available books for test here (after you sign in): http://developer.bookshare.org/docs/read/Bookshare_Test_Data_for_Partners, and then log in to Bookshare and download the book (this link will lead you to one that is available for download for tests: https://www.bookshare.org/search?keyword=Bookshare+Demo%3A+The+Rocket+Boys+of+NIH).
@ghost commented on GitHub (Jul 25, 2017):
Just to note that when using System.IO.Compression I also get the exception: System.IO.InvalidDataException: End of Central Directory record could not be found.
However the file opens without the problem in the explorer and as said above that somewhat obsolete version of this project opens it without the problem. Any ideas why this is happening and if I can do something Adam?
@adamhathcock commented on GitHub (Jul 25, 2017):
Zip format has become a bit haphazard over the years. The official implementation requires a valid central directory but it’s possible to extract sometimes without it.
It depends on what those files have in it. I haven’t looked yet.
@ghost commented on GitHub (Jul 25, 2017):
After some checking my initial report wasn't fully right, the problem is caused by different platforms behaving differently. This works properly with Windows, but on Xamarin.iOS it doesn't.
@adamhathcock commented on GitHub (Jul 25, 2017):
You’ll have to show me code that works on windows but not xamarin along with exceptions or whatever.
@ghost commented on GitHub (Jul 25, 2017):
It crashes on the second line on Xamarin with exception System.InvalidOperationException: Cannot determine compressed stream type. Supported Archive Formats: Zip, GZip, Tar, Rar, 7Zip, LZip
at SharpCompress.Archives.ArchiveFactory.Open (System.IO.Stream stream, SharpCompress.Readers.ReaderOptions readerOptions) [0x000de] in <714c60c556704f94af7b2094897f5d2b>:0
@adamhathcock commented on GitHub (Jul 26, 2017):
That's weird. I would expect some error reading from the file system.
If you know the file is a zip, try using a ZipArchive from ZipArchiveFactory directly to avoid the detection issue just as a test.
@ghost commented on GitHub (Jul 26, 2017):
Also of note, it works on Xamarin.Mac properly. I guess that there is something wrong in the Xamarin.iOS framework, not sure if you can fix this (maybe just workaround the problem), I have also submitted the problem regarding System.IO.Compression to Xamarin.
I'll check later what happens if I do like you have advised.
@adamhathcock commented on GitHub (Jul 26, 2017):
System.IO.Compression isn’t used in the code you showed me?
The funny part is is that Mono uses SharpCompress for their zip implementation last I checked. Not sure what issues you’re having.
@ghost commented on GitHub (Jul 26, 2017):
No I just pointed out that there is also issue there. Actually I have tried yesterday several more zip packages and every single of them had issues on iOS with this file. As said I believe it is a deeper problem in the framework just there might be some workaround.
@ghost commented on GitHub (Jul 27, 2017):
Adam,
using (var archive = SharpCompress.Archives.Zip.ZipArchive.Open(fileStream))did the trick. Thanks! I leave this open because it is a bug and you should try to fix it, but regarding my issue, it is resolved with this workaround.
@adamhathcock commented on GitHub (Jul 27, 2017):
It's weird the autodetection doesn't work on iOS. Maybe something to do with improper read counting from a Stream like https://github.com/adamhathcock/sharpcompress/issues/275
@Wufus commented on GitHub (Sep 6, 2021):
After creating ZipArchive with sharpcompress, i cant open this archive with sharpcompress.