mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-12-19 03:22:01 +00:00
Move Ryujinx Folder from ~/.config to ~/Library/Application Support on macOS (#4296)
* Move Ryujinx folder to Application Support on macOS
* Create a symlink to preserve back compat
Co-authored-by: Ac_K <Acoustik666@gmail.com>
* Remove extra whitespace
* Don’t create a symlink
* Update Ryujinx.Common/Configuration/AppDataManager.cs
Co-authored-by: Ac_K <Acoustik666@gmail.com>
* Revert "Don’t create a symlink"
This reverts commit 31752fe8ab
.
---------
Co-authored-by: Ac_K <Acoustik666@gmail.com>
This commit is contained in:
parent
edfd4d70c0
commit
e54f9dc4b4
1 changed files with 52 additions and 1 deletions
|
@ -45,7 +45,15 @@ namespace Ryujinx.Common.Configuration
|
||||||
|
|
||||||
public static void Initialize(string baseDirPath)
|
public static void Initialize(string baseDirPath)
|
||||||
{
|
{
|
||||||
string appDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
|
string appDataPath;
|
||||||
|
if (OperatingSystem.IsMacOS())
|
||||||
|
{
|
||||||
|
appDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "Library", "Application Support");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
appDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
|
||||||
|
}
|
||||||
|
|
||||||
if (appDataPath.Length == 0)
|
if (appDataPath.Length == 0)
|
||||||
{
|
{
|
||||||
|
@ -81,6 +89,21 @@ namespace Ryujinx.Common.Configuration
|
||||||
|
|
||||||
BaseDirPath = Path.GetFullPath(BaseDirPath); // convert relative paths
|
BaseDirPath = Path.GetFullPath(BaseDirPath); // convert relative paths
|
||||||
|
|
||||||
|
// NOTE: Moves the Ryujinx folder in `~/.config` to `~/Library/Application Support` if one is found
|
||||||
|
// 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)
|
||||||
|
{
|
||||||
|
string oldConfigPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), DefaultBaseDir);
|
||||||
|
if (Path.Exists(oldConfigPath) && !Path.Exists(BaseDirPath))
|
||||||
|
{
|
||||||
|
CopyDirectory(oldConfigPath, BaseDirPath);
|
||||||
|
Directory.Delete(oldConfigPath, true);
|
||||||
|
Directory.CreateSymbolicLink(oldConfigPath, BaseDirPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SetupBasePaths();
|
SetupBasePaths();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,6 +115,34 @@ namespace Ryujinx.Common.Configuration
|
||||||
Directory.CreateDirectory(KeysDirPath = Path.Combine(BaseDirPath, KeysDir));
|
Directory.CreateDirectory(KeysDirPath = Path.Combine(BaseDirPath, KeysDir));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void CopyDirectory(string sourceDir, string destinationDir)
|
||||||
|
{
|
||||||
|
var dir = new DirectoryInfo(sourceDir);
|
||||||
|
|
||||||
|
if (!dir.Exists)
|
||||||
|
{
|
||||||
|
throw new DirectoryNotFoundException($"Source directory not found: {dir.FullName}");
|
||||||
|
}
|
||||||
|
|
||||||
|
DirectoryInfo[] subDirs = dir.GetDirectories();
|
||||||
|
Directory.CreateDirectory(destinationDir);
|
||||||
|
|
||||||
|
foreach (FileInfo file in dir.GetFiles())
|
||||||
|
{
|
||||||
|
if (file.Name == ".DS_Store")
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
file.CopyTo(Path.Combine(destinationDir, file.Name));
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (DirectoryInfo subDir in subDirs)
|
||||||
|
{
|
||||||
|
CopyDirectory(subDir.FullName, Path.Combine(destinationDir, subDir.Name));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static string GetModsPath() => CustomModsPath ?? Directory.CreateDirectory(Path.Combine(BaseDirPath, DefaultModsDir)).FullName;
|
public static string GetModsPath() => CustomModsPath ?? Directory.CreateDirectory(Path.Combine(BaseDirPath, DefaultModsDir)).FullName;
|
||||||
public static string GetSdModsPath() => CustomSdModsPath ?? Directory.CreateDirectory(Path.Combine(BaseDirPath, DefaultSdcardDir, "atmosphere")).FullName;
|
public static string GetSdModsPath() => CustomSdModsPath ?? Directory.CreateDirectory(Path.Combine(BaseDirPath, DefaultSdcardDir, "atmosphere")).FullName;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue