public int FindLastChild()
        {
            int rootBeginAddr = (int)FCBLevel.Peek();

            BitArray   rootFCBArray = GetBitArray(rootBeginAddr, 128);
            FCB        rootFCB      = new FCB(rootFCBArray, rootBeginAddr);
            BitArray   blockArray   = GetBitArray(rootFCB.indexBlock * blockSize, blockSize);
            IndexBlock indexBlock   = new IndexBlock(blockArray);

            indexBlock.num = rootFCB.indexBlock;
            int i;

            while (indexBlock.IsFull())
            {
                int nextBlock = indexBlock.indexes[31];
                for (i = 0; i < blockSize; ++i)
                {
                    blockArray[i] = disk[i + nextBlock * blockSize];
                }
                indexBlock.ChangeBlock(blockArray);
                indexBlock.num = nextBlock;
            }
            int childAddr = indexBlock.indexes[indexBlock.endIndex - 1] * blockSize + (rootFCB.endOffset - 32);

            return(childAddr);
        }
        public bool OpenFile(String s)
        {
            int        rootBeginAddr = (int)FCBLevel.Peek();
            BitArray   rootFCBArray = GetBitArray(rootBeginAddr, 128);
            FCB        rootFCB = new FCB(rootFCBArray, rootBeginAddr);
            BitArray   blockArray = GetBitArray(rootFCB.indexBlock * blockSize, blockSize);
            IndexBlock indexBlock = new IndexBlock(blockArray);
            int        i, j;

            while (indexBlock.IsFull())
            {
                for (i = 0; i < 31; ++i)
                {
                    int curBlock = indexBlock.indexes[i];
                    for (j = 0; j < 16; ++j)
                    {
                        int childAddr = GetInt(curBlock * blockSize + 32 * j, 21);
                        if (GetString(childAddr, 12) == s)
                        {
                            FCBLevel.Push(childAddr);
                            curPath.Add(s);
                            return(true);
                        }
                    }
                }
                int nextBlock = indexBlock.indexes[31];
                for (i = 0; i < blockSize; ++i)
                {
                    blockArray[i] = disk[i + nextBlock * blockSize];
                }
                indexBlock.ChangeBlock(blockArray);
            }
            for (i = 0; i < indexBlock.endIndex - 1; ++i)
            {
                int curBlock = indexBlock.indexes[i];
                for (j = 0; j < 16; ++j)
                {
                    int childAddr = GetInt(curBlock * blockSize + 32 * j, 21);
                    if (GetString(childAddr, 12) == s)
                    {
                        FCBLevel.Push(childAddr);
                        curPath.Add(s);
                        return(true);
                    }
                }
            }
            for (j = 0; j * 32 < rootFCB.endOffset; ++j)
            {
                int childAddr = GetInt(indexBlock.indexes[i] * blockSize + 32 * j, 21);
                if (GetString(childAddr, 12) == s)
                {
                    FCBLevel.Push(childAddr);
                    curPath.Add(s);
                    return(true);
                }
            }
            return(false);
        }
        public String ReadFile(int rootBeginAddr)
        {
            List <String> ls = new List <String>();
            BitArray      rootFCBArray = GetBitArray(rootBeginAddr, 128);
            FCB           rootFCB = new FCB(rootFCBArray, rootBeginAddr);
            BitArray      blockArray = GetBitArray(rootFCB.indexBlock * blockSize, blockSize);
            IndexBlock    indexBlock = new IndexBlock(blockArray);
            int           i, j;

            while (indexBlock.IsFull())
            {
                for (i = 0; i < 31; ++i)
                {
                    int curBlock = indexBlock.indexes[i];
                    ls.Add(GetString(curBlock * 512, 64));
                }
                int nextBlock = indexBlock.indexes[31];
                for (i = 0; i < blockSize; ++i)
                {
                    blockArray[i] = disk[i + nextBlock * blockSize];
                }
                indexBlock.ChangeBlock(blockArray);
            }
            for (i = 0; i < indexBlock.endIndex - 1; ++i)
            {
                int curBlock = indexBlock.indexes[i];
                ls.Add(GetString(curBlock * 512, 64));
            }

            String s = GetString(indexBlock.indexes[i] * blockSize, rootFCB.endOffset);
            int    totLen = ls.Count * 64 + s.Length;

            char[] t = new char[totLen];
            j = 0;
            i = 0;
            foreach (String str in ls)
            {
                for (j = 0; j < 64; ++j)
                {
                    t[i] = str[j];
                    i++;
                }
            }
            for (j = 0; j < s.Length; ++j)
            {
                t[i] = s[j];
                i++;
            }
            return(new String(t));
        }
        public ArrayList GetAllChildType(int rootBeginAddr)
        {
            ArrayList allChild = new ArrayList();

            BitArray   rootFCBArray = GetBitArray(rootBeginAddr, 128);
            FCB        rootFCB = new FCB(rootFCBArray, rootBeginAddr);
            BitArray   blockArray = GetBitArray(rootFCB.indexBlock * blockSize, blockSize);
            IndexBlock indexBlock = new IndexBlock(blockArray);
            int        i, j;

            while (indexBlock.IsFull())
            {
                for (i = 0; i < 31; ++i)
                {
                    int curBlock = indexBlock.indexes[i];
                    for (j = 0; j < 16; ++j)
                    {
                        allChild.Add(disk[GetInt(curBlock * blockSize + 32 * j, 21) + 96]);
                    }
                }
                int nextBlock = indexBlock.indexes[31];
                for (i = 0; i < blockSize; ++i)
                {
                    blockArray[i] = disk[i + nextBlock * blockSize];
                }
                indexBlock.ChangeBlock(blockArray);
            }
            for (i = 0; i < indexBlock.endIndex - 1; ++i)
            {
                int curBlock = indexBlock.indexes[i];
                for (j = 0; j < 16; ++j)
                {
                    allChild.Add(disk[GetInt(curBlock * blockSize + 32 * j, 21) + 96]);
                }
            }
            for (j = 0; j * 32 < rootFCB.endOffset; ++j)
            {
                allChild.Add(disk[GetInt(indexBlock.indexes[i] * blockSize + 32 * j, 21) + 96]);
            }
            return(allChild);
        }
        public void DeleteFile(int rootBeginAddr)
        {
            bool isFolder = disk[rootBeginAddr + 96];
            int  i;

            if (isFolder)
            {
                BitArray   rootFCBArray = GetBitArray(rootBeginAddr, 128);
                FCB        rootFCB      = new FCB(rootFCBArray, rootBeginAddr);
                BitArray   blockArray   = GetBitArray(rootFCB.indexBlock * blockSize, blockSize);
                IndexBlock indexBlock   = new IndexBlock(blockArray);
                indexBlock.num = rootFCB.indexBlock;
                int j;
                while (indexBlock.IsFull())
                {
                    for (i = 0; i < 31; ++i)
                    {
                        int curBlock = indexBlock.indexes[i];
                        for (j = 0; j < 16; ++j)
                        {
                            DeleteFile(GetInt(curBlock * blockSize + 32 * j, 21));
                        }
                    }
                    int nextBlock = indexBlock.indexes[31];
                    for (i = 0; i < 512; ++i)
                    {
                        disk[indexBlock.num * blockSize + i] = false;//将数据擦除
                    }
                    SetInt(GetInt(0, 16), indexBlock.num * blockSize, 16);
                    SetInt(indexBlock.num, 0, 16);
                    SetInt(GetInt(256, 16) + 1, 256, 16);
                    for (i = 0; i < blockSize; ++i)
                    {
                        blockArray[i] = disk[i + nextBlock * blockSize];
                    }
                    indexBlock.ChangeBlock(blockArray);
                    indexBlock.num = nextBlock;
                }
                for (i = 0; i < indexBlock.endIndex - 1; ++i)
                {
                    int curBlock = indexBlock.indexes[i];
                    for (j = 0; j < 16; ++j)
                    {
                        DeleteFile(GetInt(curBlock * blockSize + 32 * j, 21));
                    }
                }
                for (j = 0; j * 32 < rootFCB.endOffset; ++j)
                {
                    DeleteFile(GetInt(indexBlock.indexes[i] * blockSize + 32 * j, 21));
                }
                for (i = 0; i < 512; ++i)
                {
                    disk[indexBlock.num * blockSize + i] = false;//将数据擦除
                }
                SetInt(GetInt(0, 16), indexBlock.num * blockSize, 16);
                SetInt(indexBlock.num, 0, 16);
                SetInt(GetInt(256, 16) + 1, 256, 16);
            }
            else
            {
                BitArray   rootFCBArray = GetBitArray(rootBeginAddr, 128);
                FCB        rootFCB      = new FCB(rootFCBArray, rootBeginAddr);
                BitArray   blockArray   = GetBitArray(rootFCB.indexBlock * blockSize, blockSize);
                IndexBlock indexBlock   = new IndexBlock(blockArray);
                indexBlock.num = rootFCB.indexBlock;
                int j;
                while (indexBlock.IsFull())
                {
                    for (i = 0; i < 31; ++i)
                    {
                        int curBlock = indexBlock.indexes[i];
                        for (j = 0; j < 512; ++j)
                        {
                            disk[curBlock * blockSize + j] = false;//将数据擦除
                        }
                        SetInt(GetInt(0, 16), curBlock * blockSize, 16);
                        SetInt(curBlock, 0, 16);
                        SetInt(GetInt(256, 16) + 1, 256, 16);
                    }
                    int nextBlock = indexBlock.indexes[31];
                    for (i = 0; i < 512; ++i)
                    {
                        disk[indexBlock.num * blockSize + i] = false;//将数据擦除
                    }
                    SetInt(GetInt(0, 16), indexBlock.num * blockSize, 16);
                    SetInt(indexBlock.num, 0, 16);
                    SetInt(GetInt(256, 16) + 1, 256, 16);
                    for (i = 0; i < blockSize; ++i)
                    {
                        blockArray[i] = disk[i + nextBlock * blockSize];
                    }
                    indexBlock.ChangeBlock(blockArray);
                    indexBlock.num = nextBlock;
                }
                for (i = 0; i < indexBlock.endIndex; ++i)
                {
                    int curBlock = indexBlock.indexes[i];
                    for (j = 0; j < 512; ++j)
                    {
                        disk[curBlock * blockSize + j] = false;//将数据擦除
                    }
                    SetInt(GetInt(0, 16), curBlock * blockSize, 16);
                    SetInt(curBlock, 0, 16);
                    SetInt(GetInt(256, 16) + 1, 256, 16);
                }
                for (j = 0; j < 512; ++j)
                {
                    disk[indexBlock.num * blockSize + j] = false;//将数据擦除
                }
                SetInt(GetInt(0, 16), indexBlock.num * blockSize, 16);
                SetInt(indexBlock.num, 0, 16);
                SetInt(GetInt(256, 16) + 1, 256, 16);
            }
            for (i = 0; i < 128; ++i)
            {
                disk[rootBeginAddr + i] = false;//擦除PCB
            }
            SetInt(GetInt(16, 21), rootBeginAddr, 21);
            SetInt(rootBeginAddr, 16, 21);
        }
        public bool WriteFile(int rootBeginAddr, BitArray dataBitset)
        {
            int        i;
            BitArray   rootFCBArray = GetBitArray(rootBeginAddr, 128);
            FCB        rootFCB      = new FCB(rootFCBArray, rootBeginAddr);
            BitArray   blockArray   = GetBitArray(rootFCB.indexBlock * blockSize, blockSize);
            IndexBlock indexBlock   = new IndexBlock(blockArray);

            indexBlock.num = rootFCB.indexBlock;
            while (indexBlock.IsFull())
            {
                int nextBlock = indexBlock.indexes[31];
                for (i = 0; i < blockSize; ++i)
                {
                    blockArray[i] = disk[i + nextBlock * blockSize];
                }
                indexBlock.ChangeBlock(blockArray);
                indexBlock.num = nextBlock;
            }
            int endAddr = rootFCB.endOffset + indexBlock.indexes[indexBlock.endIndex - 1] * blockSize;

            for (i = 0; i < dataBitset.Length; ++i)
            {
                disk[endAddr] = dataBitset[i];
                if (endAddr % blockSize == (blockSize - 1)) //当前块被写满
                {
                    if (indexBlock.endIndex == 31)          //索引块被写满
                    {
                        int nextBlock = GetNextFreeBlock();
                        if (nextBlock == 0)
                        {
                            return(false);               //磁盘已满,写入失败
                        }
                        SetInt(nextBlock, indexBlock.num * blockSize + 16 * 31, 16);
                        int j;
                        for (j = 0; j < blockSize; ++j)
                        {
                            blockArray[j] = disk[j + indexBlock.num * blockSize];
                        }
                        int temp = nextBlock;
                        nextBlock = GetNextFreeBlock();
                        SetInt(nextBlock, temp * blockSize, 16);

                        indexBlock.ChangeBlock(blockArray);
                        indexBlock.num      = temp;
                        endAddr             = nextBlock * blockSize;
                        indexBlock.endIndex = 1;
                    }
                    else
                    {
                        int nextBlock = GetNextFreeBlock();
                        if (nextBlock == 0)
                        {
                            return(false);               //磁盘已满,写入失败
                        }
                        SetInt(nextBlock, indexBlock.num * blockSize + indexBlock.endIndex * 16, 16);
                        indexBlock.endIndex++;
                        endAddr = nextBlock * blockSize;
                    }
                }
                else
                {
                    endAddr++;
                }
            }
            int offset = endAddr % blockSize;

            SetInt(offset, rootBeginAddr + 113, 9);
            return(true);
        }