private static byte[] MakeApplicationControlPropertyBytes(string metaPath) { XmlDocument xmlDocument = new XmlDocument(); xmlDocument.Load(metaPath); XmlNode xmlNode = xmlDocument.SelectSingleNode("//Application"); ApplicationControlPropertyModel controlPropertyModel = (ApplicationControlPropertyModel) new XmlSerializer(typeof(ApplicationControlPropertyModel)).Deserialize(XmlReader.Create((TextReader) new StringReader(xmlNode == null ? "<Application></Application>" : xmlNode.OuterXml))); DotMetaReader dotMetaReader = new DotMetaReader(metaPath); long applicationId = (long)dotMetaReader.GetApplicationId(); long aocBaseId = (long)IdConverter.ConvertToAocBaseId(dotMetaReader.GetCoreId()); return(controlPropertyModel.MakePropertyBytes((ulong)applicationId, (ulong)aocBaseId)); }
public NintendoSubmissionPackageFileSystemInfo GetFileSystemInfo() { NintendoSubmissionPackageFileSystemInfo packageFileSystemInfo = new NintendoSubmissionPackageFileSystemInfo(); using (StreamReader streamReader = new StreamReader(this.m_adfPath, Encoding.UTF8)) { YamlStream yamlStream = new YamlStream(); yamlStream.Load((TextReader)streamReader); YamlSequenceNode child1; try { YamlMappingNode rootNode = (YamlMappingNode)yamlStream.Documents[0].RootNode; if (((YamlScalarNode)rootNode.Children[(YamlNode) new YamlScalarNode("formatType")]).Value != "NintendoSubmissionPackage") { throw new ArgumentException(); } YamlScalarNode child2 = (YamlScalarNode)rootNode.Children[(YamlNode) new YamlScalarNode("version")]; child1 = (YamlSequenceNode)rootNode.Children[(YamlNode) new YamlScalarNode("entries")]; packageFileSystemInfo.Version = Convert.ToByte(child2.Value); } catch { throw new ArgumentException("invalid format .adf file."); } foreach (YamlMappingNode yamlMappingNode1 in child1) { NintendoSubmissionPackageFileSystemInfo.EntryInfo entryInfo = new NintendoSubmissionPackageFileSystemInfo.EntryInfo(); entryInfo.Contents = new List <NintendoSubmissionPackageFileSystemInfo.ContentInfo>(); YamlNode child2 = yamlMappingNode1.Children[(YamlNode) new YamlScalarNode("contents")]; if (child2 is YamlSequenceNode) { foreach (YamlMappingNode yamlMappingNode2 in (YamlSequenceNode)child2) { NintendoSubmissionPackageFileSystemInfo.ContentInfo contentInfo = new NintendoSubmissionPackageFileSystemInfo.ContentInfo(); string empty1 = string.Empty; string empty2 = string.Empty; foreach (KeyValuePair <YamlNode, YamlNode> keyValuePair in yamlMappingNode2) { string str = ((YamlScalarNode)keyValuePair.Key).Value; if (!(str == "type")) { if (!(str == "contentType")) { if (!(str == "path")) { throw new ArgumentException("invalid format .adf file. invalid key is specified\n" + yamlMappingNode2.ToString()); } empty2 = ((YamlScalarNode)keyValuePair.Value).Value; } else { contentInfo.ContentType = ((YamlScalarNode)keyValuePair.Value).Value; } } else { empty1 = ((YamlScalarNode)keyValuePair.Value).Value; } } if (empty2 == null) { throw new ArgumentException("invalid format .adf file. \"path\" is not specified\n" + yamlMappingNode2.ToString()); } if (empty1 == "format") { NintendoContentAdfReader contentAdfReader = new NintendoContentAdfReader(empty2); contentInfo.FsInfo = (Nintendo.Authoring.FileSystemMetaLibrary.FileSystemInfo)contentAdfReader.GetFileSystemInfo(); } else { if (!(empty1 == "file")) { throw new ArgumentException("invalid format .adf file. unknown \"type\" is specified\n" + yamlMappingNode2.ToString()); } FileInfo fileInfo = new FileInfo(empty2); contentInfo.Source = (ISource) new FileSource(empty2, 0L, fileInfo.Length); } entryInfo.Contents.Add(contentInfo); } } List <Tuple <string, string> > iconList = new List <Tuple <string, string> >(); List <Tuple <string, string> > nxIconList = new List <Tuple <string, string> >(); uint maxNxIconSize = 102400; foreach (KeyValuePair <YamlNode, YamlNode> keyValuePair in yamlMappingNode1) { switch (((YamlScalarNode)keyValuePair.Key).Value) { case "contents": continue; case "icon": using (IEnumerator <YamlNode> enumerator = ((YamlSequenceNode)keyValuePair.Value).GetEnumerator()) { while (enumerator.MoveNext()) { YamlMappingNode current = (YamlMappingNode)enumerator.Current; string str1 = ((YamlScalarNode)current.Children[(YamlNode) new YamlScalarNode("language")]).Value; string str2 = ((YamlScalarNode)current.Children[(YamlNode) new YamlScalarNode("path")]).Value; iconList.Add(new Tuple <string, string>(str1, str2)); } continue; } case "keyIndex": entryInfo.KeyIndex = int.Parse(((YamlScalarNode)keyValuePair.Value).Value); continue; case "metaFilePath": entryInfo.MetaFilePath = ((YamlScalarNode)keyValuePair.Value).Value; continue; case "metaType": entryInfo.MetaType = ((YamlScalarNode)keyValuePair.Value).Value; continue; case "nxIcon": using (IEnumerator <YamlNode> enumerator = ((YamlSequenceNode)keyValuePair.Value).GetEnumerator()) { while (enumerator.MoveNext()) { YamlMappingNode current = (YamlMappingNode)enumerator.Current; string str1 = ((YamlScalarNode)current.Children[(YamlNode) new YamlScalarNode("language")]).Value; string str2 = ((YamlScalarNode)current.Children[(YamlNode) new YamlScalarNode("path")]).Value; nxIconList.Add(new Tuple <string, string>(str1, str2)); } continue; } case "nxIconMaxSize": maxNxIconSize = uint.Parse(((YamlScalarNode)keyValuePair.Value).Value); continue; default: throw new ArgumentException("invalid format .adf file. invalid key is specified\n" + yamlMappingNode1.ToString()); } } if (entryInfo.MetaFilePath == null) { throw new ArgumentException(); } Tuple <int, int> cardSpec = new DotMetaReader(entryInfo.MetaFilePath).GetCardSpec(); if (cardSpec != null) { packageFileSystemInfo.CardSize = cardSpec.Item1; packageFileSystemInfo.CardClockRate = cardSpec.Item2; } else { Log.Info("\"CardSpec\" is not specified by .meta file. Size and ClockRate will be calculated automatically."); } entryInfo.ExtraData = this.CreateExtraSource(iconList, nxIconList, maxNxIconSize); packageFileSystemInfo.Entries.Add(entryInfo); } } return(packageFileSystemInfo); }
private static ContentMetaDescriptor ExtractContentMetaDescriptor(string type, string metaPath, List <NintendoContentInfo> contentInfoList) { ulong applicationId = 0; byte attributes = 0; NintendoExtendedHeader extendedHeader = (NintendoExtendedHeader)null; List <NintendoContentMetaInfo> contentMetaInfoList = new List <NintendoContentMetaInfo>(); uint num1 = NintendoContentMetaBase.GetDefaultDownloadSystemVersion(); ulong id; uint version; if (type.Equals("SystemUpdate")) { ContentMetaModel contentMeta1 = NintendoContentMetaBase.GetDeserializedModel <SystemUpdateModel>(metaPath, false).ContentMeta; if (contentMeta1.Type != "SystemUpdate") { throw new ArgumentException("The content meta type is not SystemUpdate."); } id = contentMeta1.GetUInt64Id(); version = contentMeta1.Version; foreach (ContentMetaModel contentMeta2 in contentMeta1.ContentMetaList) { contentMetaInfoList.Add(new NintendoContentMetaInfo(contentMeta2.Type, contentMeta2.GetUInt64Id(), contentMeta2.Version, (byte)ContentMetaAttributeExtension.FromStringList((IEnumerable <string>)contentMeta2.AttributeList))); } } else { DotMetaReader dotMetaReader = new DotMetaReader(metaPath); id = dotMetaReader.GetContentMetaId(); version = dotMetaReader.GetVersion(); attributes = dotMetaReader.GetContentMetaAttributes(); num1 = dotMetaReader.GetRequiredDownloadSystemVersion().GetValueOrDefault(num1); if (!(type == "Application")) { if (!(type == "AddOnContent")) { if (type == "Patch") { applicationId = dotMetaReader.GetApplicationId(); uint?requiredSystemVersion1 = dotMetaReader.GetRequiredSystemVersion(); uint requiredSystemVersion2 = requiredSystemVersion1.HasValue ? requiredSystemVersion1.Value : NintendoContentMeta.GetRequiredSystemVersion(); extendedHeader = (NintendoExtendedHeader) new NintendoPatchExtendedHeader(dotMetaReader.GetApplicationId(), requiredSystemVersion2); version = NintendoContentMetaBase.ShiftVersion(version, "Patch"); } } else { applicationId = dotMetaReader.GetApplicationId(); extendedHeader = (NintendoExtendedHeader) new NintendoAddOnContentExtendedHeader(dotMetaReader.GetApplicationId(), dotMetaReader.GetRequiredApplicationVersion(), dotMetaReader.GetAddOnContentTag()); version = NintendoContentMetaBase.ShiftVersion(version, "AddOnContent"); } } else { long num2 = (long)id + 2048L; uint?requiredSystemVersion = dotMetaReader.GetRequiredSystemVersion(); int num3 = requiredSystemVersion.HasValue ? (int)requiredSystemVersion.Value : (int)NintendoContentMeta.GetRequiredSystemVersion(); extendedHeader = (NintendoExtendedHeader) new NintendoApplicationExtendedHeader((ulong)num2, (uint)num3); version = NintendoContentMetaBase.ShiftVersion(version, "Application"); } } return(new ContentMetaDescriptor(type, id, version, attributes, applicationId, num1, contentInfoList, contentMetaInfoList, extendedHeader, new byte[NintendoContentMeta.GetDigestSize()])); }