public static long calculateMaximumSize(final HeaderBlock header) { return calculateMaximumSize(header.getBigBlockSize(), header.getBATCount()); }
/** * Returns the BATBlock that handles the specified offset, * and the relative index within it */ protected BATBlockAndIndex getBATBlockAndIndex(final int offset) { return BATBlock.getSBATBlockAndIndex( offset, _header, _sbat_blocks ); }
/** * Set the start block for this instance * * @param index index into the array of BigBlock instances making * up the the filesystem */ public void setStartBlock(final int index) { _header_block.setPropertyStart(index); }
/** * Works out what block follows the specified one. */ protected int getNextBlock(final int offset) { BATBlockAndIndex bai = getBATBlockAndIndex(offset); return bai.getBlock().getValueAt( bai.getIndex() ); }
/** * Constructor, intended for writing */ public POIFSFileSystem() { this(true); // Reserve block 0 for the start of the Properties Table // Create a single empty BAT, at pop that at offset 1 _header.setBATCount(1); _header.setBATArray(new int[] { 1 }); BATBlock bb = BATBlock.createEmptyBATBlock(bigBlockSize, false); bb.setOurBlockIndex(1); _bat_blocks.add(bb); setNextBlock(0, POIFSConstants.END_OF_CHAIN); setNextBlock(1, POIFSConstants.FAT_SECTOR_BLOCK); _property_table.setStartBlock(0); }
/** * Changes the record of what block follows the specified one. */ protected void setNextBlock(final int offset, final int nextBlock) { BATBlockAndIndex bai = getBATBlockAndIndex(offset); bai.getBlock().setValueAt( bai.getIndex(), nextBlock ); }
private void readBAT(int batAt, ChainLoopDetector loopDetector) throws IOException { loopDetector.claim(batAt); ByteBuffer fatData = getBlockAt(batAt); BATBlock bat = BATBlock.createBATBlock(bigBlockSize, fatData); bat.setOurBlockIndex(batAt); _bat_blocks.add(bat); } private BATBlock createBAT(int offset, boolean isBAT) throws IOException {
/** * Returns the BATBlock that handles the specified offset, * and the relative index within it. * The List of BATBlocks must be in sequential order */ public static BATBlockAndIndex getBATBlockAndIndex(final int offset, final HeaderBlock header, final List<BATBlock> bats) { POIFSBigBlockSize bigBlockSize = header.getBigBlockSize(); int entriesPerBlock = bigBlockSize.getBATEntriesPerBlock(); int whichBAT = offset / entriesPerBlock; int index = offset % entriesPerBlock; return new BATBlockAndIndex( index, bats.get(whichBAT) ); }
/** * Get the start block for the property table * * @return start block index */ public int getStartBlock() { return _header_block.getPropertyStart(); }
/** * Returns the BATBlock that handles the specified offset, * and the relative index within it, for the mini stream. * The List of BATBlocks must be in sequential order */ public static BATBlockAndIndex getSBATBlockAndIndex(final int offset, final HeaderBlock header, final List<BATBlock> sbats) { return getBATBlockAndIndex(offset, header, sbats); }
/** * Write the block's data to an OutputStream * * @param stream the OutputStream to which the stored data should * be written * * @exception IOException on problems writing to the specified * stream */ public void writeBlocks(final OutputStream stream) throws IOException { // Save it out stream.write( serialize() ); }
public void setValueAt(int relativeOffset, int value) { int oldValue = _values[relativeOffset]; _values[relativeOffset] = value; // Do we need to re-compute the free? if(value == POIFSConstants.UNUSED_BLOCK) { _has_free_sectors = true; return; } if(oldValue == POIFSConstants.UNUSED_BLOCK) { recomputeFree(); } }
public PropertyTable(HeaderBlock headerBlock) { _header_block = headerBlock; _bigBigBlockSize = headerBlock.getBigBlockSize(); addProperty(new RootProperty()); }
/** * Creates a single BATBlock, with all the values set to empty. */ public static BATBlock createEmptyBATBlock(final POIFSBigBlockSize bigBlockSize, boolean isXBAT) { BATBlock block = new BATBlock(bigBlockSize); if(isXBAT) { final int _entries_per_xbat_block = bigBlockSize.getXBATEntriesPerBlock(); block._values[ _entries_per_xbat_block ] = POIFSConstants.END_OF_CHAIN; } return block; }
private static byte[] readFirst512(InputStream stream) throws IOException { // Grab the first 512 bytes // (For 4096 sized blocks, the remaining 3584 bytes are zero) byte[] data = new byte[512]; int bsCount = IOUtils.readFully(stream, data); if(bsCount != 512) { throw alertShortRead(bsCount); } return data; }
/** * Works out what block follows the specified one. */ @Override protected int getNextBlock(final int offset) { BATBlockAndIndex bai = getBATBlockAndIndex(offset); return bai.getBlock().getValueAt( bai.getIndex() ); }
/** * Changes the record of what block follows the specified one. */ @Override protected void setNextBlock(final int offset, final int nextBlock) { BATBlockAndIndex bai = getBATBlockAndIndex(offset); bai.getBlock().setValueAt( bai.getIndex(), nextBlock ); }
/** * reading constructor (used when we've read in a file and we want * to extract the property table from it). Populates the * properties thoroughly * * @param headerBlock the header block of the file * @param filesystem the filesystem to read from * * @exception IOException if anything goes wrong (which should be * a result of the input being NFG) */ public PropertyTable(final HeaderBlock headerBlock, final POIFSFileSystem filesystem) throws IOException { this( headerBlock, new POIFSStream(filesystem, headerBlock.getPropertyStart()) ); }
/** * Returns the BATBlock that handles the specified offset, * and the relative index within it */ @Override protected BATBlockAndIndex getBATBlockAndIndex(final int offset) { return BATBlock.getBATBlockAndIndex( offset, _header, _bat_blocks ); }
public void writeData(final ByteBuffer block) { // Save it out block.put( serialize() ); }