private String readString() throws IOException { final int length = in.readInt(); if (length > 0) { return in.readString(length); } else { return ""; } }
public AttachmentEntry(RandomAccessInputStream s) throws IOException { schemaType = s.readString(2); s.skipBytes(10); // reserved filePosition = s.readLong(); filePart = s.readInt(); contentGUID = s.readString(16); contentFileType = s.readString(8); name = s.readString(80); }
/** Cut off header bytes from a resource fork file. */ private void stripHeader() throws IOException { in.seek(0); while (!in.readString(4).equals("moov")) { in.seek(in.getFilePointer() - 2); } in.seek(in.getFilePointer() - 8); }
private void seekToNextMarker() throws IOException { while (in.getFilePointer() < in.length()) { String check = in.readString(3); if (check.equals(MARKER)) { in.skipBytes(1); return; } in.seek(in.getFilePointer() - 2); } }
in = new RandomAccessInputStream(id); CoreMetadata m = core.get(0); int n = in.readShort(); in.skipBytes(33); // reserved for future use String history = in.readString(64); addGlobalMetaList("Image history", history.trim());
@Override public boolean isThisType(RandomAccessInputStream stream) throws IOException { final int blockLen = 348; if (!FormatTools.validStream(stream, blockLen, false)) return false; stream.seek(344); String magic = stream.readString(3); return magic.equals("ni1") || magic.equals("n+1"); }
private int getFileVersion(RandomAccessInputStream stream) throws IOException { stream.seek(0); stream.order(LITTLE_ENDIAN); try { final String magicString = stream.readString(FILE_MAGIC_STRING.length()); final short magicNumber = stream.readShort(); final int version = stream.readInt(); if (magicString.equals(FILE_MAGIC_STRING) && magicNumber == MAGIC_NUMBER) { return version; } } catch(IOException exception) { } return - 1; }
@Override public boolean isThisType(RandomAccessInputStream stream) throws IOException { final int blockLen = 12; if (!FormatTools.validStream(stream, blockLen, false)) return false; String type = stream.readString(4); stream.skipBytes(4); String format = stream.readString(4); return type.equals(AVI_MAGIC_STRING) && format.equals("AVI "); }
private void seekToNextMarker() throws IOException { while (in.getFilePointer() < in.length()) { String check = in.readString(3); if (check.equals(MARKER)) { in.skipBytes(1); return; } in.seek(in.getFilePointer() - 2); } }
public AttachmentEntry(RandomAccessInputStream s) throws IOException { schemaType = s.readString(2); s.skipBytes(10); // reserved filePosition = s.readLong(); filePart = s.readInt(); contentGUID = s.readString(16); contentFileType = s.readString(8); name = s.readString(80); }
@Override public boolean isThisType(RandomAccessInputStream stream) throws IOException { final int blockLen = 348; if (!FormatTools.validStream(stream, blockLen, false)) return false; stream.seek(344); String magic = stream.readString(3); return magic.equals("ni1") || magic.equals("n+1"); }
private int getFileVersion(RandomAccessInputStream stream) throws IOException { stream.seek(0); stream.order(LITTLE_ENDIAN); try { final String magicString = stream.readString(FILE_MAGIC_STRING.length()); final short magicNumber = stream.readShort(); final int version = stream.readInt(); if (magicString.equals(FILE_MAGIC_STRING) && magicNumber == MAGIC_NUMBER) { return version; } } catch(IOException exception) { } return - 1; }
/** Cut off header bytes from a resource fork file. */ private void stripHeader() throws IOException { in.seek(0); while (!in.readString(4).equals("moov")) { in.seek(in.getFilePointer() - 2); } in.seek(in.getFilePointer() - 8); }
@Override public String loadRevision() throws IOException { int length = loadStream.readInt(); return loadStream.readString(length); }
@Override public boolean isThisType(RandomAccessInputStream stream) throws IOException { final int blockLen = 12; if (!FormatTools.validStream(stream, blockLen, false)) return false; String type = stream.readString(4); stream.skipBytes(4); String format = stream.readString(4); return type.equals(AVI_MAGIC_STRING) && format.equals("AVI "); }
private byte[] readPixelBlock(RandomAccessInputStream s, long offset) throws IOException { s.order(true); s.seek(offset); int checkLength = s.readInt(); int check = s.readInt(); if (check != 3) { s.seek(offset); return null; } s.skipBytes(8); // currently unknown int uidLength = s.readInt(); String uid = s.readString(uidLength); LOGGER.debug("reading pixel block with uid = {}", uid); if (checkLength != uidLength + 12) { s.seek(offset); return null; } int pixelBytes = s.readInt(); s.skipBytes(4); // currently unknown byte[] pixels = new byte[pixelBytes]; s.readFully(pixels); return pixels; }
/** Read the next tag. */ private void readTagHeader() throws IOException { tag = in.readShort(); subTag = in.readShort(); nextTag = (version == 2 ? in.readInt() : in.readLong()); fmt = in.readString(4); in.skipBytes(version == 2 ? 4 : 8); }
@Override public boolean isThisType(RandomAccessInputStream stream) throws IOException { final int blockLen = 56; if (!FormatTools.validStream(stream, blockLen, LITTLE_ENDIAN)) { return false; } String c = stream.readString(blockLen); stream.seek(54); return stream.readShort() == PIC_FILE_ID || c.startsWith("[Input Sources]"); }
@Override public boolean isThisType(RandomAccessInputStream stream) throws IOException { // Extra sanity check; if it's a TIFF, return false immediately, to avoid // false negatives. if(new TiffParser(stream).isValidHeader()) { return false; } final int blockLen = 212; if (!FormatTools.validStream(stream, blockLen, true)) return false; stream.seek(96); int magic = stream.readShort() & 0xffff; boolean valid = magic == DV_MAGIC_BYTES_1 || magic == DV_MAGIC_BYTES_2; if (!valid) { return false; } stream.order(magic == (LITTLE_ENDIAN & 0xffff)); stream.seek(208); boolean isMap = stream.readString(4).trim().equals("MAP"); if (isMap) { return false; } stream.seek(0); int x = stream.readInt(); int y = stream.readInt(); int count = stream.readInt(); return x > 0 && y > 0 && count > 0 && ((long) x * (long) y * (long) count < stream.length()); }
@Override public boolean isThisType(RandomAccessInputStream stream) throws IOException { final int blockLen = 4096; if (!FormatTools.validStream(stream, blockLen, false)) return false; TiffParser parser = new TiffParser(stream); if (parser.isValidHeader()) { return parser.getIFDOffsets().length > 1; } stream.seek(4); if (stream.readShort() == 0x5374) { String check = stream.readString((int) (blockLen - stream.getFilePointer())); return check.indexOf("ID") > 0; } return false; }