Ejemplo n.º 1
0
        private FileBlock GetBlock(long offset)
        {
            FileBlock result = null;
            int       num    = (int)(offset / m_blockSize);

            if (num < m_blocks.Count)
            {
                result = m_blocks[num];
            }
            return(result);
        }
Ejemplo n.º 2
0
        private long SearchBlock(long offset, long size)
        {
            long      result = -1L;
            FileBlock block  = GetBlock(offset);

            if (block != null)
            {
                result = block.AllocateSpace(size);
            }
            return(result);
        }
Ejemplo n.º 3
0
        private FileBlock GetOrCreateBlock(long offset)
        {
            int num = (int)(offset / m_blockSize);

            if (num >= m_blocks.Count)
            {
                for (int i = m_blocks.Count - 1; i < num; i++)
                {
                    m_blocks.Add(null);
                }
                m_blocks.Add(new FileBlock());
            }
            FileBlock fileBlock = m_blocks[num];

            if (fileBlock == null)
            {
                fileBlock     = new FileBlock();
                m_blocks[num] = fileBlock;
            }
            return(fileBlock);
        }