The current API of zipalign is very minimal and a bit too specific (the RandomAccessFile arg). Honestly the original API looks good as-is, and is perfect for its main goal but its a bit hard to maintain the long lines of code. I'm imagining a more object-oriented approach in the next 2.0.0 so it could be called a "real" library :smile:
I'm thinking of an API that will look something like this:
ZipAnalyzer analyzer = new ZipAnalyzer("./file.zip");
// or
ZipAnalyzer analyzer = new ZipAnalyzer(new FileInputStream(...));
// or maybe even
byte[] something = new byte[...];
ZipAnalyzer analyzer = new ZipAnalyzer(something);
analyzer.setAlignSoFiles(true, 4096);
analyzer.specialCase(new AlignCase() { ... }, 16); // perhaps the user wanted to align something specific? X)
Alignments alignments = analyzer.analyze();
alignments.align("./file.zip", "output.zip");
alignments.align(new FileInputStream(...), "output.zip");
alignments.alignInPlace("./file.zip");
byte[] result = alignments.alignToBytes("./file.zip");
The current API of zipalign is very minimal and a bit too specific (the
RandomAccessFile
arg). Honestly the original API looks good as-is, and is perfect for its main goal but its a bit hard to maintain the long lines of code. I'm imagining a more object-oriented approach in the next 2.0.0 so it could be called a "real" library :smile:I'm thinking of an API that will look something like this:
What do you think?