Beispiel #1
0
        private bool CheckAccessToFiles()
        {
            foreach (var filePath in Directory.GetFiles(TargetDir, "*", SearchOption.TopDirectoryOnly))
            {
                if (filePath == MySession.Static.ThumbPath)
                {
                    continue;
                }

                if (!MyFileSystem.CheckFileWriteAccess(filePath))
                {
                    MySandboxGame.Log.WriteLine(string.Format("Couldn't access file '{0}'.", Path.GetFileName(filePath)));
                    return(false);
                }
            }
            return(true);
        }
Beispiel #2
0
        private static MyWorldInfo LoadWorldInfo(string sessionPath)
        {
            MyWorldInfo worldInfo = null;

            try
            {
                System.Xml.Linq.XDocument doc = null;
                string checkpointFile         = Path.Combine(sessionPath, CHECKPOINT_FILE);
                if (!File.Exists(checkpointFile))
                {
                    return(null);
                }

                using (var stream = MyFileSystem.OpenRead(checkpointFile).UnwrapGZip())
                {
                    doc = XDocument.Load(stream);
                }
                Debug.Assert(doc != null);
                var root = doc.Root;
                Debug.Assert(root != null);

                var session      = root.Element("SessionName");
                var description  = root.Element("Description");
                var lastSaveTime = root.Element("LastSaveTime");
                var lastLoadTime = root.Element("LastLoadTime");
                var worldId      = root.Element("WorldID");
                var workshopId   = root.Element("WorkshopId");
                var briefing     = root.Element("Briefing");

                worldInfo = new MyWorldInfo();

                if (session != null)
                {
                    worldInfo.SessionName = session.Value;
                }
                if (description != null)
                {
                    worldInfo.Description = description.Value;
                }
                if (lastSaveTime != null)
                {
                    DateTime.TryParse(lastSaveTime.Value, out worldInfo.LastSaveTime);
                }
                if (lastLoadTime != null)
                {
                    DateTime.TryParse(lastLoadTime.Value, out worldInfo.LastLoadTime);
                }

                if (workshopId != null)
                {
                    ulong tmp;
                    if (ulong.TryParse(workshopId.Value, out tmp))
                    {
                        worldInfo.WorkshopId = tmp;
                    }
                }
                if (briefing != null)
                {
                    worldInfo.Briefing = briefing.Value;
                }
            }
            catch (Exception ex)
            {
                MySandboxGame.Log.WriteLine(ex);
            }
            return(worldInfo);
        }