//开始校验文件 void StartCheckFile(FileListJson fileListJson) { var fileList = fileListJson.FileList; foreach (FileJson fileJson in fileList) { string filename = fileJson.FileName; string md5 = fileJson.MD5; string path = GameConfig.GetReadPath(filename); string checkMD5 = FileHelper.GetMD5HashFromFile(path); if (md5 != checkMD5) { string fp = GameConfig.GetPersitentPath("chinatown/filelist.txt"); string vp = GameConfig.GetPersitentPath("chinatown/version.txt"); //将之前的更新文件删除 File.Delete(fp); File.Delete(vp); InitFailed("校验文件失败"); return; } } InitLua(fileListJson); }
//更新文件 public void UpdateFile() { //更新md5 string fp = GameConfig.GetPersitentPath("chinatown/filelist.txt"); string fd = FileHelper.GetDir(fp); if (!Directory.Exists(fd)) { Directory.CreateDirectory(fd); } File.WriteAllText(fp, JsonUtility.ToJson(m_ServerFileList)); //更新version string vp = GameConfig.GetPersitentPath("chinatown/version.txt"); string vd = FileHelper.GetDir(vp); if (!Directory.Exists(vd)) { Directory.CreateDirectory(vd); } File.WriteAllText(vp, JsonUtility.ToJson(m_ServerVersion)); //更新版本显示 m_InitView.SetVersion(m_ServerVersion.Version); CheckFile(); }