/// <summary> /// 获取当前目录下的文件夹递归文件编码 /// </summary> private void InspectFaceFolderEncoding() { foreach (var temp in FaceFolder.GetDirectories()) { var folder = new EncodingScrutatorFolder(temp, InspectFileWhiteListSetting, IncludeFileSetting) { //IncludeFileSetting = IncludeFileSetting, //InspectFileWhiteListSetting = InspectFileWhiteListSetting, SitpulationEncodingSetting = SitpulationEncodingSetting, _includeRegexFile = _includeRegexFile, //Parent = FaceFolder, Parent = this, Progress = Progress }; Folder.Add(folder); //不包含 if (InspectFileWhiteListSetting.FolderWhiteList.Any(t => String.Equals(t, temp.Name))) { folder.Ignore = true; } if (!folder.Ignore) { //递归 folder.InspectFolderEncoding(); } } }
/// <summary> /// 获取所有文件编码 /// </summary> private void InspectFileEncoding() { foreach (var temp in FaceFolder.GetFiles()) //.Select(temp=>new EncodingScrutatorFile(temp)))//.Where(PredicateInclude)) { //通知扫描到这个文件 var file = new EncodingScrutatorFile(temp) { //Parent = FaceFolder Parent = this }; Progress?.Report(file); File.Add(file); //文件是否包含 if (!PredicateInclude(temp)) { file.Ignore = true; } if (!file.Ignore) { new EncodingScrutator(file).InspectFileEncoding(); } } }
private void EnsureInitialized() { if (this.isInitialized) { return; } this.isInitialized = true; var sharedApi = Api.Shared; this.allHairFolders = sharedApi.GetFolderNamesInFolder(this.hairFolderPath).OrderBy(f => f).ToList(); this.allHairFolders.Insert(0, null); var allFacesFolders = sharedApi.GetFolderNamesInFolder(this.facesFolderPath).OrderBy(f => f).ToList(); if (allFacesFolders.Count == 0) { throw new Exception("There must be at least one face variant at " + this.facesFolderPath); } var allFacePresets = new Dictionary <string, FaceFolder>(); for (var index = 0; index < allFacesFolders.Count; index++) { var faceFolderName = allFacesFolders[index]; var faceFolderPath = this.facesFolderPath + faceFolderName; using (var availableFiles = sharedApi.GetFilePathsInFolder( faceFolderPath, includeSubfolders: false, stripFolderPathFromFilePaths: true, withoutExtensions: true)) { // TODO: rewrite to avoid LINQ var topIds = availableFiles.Where(_ => _.StartsWith("FrontTop")) .Select(_ => _.Substring("FrontTop".Length)) .ToArray(); var bottomIds = availableFiles.Where(_ => _.StartsWith("FrontBottom")) .Select(_ => _.Substring("FrontBottom".Length)) .ToArray(); if (topIds.Length == 0) { throw new Exception("There are must be at least one top face part at " + faceFolderPath); } if (bottomIds.Length == 0) { throw new Exception("There are must be at least one bottom face path " + faceFolderPath); } allFacePresets[faceFolderName] = new FaceFolder(faceFolderName, (ushort)index, topIds, bottomIds); } } this.allFaceFolders = allFacePresets; }