use of org.jf.dexlib2.dexbacked.DexBackedDexFile.NotADexFile in project smali by JesusFreke.
the class DexUtil method verifyDexHeader.
/**
* Reads in the dex header from the given input stream and verifies that it is valid and a supported version
*
* The inputStream must support mark(), and will be reset to initial position upon exiting the method
*
* @param inputStream An input stream that is positioned at a dex header
* @throws NotADexFile If the file is not a dex file
* @throws InvalidFile If the header appears to be a dex file, but is not valid for some reason
* @throws UnsupportedFile If the dex header is valid, but uses unsupported functionality
*/
public static void verifyDexHeader(@Nonnull InputStream inputStream) throws IOException {
if (!inputStream.markSupported()) {
throw new IllegalArgumentException("InputStream must support mark");
}
inputStream.mark(44);
byte[] partialHeader = new byte[44];
try {
ByteStreams.readFully(inputStream, partialHeader);
} catch (EOFException ex) {
throw new NotADexFile("File is too short");
} finally {
inputStream.reset();
}
verifyDexHeader(partialHeader, 0);
}
Aggregations