Ejemplo n.º 1
0
        /// <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);
        }
Ejemplo n.º 2
0
 public void InitFileMapInfo(FileMapSystem sys)
 {
     if (sys == null)
     {
         return;
     }
     Dir = sys.Dir;
     _FileMapInfoFileName = sys.FileMapInfoFileName;
     FileInfo             = sys.FileInfo;
     RecalFileInfo2NameMap();
 }
Ejemplo n.º 3
0
        public bool InitFileMapInfo(byte[] infoBytes)
        {
            try
            {
                //MD5校验
                var fi = FileMapGroupInfo.ReadFromByteBuf(infoBytes);
                if (fi == null)
                {
                    return(false);
                }
                FileInfo = fi;
                RecalFileInfo2NameMap();
                return(true);
            }
            catch (Exception e)
            {
                CommonLog.Error(e);
            }

            return(false);
        }