VirtualFileSystem.VFSCore.GetSuperBlock C# (CSharp) Method

GetSuperBlock() public method

获取此文件系统的超级块操作对象
public GetSuperBlock ( ) : SuperBlock
return SuperBlock
        public SuperBlock GetSuperBlock()
        {
            return superBlock;
        }

Usage Example

Example #1
0
        /// <summary>
        /// 查找指定偏移所在的块,若块不存在则返回无效块
        /// </summary>
        /// <param name="position"></param>
        /// <returns></returns>
        public Block GetBlockAtPosition(UInt32 position, Boolean allocate = false)
        {
            UInt32 blockSize     = vfs.GetSuperBlock().data.blockSize;
            UInt32 IndexPerBlock = blockSize / sizeof(UInt32);

            if (position < BoundLv0)
            {
                // 直接索引
                UInt32 lv0_index = position / blockSize;
                return(new Block(vfs, data.dataBlockId[lv0_index]));
            }
            else if (position < BoundLv1)
            {
                // 一级间接索引
                position -= BoundLv0;

                UInt32 lv0_index = 12;
                UInt32 lv1_index = position / blockSize;

                Block lv0_block = new Block(vfs, data.dataBlockId[lv0_index]);
                if (lv0_block.index == UInt32.MaxValue)
                {
                    return(lv0_block);
                }

                return(new Block(vfs, lv0_block.Read <UInt32>(lv1_index * sizeof(UInt32))));
            }
            else
            {
                // 二级间接索引
                position -= BoundLv1;

                UInt32 lv0_index = 13;
                UInt32 lv1_index = (position / blockSize) / IndexPerBlock;
                UInt32 lv2_index = (position / blockSize) % IndexPerBlock;

                Block lv0_block = new Block(vfs, data.dataBlockId[lv0_index]);
                if (lv0_block.index == UInt32.MaxValue)
                {
                    return(lv0_block);
                }

                Block lv1_block = new Block(vfs, lv0_block.Read <UInt32>(lv1_index * sizeof(UInt32)));
                if (lv1_block.index == UInt32.MaxValue)
                {
                    return(lv1_block);
                }

                return(new Block(vfs, lv1_block.Read <UInt32>(lv2_index * sizeof(UInt32))));
            }
        }
All Usage Examples Of VirtualFileSystem.VFSCore::GetSuperBlock