Esempio n. 1
0
        /// <summary>
        /// Backups a file at the specified path for later retrieval
        /// </summary>
        /// <param name="game"></param>
        /// <param name="path"></param>
        /// <returns></returns>
        public BackupFile BackupFile(HandlerData game, string path)
        {
            string appData     = ApplicationUtil.GetAppDataPath();
            string gamePath    = Path.Combine(appData, game.GameID);
            string destination = Path.Combine(gamePath, Path.GetFileName(path));

            if (!File.Exists(path))
            {
                if (File.Exists(destination))
                {
                    // we f****d up and the backup exists? maybe, so restore
                    File.Copy(destination, path);
                }
            }
            else
            {
                if (File.Exists(destination))
                {
                    File.Delete(destination);
                }
                File.Copy(path, destination);
            }

            BackupFile bkp = new BackupFile(path, destination);

            backupFiles.Add(bkp);

            return(bkp);
        }
Esempio n. 2
0
 protected static string GetLogPath()
 {
     if (ApplicationUtil.IsGameTasksApp())
     {
         return(Path.Combine(ApplicationUtil.GetAppDataPath(), "gametasks.log"));
     }
     return(Path.Combine(ApplicationUtil.GetAppDataPath(), "app.log"));
 }
Esempio n. 3
0
        /// <summary>
        /// Begins a game session for backup
        /// </summary>
        /// <param name="game"></param>
        public void BeginBackup(HandlerData game)
        {
            string appData  = ApplicationUtil.GetAppDataPath();
            string gamePath = Path.Combine(appData, game.GameID);

            Directory.CreateDirectory(gamePath);

            backupFiles = new List <BackupFile>();
        }
Esempio n. 4
0
        /// <summary>
        /// Do a backup revert
        /// </summary>
        /// <param name="game"></param>
        public void ExecuteBackup(HandlerData game)
        {
            // we didnt backup anything
            if (backupFiles == null)
            {
                return;
            }

            string appData  = ApplicationUtil.GetAppDataPath();
            string gamePath = Path.Combine(appData, game.GameID);

            for (int i = 0; i < backupFiles.Count; i++)
            {
                BackupFile bkp = backupFiles[i];
                if (File.Exists(bkp.BackupPath))
                {
                    File.Delete(bkp.Source);
                    File.Move(bkp.BackupPath, bkp.Source);
                }
            }
        }
Esempio n. 5
0
        private void Initialize()
        {
            MetadataManager = new GameMetadataManager();

            string appData = ApplicationUtil.GetAppDataPath();

            Directory.CreateDirectory(appData);

            // create all default directories
            Directory.CreateDirectory(GetInstalledPackagePath());
            Directory.CreateDirectory(GetPackageTmpPath());

            PackageManager = new PackageManager();
            ModuleManager  = new ModuleManager();
            BackupManager  = new BackupManager();

            LoadUser();

            // TODO: Right now, build the DB each time we start up, later change
            RebuildGameDb();
        }
Esempio n. 6
0
        public void LogExceptionFile(string appDataPath, Exception ex)
        {
            string   local = ApplicationUtil.GetAppDataPath();
            DateTime now   = DateTime.Now;
            string   file  = string.Format("{0}{1}{2}_{3}{4}{5}", now.Day.ToString("00"), now.Month.ToString("00"), now.Year.ToString("0000"), now.Hour.ToString("00"), now.Minute.ToString("00"), now.Second.ToString("00")) + ".log";
            string   path  = Path.Combine(appDataPath, file);

            using (Stream stream = File.OpenWrite(path)) {
                using (StreamWriter writer = new StreamWriter(stream)) {
                    writer.WriteLine("[Header]");
                    writer.WriteLine(now.ToLongDateString());
                    writer.WriteLine(now.ToLongTimeString());
                    writer.WriteLine($"{Globals.Name} v{Globals.Version}");
                    writer.WriteLine("[PC Specs]");

                    writer.WriteLine("[Message]");
                    writer.WriteLine(ex.Message);
                    writer.WriteLine("[Stacktrace]");
                    writer.WriteLine(ex.StackTrace);

                    for (int i = 0; i < logCallbacks.Count; i++)
                    {
                        ILogNode node = logCallbacks[i];
                        try {
                            node.OnFailureLog(writer);
                        } catch {
                            writer.WriteLine("LogNode failed to log: " + node.ToString());
                        }
                    }
                }
            }

#if WINFORMS
            System.Windows.Forms.MessageBox.Show("Application crash. Log generated at Data/" + file);
            System.Windows.Forms.Application.Exit();
#endif
        }
Esempio n. 7
0
        public static string GetTempFolder(string gameId)
        {
            string appData = ApplicationUtil.GetAppDataPath();

            return(Path.Combine(appData, gameId));
        }
Esempio n. 8
0
        public static string GetTempFolder(HandlerData game)
        {
            string appData = ApplicationUtil.GetAppDataPath();

            return(Path.Combine(appData, "temp", game.GameID));
        }
Esempio n. 9
0
 protected string GetUserProfilePath()
 {
     return(Path.Combine(ApplicationUtil.GetAppDataPath(), "userprofile.json"));
 }
Esempio n. 10
0
 public string GetJsGamesPath()
 {
     return(Path.Combine(ApplicationUtil.GetAppDataPath(), "games"));
 }
Esempio n. 11
0
 public string GetInstalledPackagePath()
 {
     return(Path.Combine(ApplicationUtil.GetAppDataPath(), "pkg\\installed"));
 }
Esempio n. 12
0
 public string GetPackageTmpPath()
 {
     return(Path.Combine(ApplicationUtil.GetAppDataPath(), "pkg\\tmp"));
 }