public override int Read(byte[] buffer, int offset, int size) { while (size > 0) { var cluster_index = (int)(position / cluster_size); var in_cluster_offset = (int)(position % cluster_size); var cluster_wbfs_index = BigEndian.ToUInt16(clusters_table, cluster_index * 2); var cluster_copy_size = Math.Min(cluster_size - in_cluster_offset, size); if (cluster_wbfs_index == 0) { Array.Clear(buffer, offset, cluster_copy_size); } else { stream.Read((long)cluster_wbfs_index * cluster_size + in_cluster_offset, buffer, offset, cluster_copy_size); } offset += cluster_copy_size; size -= cluster_copy_size; position += cluster_copy_size; } return(size); }
public static int ReadBE16(this Stream file, long position) { return(BigEndian.ToUInt16(file.Read(position, 2), 0)); }
public static long ReadBE32(this Stream file, long position) { return(BigEndian.ToUInt32(file.Read(position, 4), 0)); }