private void OpenAllNcas() { string[] files = Fs.GetFileSystemEntries(ContentsDir, "*.nca", SearchOption.AllDirectories); foreach (string file in files) { Nca nca = null; try { bool isNax0; Stream stream = OpenSplitNcaStream(Fs, file); if (stream == null) { continue; } using (var reader = new BinaryReader(stream, Encoding.Default, true)) { stream.Position = 0x20; isNax0 = reader.ReadUInt32() == 0x3058414E; // NAX0 stream.Position = 0; } if (isNax0) { string sdPath = "/" + Util.GetRelativePath(file, ContentsDir).Replace('\\', '/'); var nax0 = new Nax0(Keyset, stream, sdPath, false); nca = new Nca(Keyset, nax0.Stream, false); } else { nca = new Nca(Keyset, stream, false); } nca.NcaId = Path.GetFileNameWithoutExtension(file); string extension = nca.Header.ContentType == ContentType.Meta ? ".cnmt.nca" : ".nca"; nca.Filename = nca.NcaId + extension; } catch (MissingKeyException ex) { if (ex.Name == null) { Console.WriteLine($"{ex.Message} File:\n{file}"); } else { string name = ex.Type == KeyType.Title ? $"Title key for rights ID {ex.Name}" : ex.Name; Console.WriteLine($"{ex.Message}\nKey: {name}\nFile: {file}"); } } catch (Exception ex) { Console.WriteLine($"{ex.Message} File: {file}"); } if (nca?.NcaId != null) { Ncas.Add(nca.NcaId, nca); } } }
public long GetSize() { return(Ncas.Sum(x => x.Nca.Header.NcaSize)); }