/// <summary> /// 无论啥错误都会返回一个默认的 /// </summary> /// <param name="cfgBytes"></param> /// <returns></returns> public static FileMapGroupInfo ReadFromByteBuf(byte[] cfgBytes) { var group = new FileMapGroupInfo(); var byteBuf = ByteBuf.CreateFromBytes(cfgBytes); group.MD51 = byteBuf.ReadLong(); group.MD52 = byteBuf.ReadLong(); group.Ver = new Version() { Version_Major = byteBuf.ReadInt(), Version_Minor = byteBuf.ReadInt(), Version_Build = byteBuf.ReadInt(), }; var readedMd5 = MD5Creater.MD5Struct.CreateFromLong(group.MD51, group.MD52); var fileMD5 = MD5Creater.GenerateMd5Code(cfgBytes, 16); if (!readedMd5.Equals(fileMD5)) { CommonLog.Error("MD5校验不通过!"); return(null); } int FileNum = byteBuf.ReadInt(); group.AllFileMapInfo = new FileMapInfo[FileNum]; for (int i = 0; i < group.AllFileMapInfo.Length; i++) { group.AllFileMapInfo[i] = FileMapInfo.ReadFromByteBuf(byteBuf); } return(group); }
public bool IsSame(FileMapInfo info) { if (info == null) { return(false); } return(this.FileName == info.FileName && this.FileData_MD51 == info.FileData_MD51 && this.FileData_MD52 == info.FileData_MD52); }
public FileMapInfo Clone() { var newF = new FileMapInfo(); newF.FileName = FileName; newF.FileData_MD51 = FileData_MD51; newF.FileData_MD52 = FileData_MD52; newF.FileTag = FileTag; newF.Offset = Offset; newF.Len = Len; newF.MapedFileName_MD51 = MapedFileName_MD51; newF.MapedFileName_MD52 = MapedFileName_MD52; //newF.MappedFileLong = MappedFileLong; return(newF); }
public static FileMapInfo ReadFromByteBuf(ByteBuf cfg) { var info = new FileMapInfo(); info.FileName = cfg.ReadUTF8(); info.FileData_MD51 = cfg.ReadLong(); info.FileData_MD52 = cfg.ReadLong(); info.FileTag = cfg.ReadInt(); info.Offset = cfg.ReadInt(); info.Len = cfg.ReadInt(); info.MapedFileName_MD51 = cfg.ReadLong(); info.MapedFileName_MD52 = cfg.ReadLong(); //info.MappedFileLong = cfg.ReadLong(); return(info); }