Java Code Examples for com.igormaznitsa.jbbp.io.JBBPBitInputStream#readLong()
The following examples show how to use
com.igormaznitsa.jbbp.io.JBBPBitInputStream#readLong() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SCLPlugin.java From zxpoly with GNU General Public License v3.0 | 5 votes |
@Override public ReadResult readFrom(final File file, final int index) throws IOException { final List<SCLCatalogItem> list = new ArrayList<>(); final JBBPBitInputStream in = new JBBPBitInputStream(new FileInputStream(file)); try { final long id = in.readLong(JBBPByteOrder.BIG_ENDIAN); if (id == 0x53494E434C414952L) { // it's scl final int fileNumber = in.readByte(); for (int i = 0; i < fileNumber; i++) { final SCLCatalogItem item = CATALOG_PARSER.parse(in).mapTo(new SCLCatalogItem()); list.add(item); } final SCLCatalogItem itemToRead = list.get(index); for (int i = 0; i < index; i++) { final int len = list.get(i).sectors * 256; if (len != in.skip(len)) { throw new IllegalStateException("Can't skip bytes:" + list.get(i).length); } } final long offset = in.getCounter(); return new ReadResult(new ZXPolyData( new Info(itemToRead.name, itemToRead.type, itemToRead.start, itemToRead.length, (int) offset), this, in.readByteArray(itemToRead.sectors * 256)), null); } else { throw new IllegalArgumentException("It's not a SCl file: " + file); } } finally { JBBPUtils.closeQuietly(in); } }
Example 2
Source File: ZXPolyData.java From zxpoly with GNU General Public License v3.0 | 4 votes |
public ZXPolyData(final InputStream in, final List<AbstractFilePlugin> plugins) throws IOException { @Bin final class Parsed { int pluginId; byte[] info; byte[] array; byte[] mask; byte[] zxpoly0; byte[] zxpoly1; byte[] zxpoly2; byte[] zxpoly3; } final JBBPBitInputStream inStream = new JBBPBitInputStream(in); if (inStream.readLong(JBBPByteOrder.BIG_ENDIAN) != 0xABBAFAFABABE0123L) { throw new IOException("It is not a valid data block"); } final Parsed parsed = PARSER.parse(inStream).mapTo(new Parsed()); this.info = new Info(new ByteArrayInputStream(parsed.info)); this.basedata = parsed.array; this.mask = parsed.mask; this.zxpoly = new byte[4][]; this.zxpoly[0] = parsed.zxpoly0; this.zxpoly[1] = parsed.zxpoly1; this.zxpoly[2] = parsed.zxpoly2; this.zxpoly[3] = parsed.zxpoly3; AbstractFilePlugin plugin = null; for (final AbstractFilePlugin p : plugins) { if (parsed.pluginId == uid2int(p.getPluginUID())) { plugin = p; break; } } if (plugin == null) { throw new IOException("Can't find a plugin for UID [" + parsed.pluginId + ']'); } this.basePlugin = plugin; }
Example 3
Source File: VarCustomImpl.java From java-binary-block-parser with Apache License 2.0 | 4 votes |
@Override public JBBPAbstractField readVarField(Object sourceStruct, JBBPBitInputStream inStream, JBBPByteOrder byteOrder, JBBPNamedFieldInfo nullableNamedFieldInfo, int extraValue) throws IOException { return new JBBPFieldLong(nullableNamedFieldInfo, inStream.readLong(byteOrder)); }
Example 4
Source File: VarCustomImpl.java From java-binary-block-parser with Apache License 2.0 | 4 votes |
@Override public JBBPAbstractField readVarField(Object sourceStruct, JBBPBitInputStream inStream, JBBPByteOrder byteOrder, JBBPNamedFieldInfo nullableNamedFieldInfo, int extraValue) throws IOException { return new JBBPFieldLong(nullableNamedFieldInfo, inStream.readLong(byteOrder)); }