public CardSpecXmlSource(NintendoSubmissionPackageFileSystemInfo nspInfo, KeyConfiguration config) { NintendoSubmissionPackageFileSystemInfo uppInfo = nspInfo; XciSizeInfo xciSize = ProdEncryptedXciArchive.CalculateXciSize(nspInfo, uppInfo, (NintendoSubmissionPackageFileSystemInfo)null, config); int romSize = XciUtils.GetRomSize(xciSize.TotalSize); if (romSize == XciInfo.InvalidRomSize) { Log.Warning("This nsp can't be published as a game card title because its size exceed the maximum size of the game card."); } if (nspInfo.CardSize == 0 || nspInfo.CardClockRate == 0) { if (romSize == XciInfo.InvalidRomSize) { nspInfo.CardSize = XciInfo.InvalidRomSize; nspInfo.CardClockRate = XciInfo.InvalidClockRate; } else { nspInfo.CardSize = romSize; nspInfo.CardClockRate = XciUtils.GetClockRate(nspInfo.CardSize); } } else if (romSize != XciInfo.InvalidRomSize && nspInfo.CardSize < romSize) { throw new ArgumentException(string.Format("This nsp requires CardSpec/Size = {0}, though it is set as {1}.", (object)romSize, (object)nspInfo.CardSize)); } if (romSize != XciInfo.InvalidRomSize) { Log.Info(string.Format("CardSize: {0} (GB), UserArea Used: {1}/{2} (bytes)", (object)romSize, (object)(xciSize.TotalSize - (XciInfo.UpdatePartitionLimitSize + 65536L)), (object)(XciUtils.GetAvailableAreaSize(romSize) - (XciInfo.UpdatePartitionLimitSize + 65536L)))); } byte[] bytes = new CardSpecXml(nspInfo.CardSize, nspInfo.CardClockRate).GetBytes(); this.m_source = (ISource) new MemorySource(bytes, 0, bytes.Length); this.Size = this.m_source.Size; }
internal static int GetRomSize(long xciSize) { IEnumerable <int> source = ((IEnumerable <int>)XciInfo.RomSizeTable).Where <int>((Func <int, bool>)(x => XciUtils.GetAvailableAreaSize(x) >= xciSize)); if (!source.Any <int>()) { return(XciInfo.InvalidRomSize); } return(source.First <int>()); }