public byte[] Read(int index, int length) { //reads length data bytes from file starting at index byte //fill cache by read current data from disk for this file LoadBlocks(); //copy data from blocks return(VirtualBlock.ReadBlockData(drive, blocks, index, length)); }
public byte[] Read(int index, int length) { if (!IsFile) { throw new Exception("Must be a file to read bytes!"); } // Make sure the cache is filled LoadBlocks(); // Copy the data from the blocks byte[] result = VirtualBlock.ReadBlockData(drive, blocks, index, length); // Return the data return(result); }
public byte[] Read(int index, int length) { // Make sure this is a file if (!IsFile) { throw new Exception("Must read from a file!"); } // Check for reading past end if ((index + length) > FileLength) { throw new Exception("Can't read beyond end of file! /n"); } // Load the cache of blocks for the file LoadBlocks(); // Write the bytes to the cache return(VirtualBlock.ReadBlockData(drive, blocks, index, length)); }