public static PseudoFileSystem MakeFs(this IEnumerable <SwitchFsNca> ncas) { PseudoFileSystem ncaFs = new PseudoFileSystem(); foreach (SwitchFsNca nca in ncas) { string s = nca.Filename; while (s.EndsWith(".nca")) { s = s.Substring(0, s.IndexOf(".nca")); } ncaFs.Add($"/{s}.nca", nca.Nca.BaseStorage); } return(ncaFs); }
public static PseudoFileSystem MakeFs(this IEnumerable <FileInfo> files) { PseudoFileSystem fs = new PseudoFileSystem(); foreach (FileInfo file in files) { LocalFileSystem localfs = new LocalFileSystem(file.Directory.FullName); // clean up filename so it only ends with .nca, then map to actual name string s = file.Name; while (s.EndsWith(".nca")) { s = s.Substring(0, s.IndexOf(".nca")); } fs.Add($"/{s}.nca", $"/{file.Name}", localfs); } return(fs); }
private void ImportGameDataClicked(object sender, RoutedEventArgs e) { string filter = @" Any game data (*.xci,*.nca,*.nsp)|*.xci;*.nca;*.nsp| NX Card Image (*.xci)|*.xci| Nintendo Content Archive (*.nca)|*.nca| Nintendo Installable Package (*.nsp)|*.nsp ".FilterMultilineString(); FileInfo[] files = RequestOpenFilesFromUser(".*", filter, "Select game data..."); if (files == null) { return; } TaskManagerPage.Current.Queue.Submit(new RunTask("Processing imported game data...", new Task(() => { IEnumerable <FileInfo> ncas = files.Where((f) => { try { new Nca(HACGUIKeyset.Keyset, new LocalFile(f.FullName, OpenMode.Read).AsStorage()); return(true); } catch (Exception) { return(false); } }); IEnumerable <FileInfo> xcis = files.Except(ncas).Where((f) => { try { new Xci(HACGUIKeyset.Keyset, new LocalFile(f.FullName, OpenMode.Read).AsStorage()); return(true); } catch (Exception) { return(false); } }); IEnumerable <FileInfo> nsp = files.Except(ncas).Except(xcis).Where((f) => { try { new PartitionFileSystem(new LocalFile(f.FullName, OpenMode.Read).AsStorage()); return(true); } catch (Exception) { return(false); } }); List <SwitchFs> switchFilesystems = new List <SwitchFs>(); PseudoFileSystem ncaFs = new PseudoFileSystem(); foreach (FileInfo file in ncas) { LocalFileSystem fs = new LocalFileSystem(file.Directory.FullName); // clean up filename so it only ends with .nca, then map to actual name string s = file.Name; while (s.EndsWith(".nca")) { s = s.Substring(0, s.IndexOf(".nca")); } ncaFs.Add($"/{s}.nca", $"/{file.Name}", fs); } if (ncas.Any()) { switchFilesystems.Add(SwitchFs.OpenNcaDirectory(HACGUIKeyset.Keyset, ncaFs)); } foreach (FileInfo file in xcis) { Xci xci = new Xci(HACGUIKeyset.Keyset, new LocalFile(file.FullName, OpenMode.Read).AsStorage()); switchFilesystems.Add(SwitchFs.OpenNcaDirectory(HACGUIKeyset.Keyset, xci.OpenPartition(XciPartitionType.Secure))); } foreach (FileInfo file in nsp) { PartitionFileSystem fs = new PartitionFileSystem(new LocalFile(file.FullName, OpenMode.Read).AsStorage()); switchFilesystems.Add(SwitchFs.OpenNcaDirectory(HACGUIKeyset.Keyset, fs)); } foreach (SwitchFs fs in switchFilesystems) { DeviceService.FsView.LoadFileSystemAsync("Opening imported data...", () => fs, FSView.TitleSource.Imported, false); } }))); }