/** * 获得整个根目录结构下的所有文件地址 * */ public static Dictionary <string, int> getPathFiles(string path, AssetRegexType regexType) { Dictionary <string, int> files = new Dictionary <string, int>(); string regex = RegexUtility.generateRegex(regexType); inputFiles(path, files, regex); string[] pathsList = Directory.GetDirectories(path); for (int i = 0; i < pathsList.Length; i++) { inputPathFiles(pathsList[i], files, regex); } return(files); }
/** * 通过传入的type生成表达式 * */ public static string generateRegex(AssetRegexType regexType) { string regexString = @"[.]("; int regexInt = (int)regexType; foreach (KeyValuePair <int, string> kv in regex) { if ((regexInt & kv.Key) == kv.Key) { if (regexString == @"[.](") { regexString += kv.Value; } else { regexString += "|" + kv.Value; } } } regexString = regexString + ")$"; return(regexString); }