/// <summary> /// 解压缩文件并返回临时文件夹路径 /// </summary> /// <param name="filePath"></param> /// <returns></returns> public string extractFile(string filePath) { Vesal_DirFiles.UnZip(filePath, TempFilePath); DirectoryInfo di = new DirectoryInfo(TempFilePath); try { return(di.GetDirectories()[0].FullName); } catch (Exception e) { Debug.Log(e.Message); } return(string.Empty); }
IEnumerator update_process(int index, Action count_load = null) { string fix_file = PublicClass.filePath + Vesal_DirFiles.get_file_name_from_full_path(update_list[index].name); if (Directory.Exists(PublicClass.UpdatePath)) { Vesal_DirFiles.CreateDir(PublicClass.UpdatePath); } try { Vesal_DirFiles.UnZip(fix_file, PublicClass.UpdatePath, true); Vesal_DirFiles.DelFile(fix_file); } catch (System.Exception e) { Debug.Log(e.Message); Debug.Log(e.StackTrace); } yield return(null); //打开数据库进行更新 string[] files = Directory.GetFiles(PublicClass.UpdatePath); List <string> fix_tab_list = new List <string>(); foreach (string tagetfile in files) { string target = Vesal_DirFiles.get_file_name_from_full_path(tagetfile); if (target == "vesali.db") { File.Copy(tagetfile, PublicClass.vesal_db_path + "temp.db", true); fix_tab_list = PublicTools.get_table_list("temp.db"); int tab_count = 0; if (fix_tab_list.Count != 0) { foreach (string tab_name in fix_tab_list) { switch (tab_name) { case "GetSubModel": PublicTools.update_GetSubModel_db("temp.db"); break; case "GetStructList": PublicTools.update_GetStructList_db("temp.db"); break; case "GetStructAbList": PublicTools.update_GetStructAbList_db("temp.db"); break; case "LayserSubModel": PublicTools.update_LayserSubModel_db("temp.db"); break; case "ModelRelationModel": PublicTools.update_ModelRelationModel_db("temp.db"); break; case "RightMenuLayerModel": PublicTools.update_RightMenuLayerModel_db("temp.db"); break; case "RightMenuModel": PublicTools.update_RightMenuModel_db("temp.db"); break; case "SignNewInfo": PublicTools.update_SignNewInfo_db("temp.db"); break; case "GetTextureModelList": PublicTools.update_GetTextureModelList_db("temp.db"); break; case "noun_no_info": PublicTools.update_noun_no_info_db("temp.db"); break; case "AbInfo": PublicTools.update_ab_info_db("temp.db"); break; } tab_count++; showProgress.current_progress = (float)index / update_list.Count + (float)tab_count / fix_tab_list.Count / update_list.Count; yield return(null); } } else { PublicTools.update_GetSubModel_db("temp.db"); showProgress.current_progress = (float)index / update_list.Count + 0.1f / update_list.Count; PublicTools.update_GetStructList_db("temp.db"); showProgress.current_progress = (float)index / update_list.Count + 0.3f / update_list.Count; yield return(null); PublicTools.update_GetStructAbList_db("temp.db"); PublicTools.update_LayserSubModel_db("temp.db"); showProgress.current_progress = (float)index / update_list.Count + 0.5f / update_list.Count; yield return(null); PublicTools.update_ModelRelationModel_db("temp.db"); PublicTools.update_RightMenuLayerModel_db("temp.db"); showProgress.current_progress = (float)index / update_list.Count + 0.65f / update_list.Count; yield return(null); PublicTools.update_RightMenuModel_db("temp.db"); PublicTools.update_SignNewInfo_db("temp.db"); showProgress.current_progress = (float)index / update_list.Count + 0.8f / update_list.Count; yield return(null); PublicTools.update_GetTextureModelList_db("temp.db"); PublicTools.update_noun_no_info_db("temp.db"); PublicTools.update_ab_info_db("temp.db"); showProgress.current_progress = (float)index / update_list.Count + 0.99f / update_list.Count; yield return(null); } } //拷贝文件 } string[] dirs = Directory.GetDirectories(PublicClass.UpdatePath); foreach (string targetdir in dirs) { string subdir = Vesal_DirFiles.get_file_name_from_full_path(targetdir); if (subdir.ToUpper() == "ANDROID_SIGN") { Vesal_DirFiles.Vesal_DirCopy(targetdir, PublicClass.SignPath); } if (subdir.ToUpper() == "MODEL") { Vesal_DirFiles.Vesal_DirCopy(targetdir, PublicClass.ModelPath); } } yield return(null); //删除update数据 try { Directory.Delete(PublicClass.UpdatePath, true); Vesal_DirFiles.DelFile(PublicClass.vesal_db_path + "temp.db"); } catch (System.Exception e) { Debug.Log(e.Message); Debug.Log(e.StackTrace); } yield return(null); if (count_load != null) { count_load(); } }