Exemplo n.º 1
0
        private void ReadRomfs(RomFsFileSystem romfs)
        {
            Storage header = null;
            Storage data   = null;

            foreach (var file in romfs.Files)
            {
                if (file.FullPath.Contains(".arh"))
                {
                    header = new FileStorage(romfs.OpenFile(file));
                }
                if (file.FullPath.Contains(".ard"))
                {
                    data = new FileStorage(romfs.OpenFile(file));
                }
                else
                {
                    Files.Add(new ArchiveFileInfo(romfs, file));
                }
            }

            if (header != null)
            {
                Files.AddRange((new ArchiveHeader(header, data)).Files.Where(x => x != null));
            }
        }
Exemplo n.º 2
0
        public Task <ImageSource> FindTitleIcon(Title title)
        {
            if (title.ControlNca != null)
            {
                NcaSection      meta      = title.ControlNca.Sections.FirstOrDefault(x => x?.Type == SectionType.Romfs);
                RomFsFileSystem controlFS = new RomFsFileSystem(title.ControlNca.OpenSection(meta.SectionNum, false, IntegrityCheckLevel.ErrorOnInvalid, false));
                DirectoryEntry  file      = controlFS.EnumerateEntries("icon_*.dat").FirstOrDefault();

                if (file != null)
                {
                    return(new Task <ImageSource>(() =>
                    {
                        try
                        {
                            JpegBitmapDecoder decoder = new JpegBitmapDecoder(controlFS.OpenFile(file.FullPath, OpenMode.Read).AsStream(), BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
                            decoder.Frames[0].Freeze();
                            return decoder.Frames[0];
                        } catch (Exception)
                        {
                            return null;
                        }
                    }));
                }
            }
            return(null);
        }
Exemplo n.º 3
0
        private void ReadControls()
        {
            foreach (Title title in Titles.Values.Where(x => x.ControlNca != null))
            {
                var   romfs   = new RomFsFileSystem(title.ControlNca.OpenSection(0, false, IntegrityCheckLevel.ErrorOnInvalid, true));
                IFile control = romfs.OpenFile("control.nacp", OpenMode.Read);

                title.Control = new Nacp(control.AsStream());

                foreach (NacpDescription desc in title.Control.Descriptions)
                {
                    if (!string.IsNullOrWhiteSpace(desc.Title))
                    {
                        title.Name = desc.Title;
                        break;
                    }
                }
            }
        }