/** * Has our in-memory objects write their state * to their backing blocks */ private void syncWithDataSource() { // Mini Stream + SBATs first, as mini-stream details have // to be stored in the Root Property _mini_store.SyncWithDataSource(); // Properties NPOIFSStream propStream = new NPOIFSStream(this, _header.PropertyStart); _property_table.PreWrite(); _property_table.Write(propStream); // _header.setPropertyStart has been updated on write ... // HeaderBlock HeaderBlockWriter hbw = new HeaderBlockWriter(_header); hbw.WriteBlock(GetBlockAt(-1)); // BATs foreach (BATBlock bat in _bat_blocks) { ByteBuffer block = GetBlockAt(bat.OurBlockIndex); //byte[] block = GetBlockAt(bat.OurBlockIndex); BlockAllocationTableWriter.WriteBlock(bat, block); } // XBats foreach (BATBlock bat in _xbat_blocks) { ByteBuffer block = GetBlockAt(bat.OurBlockIndex); BlockAllocationTableWriter.WriteBlock(bat, block); } }
/** * Writes the SBATs to their backing blocks */ public void SyncWithDataSource() { foreach (BATBlock sbat in _sbat_blocks) { ByteBuffer block = _filesystem.GetBlockAt(sbat.OurBlockIndex); BlockAllocationTableWriter.WriteBlock(sbat, block); } }
/// <summary> /// Writes the SBATs to their backing blocks, and updates /// the mini-stream size in the properties. Stream size is /// based on full blocks used, not the data within the streams /// </summary> public void SyncWithDataSource() { int blocksUsed = 0; foreach (BATBlock sbat in _sbat_blocks) { ByteBuffer block = _filesystem.GetBlockAt(sbat.OurBlockIndex); BlockAllocationTableWriter.WriteBlock(sbat, block); if (!sbat.HasFreeSectors) { blocksUsed += _filesystem.GetBigBlockSizeDetails().GetBATEntriesPerBlock(); } else { blocksUsed += sbat.GetUsedSectors(false); } } // Set the size on the root in terms of the number of SBAT blocks // RootProperty.setSize does the sbat -> bytes conversion for us _filesystem.PropertyTable.Root.Size = (blocksUsed); }
/** * Has our in-memory objects write their state * to their backing blocks */ private void syncWithDataSource() { // HeaderBlock HeaderBlockWriter hbw = new HeaderBlockWriter(_header); hbw.WriteBlock(GetBlockAt(-1)); // BATs foreach (BATBlock bat in _bat_blocks) { ByteBuffer block = GetBlockAt(bat.OurBlockIndex); //byte[] block = GetBlockAt(bat.OurBlockIndex); BlockAllocationTableWriter.WriteBlock(bat, block); } // SBATs _mini_store.SyncWithDataSource(); // Properties _property_table.Write(new NPOIFSStream(this, _header.PropertyStart) ); }