private BATBlock createBAT(int offset, boolean isBAT) throws IOException { // Create a new BATBlock BATBlock newBAT = BATBlock.createEmptyBATBlock(bigBlockSize, !isBAT); newBAT.setOurBlockIndex(offset); // Ensure there's a spot in the file for it ByteBuffer buffer = ByteBuffer.allocate(bigBlockSize.getBigBlockSize()); int writeTo = (1 + offset) * bigBlockSize.getBigBlockSize(); // Header isn't in BATs _data.write(buffer, writeTo); // All done return newBAT; }
/** Constructor, intended for writing */ public NPOIFSFileSystem() { this(true); // Mark us as having a single empty BAT at offset 0 _header.setBATCount(1); _header.setBATArray(new int[] {0}); _bat_blocks.add(BATBlock.createEmptyBATBlock(bigBlockSize, false)); setNextBlock(0, POIFSConstants.FAT_SECTOR_BLOCK); // Now associate the properties with the empty block _property_table.setStartBlock(1); setNextBlock(1, POIFSConstants.END_OF_CHAIN); }