예제 #1
0
        private NPOIFSFileSystem(bool newFS)
        {
            _header         = new HeaderBlock(bigBlockSize);
            _property_table = new NPropertyTable(_header);
            _mini_store     = new NPOIFSMiniStore(this, _property_table.Root, new List <BATBlock>(), _header);
            _xbat_blocks    = new List <BATBlock>();
            _bat_blocks     = new List <BATBlock>();
            _root           = null;

            if (newFS)
            {
                // Data needs to Initially hold just the header block,
                //  a single bat block, and an empty properties section
                _data = new ByteArrayBackedDataSource(new byte[bigBlockSize.GetBigBlockSize() * 3]);
            }
        }
예제 #2
0
        private NPOIFSFileSystem(bool newFS)
        {
            _header = new HeaderBlock(bigBlockSize);
            _property_table = new NPropertyTable(_header);
            _mini_store = new NPOIFSMiniStore(this, _property_table.Root, new List<BATBlock>(), _header);
            _xbat_blocks = new List<BATBlock>();
            _bat_blocks = new List<BATBlock>();
            _root = null;

            if (newFS)
            {
                // Data needs to Initially hold just the header block,
                //  a single bat block, and an empty properties section
                _data = new ByteArrayBackedDataSource(new byte[bigBlockSize.GetBigBlockSize() * 3]);
            }
        }
예제 #3
0
        /**
         * Read and process the PropertiesTable and the
         *  FAT / XFAT blocks, so that we're Ready to
         *  work with the file
         */
        private void ReadCoreContents()
        {
            // Grab the block size
            bigBlockSize = _header.BigBlockSize;

            // Each block should only ever be used by one of the
            //  FAT, XFAT or Property Table. Ensure it does
            ChainLoopDetector loopDetector = GetChainLoopDetector();

            // Read the FAT blocks
            foreach (int fatAt in _header.BATArray)
            {
                ReadBAT(fatAt, loopDetector);
            }
            // Work out how many FAT blocks remain in the XFATs
            int remainingFATs = _header.BATCount - _header.BATArray.Length;

            // Now read the XFAT blocks, and the FATs within them
            BATBlock xfat;
            int      nextAt = _header.XBATIndex;

            for (int i = 0; i < _header.XBATCount; i++)
            {
                loopDetector.Claim(nextAt);
                ByteBuffer fatData = GetBlockAt(nextAt);
                xfat = BATBlock.CreateBATBlock(bigBlockSize, fatData);
                xfat.OurBlockIndex = nextAt;
                nextAt             = xfat.GetValueAt(bigBlockSize.GetXBATEntriesPerBlock());
                _xbat_blocks.Add(xfat);
                // Process all the (used) FATs from this XFAT
                int xbatFATs = Math.Min(remainingFATs, bigBlockSize.GetXBATEntriesPerBlock());
                for (int j = 0; j < xbatFATs; j++)
                {
                    int fatAt = xfat.GetValueAt(j);
                    if (fatAt == POIFSConstants.UNUSED_BLOCK || fatAt == POIFSConstants.END_OF_CHAIN)
                    {
                        break;
                    }
                    ReadBAT(fatAt, loopDetector);
                }
                remainingFATs -= xbatFATs;
            }

            // We're now able to load steams
            // Use this to read in the properties
            _property_table = new NPropertyTable(_header, this);

            // Finally read the Small Stream FAT (SBAT) blocks
            BATBlock        sfat;
            List <BATBlock> sbats = new List <BATBlock>();

            _mini_store = new NPOIFSMiniStore(this, _property_table.Root, sbats, _header);
            nextAt      = _header.SBATStart;
            for (int i = 0; i < _header.SBATCount; i++)
            {
                loopDetector.Claim(nextAt);
                ByteBuffer fatData = GetBlockAt(nextAt);
                sfat = BATBlock.CreateBATBlock(bigBlockSize, fatData);
                sfat.OurBlockIndex = nextAt;
                sbats.Add(sfat);
                nextAt = GetNextBlock(nextAt);
            }
        }
예제 #4
0
        /**
         * Read and process the PropertiesTable and the
         *  FAT / XFAT blocks, so that we're Ready to
         *  work with the file
         */
        private void ReadCoreContents()
        {
            // Grab the block size
            bigBlockSize = _header.BigBlockSize;

            // Each block should only ever be used by one of the
            //  FAT, XFAT or Property Table. Ensure it does
            ChainLoopDetector loopDetector = GetChainLoopDetector();

            // Read the FAT blocks
            foreach (int fatAt in _header.BATArray)
            {
                ReadBAT(fatAt, loopDetector);
            }
            // Work out how many FAT blocks remain in the XFATs
            int remainingFATs = _header.BATCount - _header.BATArray.Length;
       
            // Now read the XFAT blocks, and the FATs within them
            BATBlock xfat;
            int nextAt = _header.XBATIndex;
            for (int i = 0; i < _header.XBATCount; i++)
            {
                loopDetector.Claim(nextAt);
                ByteBuffer fatData = GetBlockAt(nextAt);
                xfat = BATBlock.CreateBATBlock(bigBlockSize, fatData);
                xfat.OurBlockIndex = nextAt;
                nextAt = xfat.GetValueAt(bigBlockSize.GetXBATEntriesPerBlock());
                _xbat_blocks.Add(xfat);
                // Process all the (used) FATs from this XFAT
                int xbatFATs = Math.Min(remainingFATs, bigBlockSize.GetXBATEntriesPerBlock());
                for(int j=0; j<xbatFATs; j++) 
                {
                    int fatAt = xfat.GetValueAt(j);
                    if (fatAt == POIFSConstants.UNUSED_BLOCK || fatAt == POIFSConstants.END_OF_CHAIN) break;
                    ReadBAT(fatAt, loopDetector);
                }
                remainingFATs -= xbatFATs;
            }

            // We're now able to load steams
            // Use this to read in the properties
            _property_table = new NPropertyTable(_header, this);

            // Finally read the Small Stream FAT (SBAT) blocks
            BATBlock sfat;
            List<BATBlock> sbats = new List<BATBlock>();
            _mini_store = new NPOIFSMiniStore(this, _property_table.Root, sbats, _header);
            nextAt = _header.SBATStart;
            for (int i = 0; i < _header.SBATCount; i++)
            {
                loopDetector.Claim(nextAt);
                ByteBuffer fatData = GetBlockAt(nextAt);
                sfat = BATBlock.CreateBATBlock(bigBlockSize, fatData);
                sfat.OurBlockIndex = nextAt;
                sbats.Add(sfat);
                nextAt = GetNextBlock(nextAt);
            }
        }