private void ReadControls() { foreach (Title title in Titles.Values.Where(x => x.ControlNca != null)) { var romfs = new Romfs(title.ControlNca.OpenSection(0, false, IntegrityCheckLevel.ErrorOnInvalid, true)); IStorage control = romfs.OpenFile("/control.nacp"); title.Control = new Nacp(control.AsStream()); foreach (NacpDescription desc in title.Control.Descriptions) { if (!string.IsNullOrWhiteSpace(desc.Title)) { title.Name = desc.Title; break; } } } }
public static void Extract(this Romfs romfs, string outDir, IProgressReport logger = null) { foreach (RomfsFile file in romfs.Files) { IStorage storage = romfs.OpenFile(file); string outName = outDir + file.FullPath; string dir = Path.GetDirectoryName(outName); if (!string.IsNullOrWhiteSpace(dir)) { Directory.CreateDirectory(dir); } using (var outFile = new FileStream(outName, FileMode.Create, FileAccess.ReadWrite)) { logger?.LogMessage(file.FullPath); storage.CopyToStream(outFile, storage.Length, logger); } } }