public static void Initialize(string titleIdText, string displayVersion, bool enabled) { Wait(); ClearMemoryStreams(); PtcJumpTable.Clear(); PtcProfiler.Stop(); PtcProfiler.Wait(); PtcProfiler.ClearEntries(); if (String.IsNullOrEmpty(titleIdText) || titleIdText == TitleIdTextDefault) { TitleIdText = TitleIdTextDefault; DisplayVersion = DisplayVersionDefault; CachePathActual = string.Empty; CachePathBackup = string.Empty; Disable(); return; } Logger.PrintInfo(LogClass.Ptc, $"Initializing Profiled Persistent Translation Cache (enabled: {enabled})."); TitleIdText = titleIdText; DisplayVersion = !String.IsNullOrEmpty(displayVersion) ? displayVersion : DisplayVersionDefault; if (enabled) { string workPathActual = Path.Combine(_basePath, "games", TitleIdText, "cache", "cpu", ActualDir); string workPathBackup = Path.Combine(_basePath, "games", TitleIdText, "cache", "cpu", BackupDir); if (!Directory.Exists(workPathActual)) { Directory.CreateDirectory(workPathActual); } if (!Directory.Exists(workPathBackup)) { Directory.CreateDirectory(workPathBackup); } CachePathActual = Path.Combine(workPathActual, DisplayVersion); CachePathBackup = Path.Combine(workPathBackup, DisplayVersion); Enable(); PreLoad(); PtcProfiler.PreLoad(); } else { CachePathActual = string.Empty; CachePathBackup = string.Empty; Disable(); } }
private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { Close(); PtcProfiler.Stop(); if (e.IsTerminating) { Dispose(); PtcProfiler.Dispose(); } }