From 4789f79254aea21740e8bf96d1b129a748bdd002 Mon Sep 17 00:00:00 2001 From: Thog Date: Fri, 14 Feb 2020 23:07:22 +0100 Subject: [PATCH] Fix crash when first starting the emulator (#945) * Fix crash when first starting the emulator * Fix a nit --- Ryujinx/Program.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Ryujinx/Program.cs b/Ryujinx/Program.cs index 1f417f5a6..7ff2b64f7 100644 --- a/Ryujinx/Program.cs +++ b/Ryujinx/Program.cs @@ -43,7 +43,8 @@ namespace Ryujinx DiscordIntegrationModule.Initialize(); string localConfigurationPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Config.json"); - string globalConfigurationPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Ryujinx", "Config.json"); + string globalBasePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Ryujinx"); + string globalConfigurationPath = Path.Combine(globalBasePath, "Config.json"); // Now load the configuration as the other subsystems are now registered if (File.Exists(localConfigurationPath)) @@ -67,6 +68,9 @@ namespace Ryujinx // No configuration, we load the default values and save it on disk ConfigurationPath = globalConfigurationPath; + // Make sure to create the Ryujinx directory if needed. + Directory.CreateDirectory(globalBasePath); + ConfigurationState.Instance.LoadDefault(); ConfigurationState.Instance.ToFileFormat().SaveConfig(globalConfigurationPath); } @@ -75,9 +79,9 @@ namespace Ryujinx Application.Init(); - string appDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Ryujinx", "system", "prod.keys"); - string userProfilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".switch", "prod.keys"); - if (!File.Exists(appDataPath) && !File.Exists(userProfilePath) && !Migration.IsMigrationNeeded()) + string globalProdKeysPath = Path.Combine(globalBasePath, "system", "prod.keys"); + string userProfilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".switch", "prod.keys"); + if (!File.Exists(globalProdKeysPath) && !File.Exists(userProfilePath) && !Migration.IsMigrationNeeded()) { GtkDialog.CreateWarningDialog("Key file was not found", "Please refer to `KEYS.md` for more info"); }