static public T[] ReadChunk <T>(long position, int count, Stream fs, BinaryReader bread) where T : struct { T[] Structure = new T[count]; fs.Seek(position, SeekOrigin.Begin); byte[] red = bread.ReadBytes(Marshal.SizeOf(Structure /*cks.ckFmt*/)); Structure = IOHelper.xread <T[]>(Structure, red); red = null; return(Structure); }
static public T ReadChunk <T>(long position, Stream fs) where T : struct { T Structure = new T(); fs.Seek(position, SeekOrigin.Begin); int size = Marshal.SizeOf(Structure /*cks.ckFmt*/); byte[] red = new byte[size]; fs.Read(red, Convert.ToInt32(position), size); Structure = IOHelper.xread <T>(Structure, red); red = null; return(Structure); }
static public T[] ReadChunk <T>(long position, int numberOfChunks, Stream s) where T : struct { T[] Structure = new T[numberOfChunks]; T test = new T(); int StructureSize = Marshal.SizeOf(test); // the number of bytes we're going to read is "numberOfChunks * StructureSize" s.Seek(Convert.ToInt32(position), SeekOrigin.Begin); int size = Marshal.SizeOf(Structure); byte[] bytes = new byte[size]; s.Read(bytes, Convert.ToInt32(position), size); Structure = IOHelper.xread <T[]>(Structure, bytes); bytes = null; return(Structure); }