void Init(string path, G2Protocol protocol, ProcessTagsHandler processTags) { Seek(-8, SeekOrigin.End); byte[] sizeBytes = new byte[8]; Read(sizeBytes, 0, sizeBytes.Length); long fileSize = BitConverter.ToInt64(sizeBytes, 0); if (processTags != null) { // read public packets Seek(fileSize, SeekOrigin.Begin); PacketStream stream = new PacketStream(this, protocol, FileAccess.Read); // dont need to close packetStream processTags.Invoke(stream); } // set public size down here so reading packet stream works without mixing up true file lenght InternalSize = fileSize; // set back to the beginning of the file Seek(0, SeekOrigin.Begin); }
void Init(string path, G2Protocol protocol, ProcessTagsHandler processTags) { Seek(-8, SeekOrigin.End); byte[] sizeBytes = new byte[8]; Read(sizeBytes, 0, sizeBytes.Length); long fileSize = BitConverter.ToInt64(sizeBytes, 0); if (processTags != null) { // read public packets Seek(fileSize, SeekOrigin.Begin); PacketStream stream = new PacketStream(this, protocol, FileAccess.Read); // dont need to close packetStream processTags.Invoke(stream); } // set public size down here so reading packet stream works without mixing up true file lenght InternalSize = fileSize; // set back to the beginning of the file Seek(0, SeekOrigin.Begin); }
public TaggedStream(string path, G2Protocol protocol, ProcessTagsHandler processTags) : base(path, FileMode.Open, FileAccess.Read, FileShare.Read) { Init(path, protocol, processTags); }
public TaggedStream(string path, G2Protocol protocol, ProcessTagsHandler processTags) : base(path, FileMode.Open, FileAccess.Read, FileShare.Read) { Init(path, protocol, processTags); }