/// <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); }
protected static string GetLogPath() { if (ApplicationUtil.IsGameTasksApp()) { return(Path.Combine(ApplicationUtil.GetAppDataPath(), "gametasks.log")); } return(Path.Combine(ApplicationUtil.GetAppDataPath(), "app.log")); }
/// <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>(); }
/// <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); } } }
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(); }
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 }
public static string GetTempFolder(string gameId) { string appData = ApplicationUtil.GetAppDataPath(); return(Path.Combine(appData, gameId)); }
public static string GetTempFolder(HandlerData game) { string appData = ApplicationUtil.GetAppDataPath(); return(Path.Combine(appData, "temp", game.GameID)); }
protected string GetUserProfilePath() { return(Path.Combine(ApplicationUtil.GetAppDataPath(), "userprofile.json")); }
public string GetJsGamesPath() { return(Path.Combine(ApplicationUtil.GetAppDataPath(), "games")); }
public string GetInstalledPackagePath() { return(Path.Combine(ApplicationUtil.GetAppDataPath(), "pkg\\installed")); }
public string GetPackageTmpPath() { return(Path.Combine(ApplicationUtil.GetAppDataPath(), "pkg\\tmp")); }