/// <summary> /// Determines if the given archive is a valid PFP. /// </summary> /// <param name="p_arcPFP">The archive to validate as a PFP.</param> /// <returns> /// An error string describing why the specified file is not a valid PFP, or /// <lang langref="null" /> if the given archive is a valid PFP. /// </returns> protected static string ValidatePFP(Archive p_arcPFP) { if (!p_arcPFP.ContainsFile("metadata.xml")) { return "Missing metadata.xml file."; } var xmlMeta = new XmlDocument(); using (var msmMeta = new MemoryStream(p_arcPFP.GetFileContents("metadata.xml"))) { xmlMeta.Load(msmMeta); msmMeta.Close(); } var xndSources = xmlMeta.SelectSingleNode("premadeFomodPack/sources"); foreach (XmlNode xndSource in xndSources.ChildNodes) { if ((xndSource.Attributes["name"] == null) || String.IsNullOrEmpty(xndSource.Attributes["name"].Value) || (xndSource.Attributes["url"] == null) || String.IsNullOrEmpty(xndSource.Attributes["url"].Value)) { return "Invalid metadata.xml file."; } } return null; }
/// <summary> /// Determines if the given archive is a valid PFP. /// </summary> /// <param name="p_arcPFP">The archive to validate as a PFP.</param> /// <returns> /// An error string describing why the specified file is not a valid PFP, or /// <lang langref="null" /> if the given archive is a valid PFP. /// </returns> protected static string ValidatePFP(Archive p_arcPFP) { if (!p_arcPFP.ContainsFile("metadata.xml")) { return("Missing metadata.xml file."); } var xmlMeta = new XmlDocument(); using (var msmMeta = new MemoryStream(p_arcPFP.GetFileContents("metadata.xml"))) { xmlMeta.Load(msmMeta); msmMeta.Close(); } var xndSources = xmlMeta.SelectSingleNode("premadeFomodPack/sources"); foreach (XmlNode xndSource in xndSources.ChildNodes) { if ((xndSource.Attributes["name"] == null) || String.IsNullOrEmpty(xndSource.Attributes["name"].Value) || (xndSource.Attributes["url"] == null) || String.IsNullOrEmpty(xndSource.Attributes["url"].Value)) { return("Invalid metadata.xml file."); } } return(null); }
/// <summary> /// Determines if the FOMod contains the given file. /// </summary> /// <remarks> /// This method accounts for the <see cref="PathPrefix" />. /// </remarks> /// <param name="p_strPath">The filename whose existence in the FOMod is to be determined.</param> /// <returns><lang langref="true" /> if the specified file is in the FOMod; <lang langref="false" /> otherwise.</returns> public bool ContainsFile(string p_strPath) { var strPath = p_strPath.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar); strPath = strPath.Trim(Path.DirectorySeparatorChar); if (m_dicMovedArchiveFiles.ContainsKey(strPath)) { return(true); } if (FomodFile.ContainsFile(GetPrefixAdjustedPath(strPath))) { return(true); } return((m_arcCacheFile != null) && m_arcCacheFile.ContainsFile(GetPrefixAdjustedPath(strPath))); }