/// <summary> /// Attempts to read a record from file, /// returns null upon reaching end of file /// </summary> /// <param name="fs">file stream to read from</param> /// <param name="offset">offset to begin from</param> /// <returns>A new record or null</returns> public Record ReadRecord(FileStream fs) { byte[] rawHeader = new byte[HEADER_SIZE]; int count = fs.Read(rawHeader, 0, HEADER_SIZE); if (count == 0) { return(null); } else if (count < 16) { throw new FormatException("Unexpected file size."); } bytesRead += count; RecordHeader header = new RecordHeader(rawHeader); byte[] data = new byte[header.Size]; count = fs.Read(data, 0, header.Size); if (count < header.Size) { throw new Exception("Unexpected file size."); } bytesRead += count; return(factory.ConstructRecord(header, data)); }