[Karmalib-commits] csharp/src/KarmaLib/Messages GetAllFileDetailsResponse.cs,NONE,1.1
Brought to you by:
justinkwaugh
From: <ia...@us...> - 2004-01-17 00:07:06
|
Update of /cvsroot/karmalib/csharp/src/KarmaLib/Messages In directory sc8-pr-cvs1:/tmp/cvs-serv13539/src/KarmaLib/Messages Added Files: GetAllFileDetailsResponse.cs Log Message: new files for GetAllFileDetails implementation --- NEW FILE: GetAllFileDetailsResponse.cs --- using System; //using System.IO; using System.Net.Sockets; using KarmaLib.Data; using KarmaLib.Util; namespace KarmaLib.Messages { public class GetAllFileDetailsResponse : KarmaStatusResponse { private KarmaLib.Data.FileDetails current = null; private int totalRead = 0; public GetAllFileDetailsResponse(NetworkStream rns) : base(rns) { } public FileDetails NextElement() { FileDetails rv = current; current = ReadFileDetails(); return rv; } private FileDetails ReadFileDetails() { FileDetails rv = null; byte[] FileDetails = IOUtils.ReadUntilEmptyLineOrNull( this.rns ); if (FileDetails.Length > 0) { totalRead += FileDetails.Length; rv = new FileDetails(); rv.LoadFromByteArray(FileDetails); } else { totalRead++; int remainder = totalRead % 4; if (remainder > 0) { IOUtils.DiscardBytes(rns, 4 - remainder); } } return rv; } public bool HasMoreElements() { return (current == null ? false : true); } public override void ReadResponse() { base.ReadResponse(); current = ReadFileDetails(); } public FileDetailsEnumerator Files { get { return new FileDetailsEnumerator( this ); } } } } |