Ejemplo n.º 1
0
        public virtual byte[] ToBytes()
        {
            var bytes  = new byte[Length];
            var offset = Protocol.WriteUint(bytes, Length, 0);

            bytes[offset] = Type;
            offset       += Constants.Bit8Sz;

            offset += Protocol.WriteUshort(bytes, Tag, offset);

            if (offset < Length)
            {
                throw new Exception($"Buffer underflow. Len: {Length}, Offset: {offset}");
            }
            return(bytes);
        }
Ejemplo n.º 2
0
Archivo: Qid.cs Proyecto: forki/Sharp9P
        public byte[] ToBytes()
        {
            var bytes  = new byte[Constants.Qidsz];
            var offset = 0;

            bytes[offset] = Type;
            offset       += Constants.Bit8Sz;
            offset       += Protocol.WriteUint(bytes, Vers, offset);
            offset       += Protocol.WriteUlong(bytes, Path, offset);

            if (offset < Constants.Qidsz)
            {
                throw new Exception($"Buffer underflow. Len: {Constants.Qidsz}, Offset: {offset}");
            }
            return(bytes);
        }
Ejemplo n.º 3
0
        public byte[] ToBytes()
        {
            var bytes  = new byte[Size];
            var offset = 0;

            offset += Protocol.WriteUshort(bytes, Size, offset);
            offset += Protocol.WriteUshort(bytes, Type, offset);
            offset += Protocol.WriteUint(bytes, Dev, offset);
            offset += Protocol.WriteQid(bytes, Qid, offset);
            offset += Protocol.WriteUint(bytes, Mode, offset);
            offset += Protocol.WriteUint(bytes, Atime, offset);
            offset += Protocol.WriteUint(bytes, Mtime, offset);
            offset += Protocol.WriteUlong(bytes, Length, offset);
            offset += Protocol.WriteString(bytes, Name, offset);
            offset += Protocol.WriteString(bytes, Uid, offset);
            offset += Protocol.WriteString(bytes, Gid, offset);
            offset += Protocol.WriteString(bytes, Muid, offset);

            if (offset < Size)
            {
                throw new Exception($"Buffer underflow. Len: {Size}, Offset: {offset}");
            }
            return(bytes);
        }