mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-12-12 22:36:59 +00:00
Merge branch ryujinx:master into input-mapping-simplification
This commit is contained in:
commit
16d0e55fba
3 changed files with 43 additions and 0 deletions
|
|
@ -233,6 +233,8 @@ namespace Ryujinx.Ava
|
|||
{
|
||||
Logger.Warning?.PrintMsg(LogClass.Application, $"Failed to load config! Loading the default config instead.\nFailed config location: {ConfigurationPath}");
|
||||
|
||||
ConfigurationFileFormat.RenameInvalidConfigFile(ConfigurationPath);
|
||||
|
||||
ConfigurationState.Instance.LoadDefault();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,9 @@ using Ryujinx.Common.Configuration.Multiplayer;
|
|||
using Ryujinx.Common.Logging;
|
||||
using Ryujinx.Common.Utilities;
|
||||
using Ryujinx.HLE;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace Ryujinx.Ava.Systems.Configuration
|
||||
{
|
||||
|
|
@ -510,6 +512,43 @@ namespace Ryujinx.Ava.Systems.Configuration
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Renames the configuration file when it is deemed invalid
|
||||
/// </summary>
|
||||
/// <param name="path">The path to the invalid JSON configuration file</param>
|
||||
/// <returns>The path of the renamed invalid JSON configuration file, or null if the rename failed</returns>
|
||||
public static string RenameInvalidConfigFile(string path)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(path) || !File.Exists(path))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
string directory = Path.GetDirectoryName(path) ?? string.Empty;
|
||||
string originalFileName = Path.GetFileName(path);
|
||||
if (string.IsNullOrWhiteSpace(originalFileName))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
string renamedFileName = $"{originalFileName}.{DateTime.Now:yyyy-MM-dd_HH-mm-ss}.invalid";
|
||||
string renamedPath = string.IsNullOrEmpty(directory) ? renamedFileName : Path.Combine(directory, renamedFileName);
|
||||
|
||||
File.Move(path, renamedPath, overwrite: false);
|
||||
|
||||
Logger.Warning?.PrintMsg(LogClass.Application, $"Invalid configuration renamed to: {renamedPath}");
|
||||
|
||||
return renamedPath;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Error?.PrintMsg(LogClass.Application, $"Failed to rename invalid configuration file \"{path}\": {ex}");
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Save a configuration file to disk
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@ namespace Ryujinx.Ava.Systems.Configuration
|
|||
{
|
||||
RyuLogger.Warning?.Print(LogClass.Application, $"Unsupported configuration version {cff.Version}, loading default.");
|
||||
|
||||
ConfigurationFileFormat.RenameInvalidConfigFile(configurationFilePath);
|
||||
|
||||
LoadDefault();
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue