コード例 #1
0
ファイル: BATBlock.cs プロジェクト: missxiaohuang/Weekly
        /**
         * Calculates the maximum size of a file which is addressable given the
         *  number of FAT (BAT) sectors specified. (We don't care if those BAT
         *  blocks come from the 109 in the header, or from header + XBATS, it
         *  won't affect the calculation)
         *  
         * The actual file size will be between [size of fatCount-1 blocks] and
         *   [size of fatCount blocks].
         *  For 512 byte block sizes, this means we may over-estimate by up to 65kb.
         *  For 4096 byte block sizes, this means we may over-estimate by up to 4mb
         */
        public static int CalculateMaximumSize(POIFSBigBlockSize bigBlockSize,
              int numBATs)
        {
            int size = 1; // Header isn't FAT addressed

            // The header has up to 109 BATs, and extra ones are referenced
            //  from XBATs
            // However, all BATs can contain 128/1024 blocks
            size += (numBATs * bigBlockSize.GetBATEntriesPerBlock());

            // So far we've been in sector counts, turn into bytes
            return size * bigBlockSize.GetBigBlockSize();
        }
コード例 #2
0
ファイル: BATBlock.cs プロジェクト: missxiaohuang/Weekly
 protected BATBlock(POIFSBigBlockSize bigBlockSize)
     : base(bigBlockSize)
 {
     int _entries_per_block = bigBlockSize.GetBATEntriesPerBlock();
     _values = new int[_entries_per_block];
     _has_free_sectors = true;
  
     for (int i = 0; i < _values.Length; i++)
         _values[i] = POIFSConstants.UNUSED_BLOCK;
 }
コード例 #3
0
ファイル: BATBlock.cs プロジェクト: missxiaohuang/Weekly
 public static int CalculateStorageRequirements(POIFSBigBlockSize bigBlockSize, int entryCount)
 {
     int _entries_per_block = bigBlockSize.GetBATEntriesPerBlock();
     return (entryCount + _entries_per_block - 1) / _entries_per_block;
 }