Ejemplo n.º 1
0
 public IFileSystem OpenFileSystem(NcaSectionType type, IntegrityCheckLevel integrityCheckLevel)
 {
     return(OpenFileSystem(Nca.GetSectionIndexFromType(type, Nca.Header.ContentType), integrityCheckLevel));
 }
Ejemplo n.º 2
0
 public SwitchFsNca(Nca nca)
 {
     Nca = nca;
 }
Ejemplo n.º 3
0
 public IStorage OpenStorage(NcaSectionType type, IntegrityCheckLevel integrityCheckLevel)
 {
     return(OpenStorage(Nca.GetSectionIndexFromType(type, Nca.Header.ContentType), integrityCheckLevel));
 }
Ejemplo n.º 4
0
        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);
                }
            }
        }