public void ExportToFolder(string outFolder, string imageExtension, string modelExtension) { if (!Directory.Exists(outFolder)) { Directory.CreateDirectory(outFolder); } List <string> directChildrenExportedPaths = new List <string>(); foreach (ResourceNode entry in Children) { if (entry is ARCNode) { ((ARCNode)entry).ExtractToFolder(Path.Combine(outFolder, (entry.Name == null || entry.Name.Contains("<Null>", StringComparison.InvariantCultureIgnoreCase)) ? "Null" : entry.Name), imageExtension, modelExtension); } else if (entry is BRRESNode) { ((BRRESNode)entry).ExportToFolder(Path.Combine(outFolder, (entry.Name == null || entry.Name.Contains("<Null>", StringComparison.InvariantCultureIgnoreCase)) ? "Null" : entry.Name), imageExtension, modelExtension); } else if (entry is U8Node) { ((U8Node)entry).ExtractToFolder(Path.Combine(outFolder, (entry.Name == null || entry.Name.Contains("<Null>", StringComparison.InvariantCultureIgnoreCase)) ? "Null" : entry.Name), imageExtension, modelExtension); } else if (entry is U8FolderNode) { ((U8FolderNode)entry).ExportToFolder(Path.Combine(outFolder, (entry.Name == null || entry.Name.Contains("<Null>", StringComparison.InvariantCultureIgnoreCase)) ? "Null" : entry.Name), imageExtension, modelExtension); } else { if (entry.WorkingSource.Length == 0) { continue; } string ext = FileFilters.GetDefaultExportAllExtension(entry.GetType()); string path = Path.Combine(outFolder, entry.Name + ext); if (directChildrenExportedPaths.Contains(path)) { throw new Exception($"There is more than one node underneath {this.Name} with the name {entry.Name}."); } else { directChildrenExportedPaths.Add(path); entry.Export(path); } } } }
public void ReplaceFromFolder(string inFolder) { DirectoryInfo dir = new DirectoryInfo(inFolder); FileInfo[] files = dir.GetFiles(); DirectoryInfo[] dirs; foreach (ARCEntryNode entry in Children) { if (entry is ARCNode) { dirs = dir.GetDirectories(entry.Name); if (dirs.Length > 0) { ((ARCNode)entry).ReplaceFromFolder(dirs[0].FullName); continue; } } else if (entry is BRRESNode) { dirs = dir.GetDirectories(entry.Name); if (dirs.Length > 0) { ((BRRESNode)entry).ReplaceFromFolder(dirs[0].FullName); continue; } else { ((BRRESNode)entry).ReplaceFromFolder(inFolder); continue; } } else { string ext = FileFilters.GetDefaultExportAllExtension(entry.GetType()); foreach (FileInfo info in files) { if (info.Extension.Equals(ext, StringComparison.OrdinalIgnoreCase) && info.Name.Equals(entry.Name + ext, StringComparison.OrdinalIgnoreCase)) { entry.Replace(info.FullName); break; } } } } }
public void ExtractToFolder(string outFolder) { if (!Directory.Exists(outFolder)) { Directory.CreateDirectory(outFolder); } List <string> directChildrenExportedPaths = new List <string>(); foreach (ARCEntryNode entry in Children) { if (entry is ARCNode) { ((ARCNode)entry).ExtractToFolder(Path.Combine(outFolder, entry.Name)); } else if (entry is BRRESNode) { ((BRRESNode)entry).ExportToFolder(Path.Combine(outFolder, entry.Name)); } else { if (entry.WorkingSource.Length == 0) { continue; } string ext = FileFilters.GetDefaultExportAllExtension(entry.GetType()); string path = Path.Combine(outFolder, entry.Name + ext); if (directChildrenExportedPaths.Contains(path)) { throw new Exception($"There is more than one node underneath {this.Name} with the name {entry.Name}."); } else { directChildrenExportedPaths.Add(path); entry.Export(path); } } } }