Ejemplo n.º 1
0
        public static void loadBlocksAndAddToDictionary(cDatFileBlockCache blockCache, StreamReader inputFile, int blockSize)
        {
            inputFile.BaseStream.Seek(1024, SeekOrigin.Begin);

            while (inputFile.BaseStream.Position < inputFile.BaseStream.Length)
            {
                cDatFileBlock newBlock = new cDatFileBlock(inputFile, blockSize);
                blockCache.addBlock(newBlock);
            }
        }
Ejemplo n.º 2
0
        public void addNewFreeBlocks(int amount)
        {
            cDatFileBlock previousBlock = blocks[freeTail];

            for (int i = 1; i <= amount; i++)
            {
                cDatFileBlock newBlock = new cDatFileBlock(fileSize, 0, blockSize, true);
                blocks.Add(newBlock.blockOffset, newBlock);

                previousBlock.nextBlockOffset = newBlock.blockOffset;
                previousBlock = newBlock;
                freeCount++;
                fileSize += (uint)blockSize;
            }
            freeTail = previousBlock.blockOffset;
        }
Ejemplo n.º 3
0
        public void expandListOfBlocks(List <cDatFileBlock> listOfBlocks, int amountOfBlocksToAdd)
        {
            cDatFileBlock lastBlock = null;

            if (listOfBlocks.Count > 0)
            {
                lastBlock = listOfBlocks[listOfBlocks.Count - 1];
            }

            List <cDatFileBlock> newBlocks = getNewBlocks(amountOfBlocksToAdd);

            if (lastBlock != null)
            {
                lastBlock.nextBlockOffset = newBlocks[0].blockOffset;
            }

            listOfBlocks.AddRange(newBlocks);
        }
Ejemplo n.º 4
0
 public void addBlock(cDatFileBlock block)
 {
     blocks.Add(block.blockOffset, block);
 }