/// <summary> /// With this constructor a Rstat message will be created /// </summary> /// <param name="tag"></param> /// <param name="fid"></param> public StyxStatMessage(ushort tag, StatStructure stat) { this.Tag = tag; this.Type = MessageType.Rstat; this.stat = stat; }
public static StatStructure getStat(byte[] data, int offset) { StatStructure res = new StatStructure(); // size //ushort size = BitConverter.ToUInt16(data, offset); offset += sizeof(ushort); // type res.type = BitConverter.ToUInt16(data, offset); offset += sizeof(ushort); // dev res.dev = BitConverter.ToUInt32(data, offset); offset += sizeof(uint); // qid res.qid = StyxMessage.getQuid(data, offset); offset += (int)StyxMessage.QIDSIZE; // mode res.mode = BitConverter.ToUInt32(data, offset); offset += sizeof(uint); // atime res.atime = BitConverter.ToUInt32(data, offset); offset += sizeof(uint); // mtime res.mtime = BitConverter.ToUInt32(data, offset); offset += sizeof(uint); // length res.length = BitConverter.ToUInt64(data, offset); offset += sizeof(ulong); //name int strlen = BitConverter.ToUInt16(data, offset); offset += sizeof(ushort); res.name = Encoding.UTF8.GetString(data, offset, strlen); offset += strlen; //uid strlen = BitConverter.ToUInt16(data, offset); offset += sizeof(ushort); res.uid = Encoding.UTF8.GetString(data, offset, strlen); offset += strlen; //gid strlen = BitConverter.ToUInt16(data, offset); offset += sizeof(ushort); res.gid = Encoding.UTF8.GetString(data, offset, strlen); offset += strlen; //muid strlen = BitConverter.ToUInt16(data, offset); offset += sizeof(ushort); res.muid = Encoding.UTF8.GetString(data, offset, strlen); offset += strlen; return res; }
/// <summary> /// Rstat decoder /// </summary> /// <param name="data"></param> public void SetRBinary(byte[] data) { int pos = (int)base.GetBinarySize(); int length = BitConverter.ToUInt16(data, pos); pos += sizeof(ushort); stat = StatStructure.getStat(data, pos); }