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); } }
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; }
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); }
public void addBlock(cDatFileBlock block) { blocks.Add(block.blockOffset, block); }