7-Zip-JBinding-4Android icon indicating copy to clipboard operation
7-Zip-JBinding-4Android copied to clipboard

Compatibility of the library with SAF?

Open fiasko131 opened this issue 4 years ago • 4 comments

Is there a way to use this library with an Outputstream obtained by SAF in android.

For example to compress on an external memory card I cannot use:

raf = new RandomAccessFile(zipPath, "rw");
outArchiveZip = SevenZip.openOutArchiveZip();
outArchiveZip.setLevel(level);
outArchiveZip.createArchive(new RandomAccessFileOutStream(raf),//
items.length, new CallBackZip());

RandomAccessFile is not compatible with SAF.

Of course I can compress on the internal storage and then copy , but obviously that's not ideal.

Thank you.

fiasko131 avatar Feb 28 '21 10:02 fiasko131

I'm afraid sevenzipjbinding does not include an OutStream implementation that uses OutputStream.

You will need to create such a class yourself by implementing the IOutStream interface in sevenzipjbinding.

For reference you can look at the following two existing OutStream implementations provided with sevenzipjbinding:

omicronapps avatar Mar 01 '21 03:03 omicronapps

Okay, I'll see if I can implement it later and come back later to share.

For the moment, in the case of a creation, I keep the Zip4j library which allows to work with an outputstream.

fiasko131 avatar Mar 01 '21 07:03 fiasko131

@fiasko131 I've implemented a perfectly functional Helper/wrapper for this lib that works with SAF (API21+)

https://github.com/avluis/Hentoid/blob/dcb208eabbfc134b20d68c996cce89989179655e/app/src/main/java/me/devsaki/hentoid/util/ArchiveHelper.java

It's been tested by many users with different devices 👍

However it only reads archives. Creating archives is not a use case for my app, but maybe you can get inspiration from what I did...

RobbWatershed avatar May 12 '21 08:05 RobbWatershed

@fiasko131 Any luck with SAF in extraction & compression?

asthagarg2428 avatar Mar 23 '22 08:03 asthagarg2428