public static GameFolder FromPath(string dir, string dirName) { GameFolder folder = new GameFolder(dirName); foreach (string filePath in Directory.GetFiles(dir)) { string filename = Path.GetFileName(filePath); DataStream stream = new DataStream(filePath, FileMode.Open, FileAccess.ReadWrite); folder.AddFile(new GameFile(filename, stream)); } return folder; }
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); } }