using System; using System.IO; namespace ResBuilder { class UIResProcessor { public readonly string inputRoot; public readonly string outputRoot; public readonly string relativePath; public UIResProcessor(string inputRoot , string outputRoot, string relativePath) { this.inputRoot = inputRoot; this.outputRoot = outputRoot; this.relativePath = relativePath; } public void Execute() { var inputPath = Path.Combine(inputRoot , relativePath); var allFiles = Directory.GetFiles(inputPath, "*.*", SearchOption.AllDirectories); var binFiles = Array.FindAll(allFiles, (str) => str.EndsWith(".bin")); var pngFiles = Array.FindAll(allFiles, (str) => str.EndsWith(".png") || str.EndsWith(".jpg")); var xmlFiles = Array.FindAll(allFiles, (str) => { if (!str.EndsWith(".xml")) { return false; } var fileName = Path.ChangeExtension(str , "bin"); return Array.IndexOf(binFiles, fileName) == -1; }); var outputDir = Path.Combine(outputRoot, relativePath); if (Directory.Exists(outputDir)) { Directory.Delete(outputDir, true); } // -- 1 foreach (var f in binFiles) { var relativeFilePath = f.Substring(inputPath.Length + 1); var outputFilePath = Path.Combine(outputDir, relativeFilePath); var outDirName = Path.GetDirectoryName(outputFilePath); if (!Directory.Exists(outDirName)) { Directory.CreateDirectory(outDirName); } File.Copy(f, outputFilePath, true); } // -- 2 foreach (var f in pngFiles) { var relativeFilePath = f.Substring(inputPath.Length + 1); var outputFilePath = Path.Combine(outputDir, relativeFilePath); var outDirName = Path.GetDirectoryName(outputFilePath); if (!Directory.Exists(outDirName)) { Directory.CreateDirectory(outDirName); } File.Copy(f, outputFilePath, true); } foreach (var f in xmlFiles) { var relativeFilePath = f.Substring(inputPath.Length + 1); var outputFilePath = Path.Combine(outputDir, relativeFilePath); var outDirName = Path.GetDirectoryName(outputFilePath); if (!Directory.Exists(outDirName)) { Directory.CreateDirectory(outDirName); } File.Copy(f, outputFilePath , true); } } } }