1
0
Fork 0
mirror of https://github.com/Ryujinx/Ryujinx.git synced 2024-11-15 08:46:40 +00:00

Create a symlink to preserve back compat

Co-authored-by: Ac_K <Acoustik666@gmail.com>
This commit is contained in:
Candygoblen123 2023-01-15 11:53:11 -05:00
parent c3715e698d
commit f81e41737d
No known key found for this signature in database
GPG key ID: 577DA64EBEF10385

View file

@ -45,10 +45,10 @@ namespace Ryujinx.Common.Configuration
public static void Initialize(string baseDirPath) public static void Initialize(string baseDirPath)
{ {
string appDataPath = null; string appDataPath;
if (System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.OSX)) if (OperatingSystem.IsMacOS())
{ {
appDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "Library/Application Support"); appDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "Library", "Application Support");
} }
else else
{ {
@ -89,12 +89,20 @@ namespace Ryujinx.Common.Configuration
BaseDirPath = Path.GetFullPath(BaseDirPath); // convert relative paths BaseDirPath = Path.GetFullPath(BaseDirPath); // convert relative paths
// Copy .config dir to application support dir // NOTE: Copies the Ryujinx folder in `~/.config` to `~/Library/Application Support` if one is found
if (System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.OSX) && Mode == LaunchMode.UserProfile) // and a Ryujinx folder does not already exist in Application Support.
// Also creates a symlink from `~/.config/Ryujinx` to `~/Library/Application Support/Ryujinx` to preserve backwards compatibility.
// This should be removed in the future.
if (OperatingSystem.IsMacOS() && Mode == LaunchMode.UserProfile)
{ {
var oldConfigPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), DefaultBaseDir); string oldConfigPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), DefaultBaseDir);
if (Path.Exists(oldConfigPath) && !Path.Exists(BaseDirPath)) if (Path.Exists(oldConfigPath) && !Path.Exists(BaseDirPath))
{
CopyDirectory(oldConfigPath, BaseDirPath); CopyDirectory(oldConfigPath, BaseDirPath);
Directory.Delete(oldConfigPath, true);
Directory.CreateSymbolicLink(oldConfigPath, BaseDirPath);
}
} }
SetupBasePaths(); SetupBasePaths();
@ -113,7 +121,9 @@ namespace Ryujinx.Common.Configuration
var dir = new DirectoryInfo(sourceDir); var dir = new DirectoryInfo(sourceDir);
if (!dir.Exists) if (!dir.Exists)
{
throw new DirectoryNotFoundException($"Source directory not found: {dir.FullName}"); throw new DirectoryNotFoundException($"Source directory not found: {dir.FullName}");
}
DirectoryInfo[] subDirs = dir.GetDirectories(); DirectoryInfo[] subDirs = dir.GetDirectories();
Directory.CreateDirectory(destinationDir); Directory.CreateDirectory(destinationDir);
@ -121,15 +131,15 @@ namespace Ryujinx.Common.Configuration
foreach (FileInfo file in dir.GetFiles()) foreach (FileInfo file in dir.GetFiles())
{ {
if (file.Name == ".DS_Store") if (file.Name == ".DS_Store")
{
continue; continue;
string destFile = Path.Combine(destinationDir, file.Name); }
file.CopyTo(destFile); file.CopyTo(Path.Combine(destinationDir, file.Name));
} }
foreach (DirectoryInfo subDir in subDirs) foreach (DirectoryInfo subDir in subDirs)
{ {
string destDir = Path.Combine(destinationDir, subDir.Name); CopyDirectory(subDir.FullName, Path.Combine(destinationDir, subDir.Name));
CopyDirectory(subDir.FullName, destDir);
} }
} }