public static void Main(string[] args) { args = new string[] { "/home/benito/workdir/Algoritmos/AiroRom/Games/Layton4/Layton4/bin/Debug/" }; if (args.Length < 1) { return; } string executableDir = args [0]; var root = GameFolderFactory.FromPath(executableDir); FileManager.Initialize(root, new FileInfoCollection()); GameFolder validFiles = new GameFolder("layton"); foreach (var file in root.Files) { var container = file as GameFile; if (container == null || !container.Name.EndsWith(".fa")) { continue; } container.SetFormat <Gfsa>(); validFiles.AddFile(container); } ReadAll(validFiles); ExtractFolder(args[0], validFiles); }
private static void TestNdsRomRead(string romPath, string filePath, string outPath) { DataStream romStream = new DataStream(romPath, FileMode.Open, FileAccess.Read); Format romFormat = FileManager.GetFormat("Rom"); GameFolder main = new GameFolder("main"); GameFile rom = new GameFile(Path.GetFileName(romPath), romStream, romFormat); main.AddFile(rom); romFormat.Initialize(rom); XDocument xmlGame = new XDocument(); // TODO: Replace with ExampleGame.xml xmlGame.Add(new XElement("GameInfo", new XElement("Files"))); FileManager.Initialize(main, FileInfoCollection.FromXml(xmlGame)); GameFile file = FileManager.GetInstance().RescueFile(filePath); if (file != null) { file.Stream.WriteTo(outPath); } romStream.Dispose(); }
private void CreateTree(GameFolder currentFolder, GameFile[] listFile) { int folderId = ((ushort)currentFolder.Tags["Id"] > 0x0FFF) ? (ushort)currentFolder.Tags["Id"] & 0x0FFF : 0; // Add files foreach (ElementInfo fileInfo in this.tables[folderId].Files) { listFile[fileInfo.Id].Name = fileInfo.Name; currentFolder.AddFile(listFile[fileInfo.Id]); } // Add subfolders foreach (ElementInfo folderInfo in this.tables[folderId].Folders) { GameFolder subFolder = new GameFolder(folderInfo.Name); subFolder.Tags["Id"] = folderInfo.Id; this.CreateTree(subFolder, listFile); currentFolder.AddFolder(subFolder); } }