Exemplo n.º 1
0
        /**
         * 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);
            }
        }
Exemplo n.º 2
0
 /**
  * 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);
     }
 }
Exemplo n.º 3
0
        /// <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);
        }
Exemplo n.º 4
0
        /**
         * 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)
        );
        }