예제 #1
0
 public void IsSubpathTest(string path1, string path2, bool mutual, bool expect)
 {
     if (expect == VFSUtil.IsSubpath(path1, path2, mutual))
     {
         Assert.IsTrue(true);
     }
     else
     {
         TestContext.Out.WriteLine($"测试与预期不符, path1: {path1}, path2: { path2}, mutual: {mutual.ToString()}, 预期:{expect.ToString()}");
         Assert.IsFalse(true);
     }
 }
예제 #2
0
        public void SetOptions(VFSGroupOption option)
        {
            mOption   = option;
            GroupName = option.GroupName;
            foreach (var path in option.FolderPaths)
            {
                if (!path.EndsWith("/"))
                {
                    string _path = path + "/";
                    FolderPaths.Add(_path);
                    FolderPathsLower.Add(_path.ToLower());
                }
                else
                {
                    FolderPaths.Add(path);
                    FolderPathsLower.Add(path.ToLower());
                }
            }

            foreach (var path in option.AssetPaths)
            {
                AssetPaths.Add(path);
                AssetPathsLower.Add(path.ToLower());
            }

            //忽略子目录,子目录必须是FolderPaths的子目录,这里初始化的时候过滤一下无效的配置,节省后面的运算
            foreach (var path in option.IgnoreSubPath)
            {
                string _path      = (path.EndsWith("/")) ? path : path + "/";
                string path_lower = _path.ToLower();
                foreach (var folder in FolderPathsLower)
                {
                    if (VFSUtil.IsSubpath(path_lower, folder, false))
                    {
                        IgnoreSubpath.Add(_path);
                        IgnoreSubpathLower.Add(path_lower);
                        break;
                    }
                }
            }

            //忽略后缀名
            foreach (var ext in option.IngnoreExtName)
            {
                IgnoreExtensionLower.Add(ext.StartsWith(".") ? ext.ToLower() : "." + ext.ToLower());
            }

            //特殊打包规则
            foreach (var rule in option.FolderSpecialBuildRules)
            {
                bool flag = true;
                if (rule.DevType == FolderBuildDevelopType.normal && rule.BuildType == FolderBuildType.normal)
                {
                    flag = false;//这是条没必要的规则
                }
                if (rule.FolderPath.IsNullOrEmpty() || rule.FolderPath.IsNullOrWhiteSpace())
                {
                    flag = false;
                }

                string _folder_path  = (rule.FolderPath.EndsWith("/")) ? rule.FolderPath : rule.FolderPath + "/";
                string _folder_lower = _folder_path.ToLower();

                if (!IsSubfolderOfFolderList(_folder_path))
                {
                    flag = false;
                }

                if (flag)
                {
                    var _rule = rule;
                    _rule.FolderPath = _folder_path;
                    var lower_rule = rule;
                    lower_rule.FolderPath = _folder_lower;
                    SpecialFolderBuildRules.Add(_rule);
                    SpecialFolderBuildRulesLower.Add(lower_rule);
                }
            }
        }