public void close() throws IOException { // If we're overwriting, free any remaining blocks POIFSStream toFree = new POIFSStream(blockStore, nextBlock); toFree.free(loopDetector); // Mark the end of the stream, if we have any data if (prevBlock != POIFSConstants.END_OF_CHAIN) { blockStore.setNextBlock(prevBlock, POIFSConstants.END_OF_CHAIN); } } }
POIFSMiniStore(POIFSFileSystem filesystem, RootProperty root, List<BATBlock> sbats, HeaderBlock header) { this._filesystem = filesystem; this._sbat_blocks = sbats; this._header = header; this._root = root; this._mini_stream = new POIFSStream(filesystem, root.getStartBlock()); }
public static void dump(POIFSFileSystem fs, int startBlock, String name, File parent) throws IOException { File file = new File(parent, name); try (FileOutputStream out = new FileOutputStream(file)) { POIFSStream stream = new POIFSStream(fs, startBlock); byte[] b = IOUtils.safelyAllocate(fs.getBigBlockSize(), MAX_RECORD_LENGTH); for (ByteBuffer bb : stream) { int len = bb.remaining(); bb.get(b); out.write(b, 0, len); } } } }
/** * 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()) ); }
@Override public void write(byte[] b, int off, int len) throws IOException { if (_closed) { throw new IOException("cannot perform requested operation on a closed stream"); } if (_limit > -1 && (size() + len) > _limit) { throw new IOException("tried to write too much data"); } if (_buffer != null) { _buffer.write(b, off, len); checkBufferSize(); } else { if (_stream == null) { _stream = new POIFSStream(_document.getFileSystem()); _stream_output = _stream.getOutputStream(); } _stream_output.write(b, off, len); _document_size += len; } }
/** * Constructor for an existing Document */ public POIFSDocument(DocumentProperty property, POIFSFileSystem filesystem) { this._property = property; this._filesystem = filesystem; if(property.getSize() < POIFSConstants.BIG_BLOCK_MINIMUM_DOCUMENT_SIZE) { _stream = new POIFSStream(_filesystem.getMiniStore(), property.getStartBlock()); _block_size = _filesystem.getMiniStore().getBlockStoreBlockSize(); } else { _stream = new POIFSStream(_filesystem, property.getStartBlock()); _block_size = _filesystem.getBlockStoreBlockSize(); } }
_stream = new POIFSStream(_filesystem.getMiniStore()); _block_size = _filesystem.getMiniStore().getBlockStoreBlockSize(); } else { _stream = new POIFSStream(_filesystem); _block_size = _filesystem.getBlockStoreBlockSize();
public POIFSDocument(String name, final int size, POIFSFileSystem filesystem, POIFSWriterListener writer) throws IOException { this._filesystem = filesystem; if (size < POIFSConstants.BIG_BLOCK_MINIMUM_DOCUMENT_SIZE) { _stream = new POIFSStream(filesystem.getMiniStore()); _block_size = _filesystem.getMiniStore().getBlockStoreBlockSize(); } else { _stream = new POIFSStream(filesystem); _block_size = _filesystem.getBlockStoreBlockSize(); } this._property = new DocumentProperty(name, size); _property.setStartBlock(_stream.getStartBlock()); _property.setDocument(this); try (DocumentOutputStream os = new DocumentOutputStream(this, size)) { POIFSDocumentPath path = new POIFSDocumentPath(name.split("\\\\")); String docName = path.getComponent(path.length() - 1); POIFSWriterEvent event = new POIFSWriterEvent(os, path, docName, size); writer.processPOIFSWriterEvent(event); } }
POIFSStream propStream = new POIFSStream(this, _header.getPropertyStart()); _property_table.preWrite(); _property_table.write(propStream);
_mini_stream = new POIFSStream(_filesystem, newBigBlock); } else {
public void close() throws IOException { // If we're overwriting, free any remaining blocks POIFSStream toFree = new POIFSStream(blockStore, nextBlock); toFree.free(loopDetector); // Mark the end of the stream, if we have any data if (prevBlock != POIFSConstants.END_OF_CHAIN) { blockStore.setNextBlock(prevBlock, POIFSConstants.END_OF_CHAIN); } } }
POIFSMiniStore(POIFSFileSystem filesystem, RootProperty root, List<BATBlock> sbats, HeaderBlock header) { this._filesystem = filesystem; this._sbat_blocks = sbats; this._header = header; this._root = root; this._mini_stream = new POIFSStream(filesystem, root.getStartBlock()); }
public static void dump(POIFSFileSystem fs, int startBlock, String name, File parent) throws IOException { File file = new File(parent, name); try (FileOutputStream out = new FileOutputStream(file)) { POIFSStream stream = new POIFSStream(fs, startBlock); byte[] b = IOUtils.safelyAllocate(fs.getBigBlockSize(), MAX_RECORD_LENGTH); for (ByteBuffer bb : stream) { int len = bb.remaining(); bb.get(b); out.write(b, 0, len); } } } }
/** * 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()) ); }
@Override public void write(byte[] b, int off, int len) throws IOException { if (_closed) { throw new IOException("cannot perform requested operation on a closed stream"); } if (_limit > -1 && (size() + len) > _limit) { throw new IOException("tried to write too much data"); } if (_buffer != null) { _buffer.write(b, off, len); checkBufferSize(); } else { if (_stream == null) { _stream = new POIFSStream(_document.getFileSystem()); _stream_output = _stream.getOutputStream(); } _stream_output.write(b, off, len); _document_size += len; } }
/** * Constructor for an existing Document */ public POIFSDocument(DocumentProperty property, POIFSFileSystem filesystem) { this._property = property; this._filesystem = filesystem; if(property.getSize() < POIFSConstants.BIG_BLOCK_MINIMUM_DOCUMENT_SIZE) { _stream = new POIFSStream(_filesystem.getMiniStore(), property.getStartBlock()); _block_size = _filesystem.getMiniStore().getBlockStoreBlockSize(); } else { _stream = new POIFSStream(_filesystem, property.getStartBlock()); _block_size = _filesystem.getBlockStoreBlockSize(); } }
_stream = new POIFSStream(_filesystem.getMiniStore()); _block_size = _filesystem.getMiniStore().getBlockStoreBlockSize(); } else { _stream = new POIFSStream(_filesystem); _block_size = _filesystem.getBlockStoreBlockSize();
public POIFSDocument(String name, final int size, POIFSFileSystem filesystem, POIFSWriterListener writer) throws IOException { this._filesystem = filesystem; if (size < POIFSConstants.BIG_BLOCK_MINIMUM_DOCUMENT_SIZE) { _stream = new POIFSStream(filesystem.getMiniStore()); _block_size = _filesystem.getMiniStore().getBlockStoreBlockSize(); } else { _stream = new POIFSStream(filesystem); _block_size = _filesystem.getBlockStoreBlockSize(); } this._property = new DocumentProperty(name, size); _property.setStartBlock(_stream.getStartBlock()); _property.setDocument(this); try (DocumentOutputStream os = new DocumentOutputStream(this, size)) { POIFSDocumentPath path = new POIFSDocumentPath(name.split("\\\\")); String docName = path.getComponent(path.length() - 1); POIFSWriterEvent event = new POIFSWriterEvent(os, path, docName, size); writer.processPOIFSWriterEvent(event); } }
POIFSStream propStream = new POIFSStream(this, _header.getPropertyStart()); _property_table.preWrite(); _property_table.write(propStream);
_mini_stream = new POIFSStream(_filesystem, newBigBlock); } else {