public void InitLoadingMetaHeaderOnly(string filePath) { if (Scribe.mode != 0) { Log.Error("Called InitLoadingMetaHeaderOnly() but current mode is " + Scribe.mode); Scribe.ForceStop(); } try { using (StreamReader input = new StreamReader(filePath)) { using XmlTextReader xmlTextReader = new XmlTextReader(input); if (!ScribeMetaHeaderUtility.ReadToMetaElement(xmlTextReader)) { return; } using XmlReader reader = xmlTextReader.ReadSubtree(); XmlDocument xmlDocument = new XmlDocument(); xmlDocument.Load(reader); XmlElement xmlElement = xmlDocument.CreateElement("root"); xmlElement.AppendChild(xmlDocument.DocumentElement); curXmlParent = xmlElement; } Scribe.mode = LoadSaveMode.LoadingVars; } catch (Exception ex) { Log.Error("Exception while init loading meta header: " + filePath + "\n" + ex); ForceStop(); throw; } }
public static string GameVersionOf(FileInfo file) { if (!file.Exists) { throw new ArgumentException(); } try { using (StreamReader input = new StreamReader(file.FullName)) { using (XmlTextReader xmlTextReader = new XmlTextReader(input)) { if (ScribeMetaHeaderUtility.ReadToMetaElement(xmlTextReader) && xmlTextReader.ReadToDescendant("gameVersion")) { return(VersionControl.VersionStringWithoutRev(xmlTextReader.ReadString())); } } } } catch (Exception ex) { Log.Error("Exception getting game version of " + file.Name + ": " + ex.ToString()); } return(null); }
public void InitLoadingMetaHeaderOnly(string filePath) { if (Scribe.mode != LoadSaveMode.Inactive) { Log.Error("Called InitLoadingMetaHeaderOnly() but current mode is " + Scribe.mode); Scribe.ForceStop(); } try { using (StreamReader streamReader = new StreamReader(filePath)) { using (XmlTextReader xmlTextReader = new XmlTextReader(streamReader)) { if (!ScribeMetaHeaderUtility.ReadToMetaElement(xmlTextReader)) { return; } using (XmlReader xmlReader = xmlTextReader.ReadSubtree()) { XmlDocument xmlDocument = new XmlDocument(); xmlDocument.Load(xmlReader); XmlElement xmlElement = xmlDocument.CreateElement("root"); xmlElement.AppendChild(xmlDocument.DocumentElement); this.curXmlParent = xmlElement; } } } Scribe.mode = LoadSaveMode.LoadingVars; } catch (Exception ex) { Log.Error(string.Concat(new object[] { "Exception while init loading meta header: ", filePath, "\n", ex })); this.ForceStop(); throw; } }