/// <summary> /// 检测文件路径是否在VFS管理范围内 /// </summary> /// <param name="path">文件路径</param> /// <param name="fileInfo">解析出的文件信息</param> /// <returns>如果在管理范围内,返回true</returns> private bool AssetPathTest(string path, out S_FileInfo fileInfo) { fileInfo = AssetParse.Parse(path, mConfigCache); if (fileInfo.handle_tag == E_FileHandleTag.invalid) { #if UNITY_EDITOR //编辑器报提示 EditorUtility.DisplayDialog("资源系统 - 错误", "无法加载资源:" + path + "\n该路径资源在TinaX资源系统的管理范围之外,请尝试调整资源管理策略配置。", "好"); #endif return(false); } return(true); }
public static S_FileInfo Parse(string file, VFSConfigCache confCache) { var re_fileInfo = new S_FileInfo(); re_fileInfo.file_path = file; var path_lower = file.ToLower(); //忽略判定 //是否属于白名单 var white_list_flag = false; foreach (var item in confCache.VFS_WhiteList) { string _t_path; if (item.EndsWith("/")) { _t_path = item.ToLower(); } else { _t_path = item.ToLower() + "/"; } //Debug.Log("判断路径:" + path_lower + " |是否在白名单:" + _t_path); if (path_lower.StartsWith(_t_path)) { white_list_flag = true; break; } } if (!white_list_flag) { if (!IsIgnorePathWhileList(path_lower)) { //不在资源管理范围内 re_fileInfo.ab_name = ""; re_fileInfo.file_name_in_ab = ""; re_fileInfo.handle_tag = E_FileHandleTag.invalid; re_fileInfo.invalidInfo = "不在虚拟文件系统的管理白名单内"; return(re_fileInfo); } } //关键字忽略 foreach (var item in confCache.VFS_IgnorePathKeyword) { var _t_path = path_lower; if (_t_path.IndexOf('.') != -1) { var last_index = _t_path.LastIndexOf("/"); _t_path = _t_path.Substring(0, last_index); } if (_t_path.Contains(item.ToLower())) { //命中关键字 re_fileInfo.ab_name = ""; re_fileInfo.file_name_in_ab = ""; re_fileInfo.handle_tag = E_FileHandleTag.invalid; re_fileInfo.invalidInfo = "被关键字忽略规则忽略"; return(re_fileInfo); } } //后缀名忽略 foreach (var item in confCache.VFS_IgnoreExt) { if (path_lower.EndsWith("." + item.ToLower())) { //命中后缀名 re_fileInfo.ab_name = ""; re_fileInfo.file_name_in_ab = ""; re_fileInfo.handle_tag = E_FileHandleTag.invalid; re_fileInfo.invalidInfo = "被后缀名忽略规则忽略"; return(re_fileInfo); } } //路径忽略 foreach (var item in confCache.VFS_IgnorePath) { string _t_path; if (item.EndsWith("/")) { _t_path = item.ToLower(); } else { _t_path = item.ToLower() + "/"; } if (path_lower.StartsWith(_t_path)) { //Debug.Log("命中"); if (!IsIgnorePathWhileList(path_lower)) { //命中忽略路径 re_fileInfo.ab_name = ""; re_fileInfo.file_name_in_ab = ""; re_fileInfo.handle_tag = E_FileHandleTag.invalid; re_fileInfo.invalidInfo = "被路径忽略规则忽略:" + _t_path; return(re_fileInfo); } } } //文件夹特殊打包规则确定 foreach (var item in confCache.VFS_SpecialFolder) { string _t_path; string _t_path_pure; if (item.FolderName.EndsWith("/")) { _t_path = item.FolderName.ToLower(); _t_path_pure = _t_path.Substring(0, _t_path.Length - 1); } else { _t_path_pure = item.FolderName.ToLower(); _t_path = _t_path_pure + "/"; } if (path_lower.StartsWith(_t_path)) { re_fileInfo.handle_tag = E_FileHandleTag.special; switch (item.PackType) { case E_Dir_PackType.sub_dir: var subs_path = path_lower.Replace(_t_path, ""); var sub_index = subs_path.IndexOf('/'); if (sub_index == -1) { re_fileInfo.ab_name = _t_path_pure; re_fileInfo.file_name_in_ab = path_lower; //TODO } else { re_fileInfo.ab_name = _t_path + subs_path.Substring(0, sub_index); re_fileInfo.file_name_in_ab = path_lower; //TODO } return(re_fileInfo); case E_Dir_PackType.whole: re_fileInfo.ab_name = _t_path_pure; re_fileInfo.file_name_in_ab = path_lower; return(re_fileInfo); } } } re_fileInfo.ab_name = path_lower; re_fileInfo.file_name_in_ab = path_lower; re_fileInfo.handle_tag = E_FileHandleTag.single; return(re_fileInfo); }