Ejemplo n.º 1
0
  public BATBlockAndIndex(int index, BATBlock block)
  {
    this.index = index;
    this.block = block;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Create an array of XBATBlocks from an array of int block
        /// allocation table entries
        /// </summary>
        /// <param name="entries">the array of int entries</param>
        /// <param name="startBlock">the start block of the array of XBAT blocks</param>
        /// <returns>the newly created array of BATBlocks</returns>
        public static BATBlock[] CreateXBATBlocks(POIFSBigBlockSize bigBlockSize, int[] entries,
                                                   int startBlock)
        {
            int block_count =
                CalculateXBATStorageRequirements(entries.Length);
            BATBlock[] blocks = new BATBlock[block_count];
            int index = 0;
            int remaining = entries.Length;

            if (block_count != 0)
            {
                for (int j = 0; j < entries.Length; j += _entries_per_xbat_block)
                {
                    blocks[index++] =
                        new BATBlock(bigBlockSize, entries, j,
                                     (remaining > _entries_per_xbat_block)
                                     ? j + _entries_per_xbat_block
                                     : entries.Length);
                    remaining -= _entries_per_xbat_block;
                }
                for (index = 0; index < blocks.Length - 1; index++)
                {
                    blocks[index].SetXBATChain(bigBlockSize, startBlock + index + 1);
                }
                blocks[index].SetXBATChain(bigBlockSize, POIFSConstants.END_OF_CHAIN);
            }
            return blocks;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Create an array of BATBlocks from an array of int block
        /// allocation table entries
        /// </summary>
        /// <param name="entries">the array of int entries</param>
        /// <returns>the newly created array of BATBlocks</returns>
        public static BATBlock[] CreateBATBlocks(POIFSBigBlockSize bigBlockSize, int[] entries)
        {
            int block_count = CalculateStorageRequirements(entries.Length);
            BATBlock[] blocks = new BATBlock[block_count];
            int index = 0;
            int remaining = entries.Length;

            for (int j = 0; j < entries.Length; j += _entries_per_block)
            {
                blocks[index++] = new BATBlock(bigBlockSize, entries, j,
                                                 (remaining > _entries_per_block)
                                                 ? j + _entries_per_block
                                                 : entries.Length);
                remaining -= _entries_per_block;
            }
            return blocks;
        }
Ejemplo n.º 4
0
 ///**
 // * Creates a single BATBlock, with all the values set to empty.
 // */
 public static BATBlock CreateEmptyBATBlock(POIFSBigBlockSize bigBlockSize, bool isXBAT)
 {
     BATBlock block = new BATBlock(bigBlockSize);
     if (isXBAT)
     {
         block.SetXBATChain(bigBlockSize, POIFSConstants.END_OF_CHAIN);
     }
     return block;
 }
Ejemplo n.º 5
0
        //public static BATBlock CreateBATBlock(POIFSBigBlockSize bigBlockSize, byte[] data)
        public static BATBlock CreateBATBlock(POIFSBigBlockSize bigBlockSize, ByteBuffer data)
        {
            // Create an empty block
            BATBlock block = new BATBlock(bigBlockSize);

            // Fill it
            byte[] buffer = new byte[LittleEndianConsts.INT_SIZE];
            //int index = 0;
            for (int i = 0; i < block._values.Length; i++)
            {
                //data.Read(buffer, 0, buffer.Length);
                //for (int j = 0; j < buffer.Length; j++, index++)
                 //   buffer[j] = data[index];
                data.Read(buffer);
                block._values[i] = LittleEndian.GetInt(buffer);
            }
            block.RecomputeFree();

            // All done
            return block;
        }
Ejemplo n.º 6
0
        /**
         * Create a single BATBlock from the byte buffer, which must hold at least
         *  one big block of data to be read.
         */
        public static BATBlock CreateBATBlock(POIFSBigBlockSize bigBlockSize, BinaryReader data)
        {
            // Create an empty block
            BATBlock block = new BATBlock(bigBlockSize);

            // Fill it
            byte[] buffer = new byte[LittleEndianConsts.INT_SIZE];
            for (int i = 0; i < block._values.Length; i++)
            {
                data.Read(buffer,0,buffer.Length);
                block._values[i] = LittleEndian.GetInt(buffer);
            }
            block.RecomputeFree();

            // All done
            return block;
        }