mirror of
https://github.com/revanced/Apktool.git
synced 2025-06-12 21:27:36 +02:00
Use Guava's LittleEndianDataInputStream.
This replaces the custom LittleEndianDataInputStream with guava's implementation. To do this, I had to fix ExtDataInput to better handle the case where skipBytes doesn't skip all the bytes (the tests failed without this, and succeed with it). This appears to be the main difference between the two implementations. Guava's implementation is preferred because it is already a dependency and because its license is clearer (the previous implementation had a vague "public domain" comment in the thread which may not be legally sufficient). Fixes #1166
This commit is contained in:
@ -76,6 +76,22 @@ public class ExtDataInput extends DataInputDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The general contract of DataInput doesn't guarantee all the bytes requested will be skipped
|
||||
* and failure can occur for many reasons. We override this to try harder to skip all the bytes
|
||||
* requested (this is similar to DataInputStream's wrapper).
|
||||
*/
|
||||
public final int skipBytes(int n) throws IOException {
|
||||
int total = 0;
|
||||
int cur = 0;
|
||||
|
||||
while ((total < n) && ((cur = (int) super.skipBytes(n - total)) > 0)) {
|
||||
total += cur;
|
||||
}
|
||||
|
||||
return total;
|
||||
}
|
||||
|
||||
public String readNullEndedString(int length, boolean fixed)
|
||||
throws IOException {
|
||||
StringBuilder string = new StringBuilder(16);
|
||||
|
Reference in New Issue
Block a user