Ejemplo n.º 1
0
        /// <summary>
        /// Set BAT block parameters. Assumes that all BAT blocks are
        /// contiguous. Will construct XBAT blocks if necessary and return
        /// the array of newly constructed XBAT blocks.
        /// </summary>
        /// <param name="blockCount">count of BAT blocks</param>
        /// <param name="startBlock">index of first BAT block</param>
        /// <returns>array of XBAT blocks; may be zero Length, will not be
        /// null</returns>
        public BATBlock[] SetBATBlocks(int blockCount, int startBlock)
        {
            BATBlock[] rvalue;

            POIFSBigBlockSize bigBlockSize = _header_block.BigBlockSize;

            _header_block.BATCount = blockCount;

            int limit = Math.Min(blockCount, _max_bats_in_header);

            int[] bat_blocks = new int[limit];
            for (int j = 0; j < limit; j++)
            {
                bat_blocks[j] = startBlock + j;
            }

            _header_block.BATArray = bat_blocks;

            if (blockCount > _max_bats_in_header)
            {
                int   excess_blocks      = blockCount - _max_bats_in_header;
                int[] excess_block_array = new int[excess_blocks];

                for (int j = 0; j < excess_blocks; j++)
                {
                    excess_block_array[j] = startBlock + j + _max_bats_in_header;
                }

                rvalue = BATBlock.CreateXBATBlocks(bigBlockSize, excess_block_array,
                                                   startBlock + blockCount);

                _header_block.XBATStart = startBlock + blockCount;
            }
            else
            {
                rvalue = BATBlock.CreateXBATBlocks(bigBlockSize, new int[0], 0);
                _header_block.XBATStart = POIFSConstants.END_OF_CHAIN;
            }

            _header_block.XBATCount = rvalue.Length;
            return(rvalue);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Set BAT block parameters. Assumes that all BAT blocks are
        /// contiguous. Will construct XBAT blocks if necessary and return
        /// the array of newly constructed XBAT blocks.
        /// </summary>
        /// <param name="blockCount">count of BAT blocks</param>
        /// <param name="startBlock">index of first BAT block</param>
        /// <returns>array of XBAT blocks; may be zero Length, will not be
        /// null</returns>
        public BATBlock [] SetBATBlocks(int blockCount,
                                        int startBlock)
        {
            BATBlock[] rvalue;

            _bat_count.Set(blockCount, _data);
            int limit  = Math.Min(blockCount, HeaderBlockConstants._max_bats_in_header);
            int offset = HeaderBlockConstants._bat_array_offset;

            for (int j = 0; j < limit; j++)
            {
                new IntegerField(offset, startBlock + j, _data);
                offset += LittleEndianConstants.INT_SIZE;
            }
            if (blockCount > HeaderBlockConstants._max_bats_in_header)
            {
                int   excess_blocks      = blockCount - HeaderBlockConstants._max_bats_in_header;
                int[] excess_block_array = new int[excess_blocks];

                for (int j = 0; j < excess_blocks; j++)
                {
                    excess_block_array[j] = startBlock + j
                                            + HeaderBlockConstants._max_bats_in_header;
                }
                rvalue = BATBlock.CreateXBATBlocks(excess_block_array,
                                                   startBlock + blockCount);
                _xbat_start.Set(startBlock + blockCount, _data);
            }
            else
            {
                rvalue = BATBlock.CreateXBATBlocks(new int[0], 0);
                _xbat_start.Set(POIFSConstants.END_OF_CHAIN, _data);
            }
            _xbat_count.Set(rvalue.Length, _data);
            return(rvalue);
        }