Example #1
0
        public static bool IsMatch(ImportData data, string path)
        {
            int index = path.IndexOf(RFConfig.ResourceRootPath);

            if (index != -1)
            {
                path = path.Substring(index + RFConfig.ResourceRootPath.Length);
            }
            string packagePath = PathConfig.NormalizePathSplash(path);

            if (packagePath.StartsWith("/"))
            {
                packagePath = packagePath.Substring(1);
            }
            string formatPath = PathConfig.NormalizePathSplash(data.RootPath);

            if (!string.IsNullOrEmpty(formatPath) &&
                !packagePath.StartsWith(formatPath, System.StringComparison.OrdinalIgnoreCase))
            {
                return(false);
            }
            MyRegex regex = MyRegex.Create(data.FileNameMatch);

            if (regex == null)
            {
                return(false);
            }
            return(regex.IsMatch(packagePath));
        }
Example #2
0
        public static MyRegex Create(string str)
        {
            MyRegex ret = null;

            if (ms_dict.TryGetValue(str, out ret))
            {
                return(ret);
            }
            ret = new MyRegex();

            string pattern = BuildPatternString(str);
            Regex  regex   = new Regex(pattern, RegexOptions.IgnoreCase);

            ret.m_regexs.Add(regex);

            ms_dict.Add(str, ret);
            return(ret);
        }