Beispiel #1
0
 public CardSpecXml(int size, int clockRate)
 {
     this.m_model = new CardSpecModel();
     if (size != XciInfo.InvalidRomSize && clockRate != XciInfo.InvalidClockRate)
     {
         XciUtils.CheckRomSizeAndClockRate(size, clockRate);
     }
     this.m_model.Size      = size.ToString();
     this.m_model.ClockRate = clockRate.ToString();
 }
        private static NintendoSubmissionPackageFileSystemInfo GetNspInfo(NintendoSubmissionPackageReader nspReader, KeyConfiguration keyConfig, ArchiveReconstructionUtils.GetContentInfoDelegate getContentInfoImpl, ArchiveReconstructionUtils.GetContentMetaInfoDelegate getContentMetaInfoImpl)
        {
            NintendoSubmissionPackageFileSystemInfo packageFileSystemInfo = new NintendoSubmissionPackageFileSystemInfo();

            packageFileSystemInfo.Version = (byte)0;
            foreach (Tuple <string, long> tuple in nspReader.ListFileInfo())
            {
                string fileName = tuple.Item1;
                long   fileSize = tuple.Item2;
                if (fileName.EndsWith(".cnmt.xml"))
                {
                    ContentMetaModel model = ArchiveReconstructionUtils.ReadXml <ContentMetaModel>(nspReader, fileName, fileSize);
                    string           type  = model.Type;
                    if (!(type == "Application"))
                    {
                        if (!(type == "Patch"))
                        {
                            if (type == "AddOnContent")
                            {
                                model = (ContentMetaModel)ArchiveReconstructionUtils.ReadXml <AddOnContentContentMetaModel>(nspReader, fileName, fileSize);
                            }
                        }
                        else
                        {
                            model = (ContentMetaModel)ArchiveReconstructionUtils.ReadXml <PatchContentMetaModel>(nspReader, fileName, fileSize);
                        }
                    }
                    else
                    {
                        model = (ContentMetaModel)ArchiveReconstructionUtils.ReadXml <ApplicationContentMetaModel>(nspReader, fileName, fileSize);
                    }
                    NintendoSubmissionPackageFileSystemInfo.EntryInfo entry = new NintendoSubmissionPackageFileSystemInfo.EntryInfo();
                    entry.Contents = new List <NintendoSubmissionPackageFileSystemInfo.ContentInfo>();
                    foreach (ContentModel content in model.ContentList)
                    {
                        if (!(content.Type == "Meta"))
                        {
                            NintendoSubmissionPackageFileSystemInfo.ContentInfo contentInfo = getContentInfoImpl(content);
                            entry.Contents.Add(contentInfo);
                        }
                    }
                    string contentMetaFileName = Path.GetFileNameWithoutExtension(fileName) + ".nca";
                    getContentMetaInfoImpl(ref entry, contentMetaFileName, model);
                    List <NintendoSubmissionPackageExtraData> list = nspReader.ListFileInfo().FindAll((Predicate <Tuple <string, long> >)(x =>
                    {
                        if (x.Item1.StartsWith(fileName.Replace(".cnmt.xml", "")))
                        {
                            return(x.Item1.EndsWith(".jpg"));
                        }
                        return(false);
                    })).Select <Tuple <string, long>, NintendoSubmissionPackageExtraData>((Func <Tuple <string, long>, NintendoSubmissionPackageExtraData>)(x =>
                    {
                        byte[] buffer = nspReader.ReadFile(x.Item1, 0L, x.Item2);
                        return(new NintendoSubmissionPackageExtraData(x.Item1, (ISource) new MemorySource(buffer, 0, buffer.Length)));
                    })).ToList <NintendoSubmissionPackageExtraData>();
                    entry.ExtraData = list;
                    packageFileSystemInfo.Entries.Add(entry);
                }
                if (fileName == "cardspec.xml")
                {
                    CardSpecModel cardSpecModel = ArchiveReconstructionUtils.ReadXml <CardSpecModel>(nspReader, fileName, fileSize);
                    packageFileSystemInfo.CardSize      = Convert.ToInt32(cardSpecModel.Size, 10);
                    packageFileSystemInfo.CardClockRate = Convert.ToInt32(cardSpecModel.ClockRate, 10);
                }
            }
            return(packageFileSystemInfo);
        }