public Response(byte[] responseBody) { byte[] groupNameBuffer = new byte[Consts.FDFS_GROUP_NAME_MAX_LEN]; Array.Copy(responseBody, groupNameBuffer, Consts.FDFS_GROUP_NAME_MAX_LEN); GroupName = FDFSUtil.ByteToString(groupNameBuffer).TrimEnd('\0'); byte[] fileNameBuffer = new byte[responseBody.Length - Consts.FDFS_GROUP_NAME_MAX_LEN]; Array.Copy(responseBody, Consts.FDFS_GROUP_NAME_MAX_LEN, fileNameBuffer, 0, fileNameBuffer.Length); FileName = FDFSUtil.ByteToString(fileNameBuffer).TrimEnd('\0'); }
public Response(byte[] responseByte) { byte[] groupNameBuffer = new byte[Consts.FDFS_GROUP_NAME_MAX_LEN]; Array.Copy(responseByte, groupNameBuffer, Consts.FDFS_GROUP_NAME_MAX_LEN); GroupName = FDFSUtil.ByteToString(groupNameBuffer).TrimEnd('\0'); byte[] ipAddressBuffer = new byte[Consts.IP_ADDRESS_SIZE - 1]; Array.Copy(responseByte, Consts.FDFS_GROUP_NAME_MAX_LEN, ipAddressBuffer, 0, Consts.IP_ADDRESS_SIZE - 1); IPStr = new string(FDFSConfig.Charset.GetChars(ipAddressBuffer)).TrimEnd('\0'); byte[] portBuffer = new byte[Consts.FDFS_PROTO_PKG_LEN_SIZE]; Array.Copy(responseByte, Consts.FDFS_GROUP_NAME_MAX_LEN + Consts.IP_ADDRESS_SIZE - 1, portBuffer, 0, Consts.FDFS_PROTO_PKG_LEN_SIZE); Port = (int)FDFSUtil.BufferToLong(portBuffer, 0); }