/// <summary>
/// Reads byte[] line from stream.
/// </summary>
/// <returns>Return null if end of stream reached.</returns>
public byte[] ReadLine()
{
ArrayList lineBuf = new ArrayList();
byte prevByte = 0;
int currByteInt = m_StrmSource.ReadByte();
while(currByteInt > -1){
lineBuf.Add((byte)currByteInt);
// Line found
if((prevByte == (byte)'\r' && (byte)currByteInt == (byte)'\n')){
byte[] retVal = new byte[lineBuf.Count-2]; // Remove <CRLF>
lineBuf.CopyTo(0,retVal,0,lineBuf.Count-2);
return retVal;
}
// Store byte
prevByte = (byte)currByteInt;
// Read next byte
currByteInt = m_StrmSource.ReadByte();
}
// Line isn't terminated with <CRLF> and has some chars left, return them.
if(lineBuf.Count > 0){
byte[] retVal = new byte[lineBuf.Count];
lineBuf.CopyTo(0,retVal,0,lineBuf.Count);
return retVal;
}
return null;
}