From 8381bc7220598bbb69dbd56f4304ae1add7bc884 Mon Sep 17 00:00:00 2001 From: TSR Berry <20988865+TSRBerry@users.noreply.github.com> Date: Wed, 31 Jul 2024 19:40:30 +0200 Subject: [PATCH] temp: Attempt to solve missing paths + add logging --- src/Ryujinx.Common/Utilities/FileSystemUtils.cs | 15 +++++++++++++-- src/Ryujinx.HLE/FileSystem/ContentPath.cs | 8 ++++---- src/Ryujinx.HLE/FileSystem/VirtualFileSystem.cs | 4 ++-- .../Configuration/ConfigurationFileFormat.cs | 4 ++-- 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/Ryujinx.Common/Utilities/FileSystemUtils.cs b/src/Ryujinx.Common/Utilities/FileSystemUtils.cs index 50c2a2b879..fb487e0a2d 100644 --- a/src/Ryujinx.Common/Utilities/FileSystemUtils.cs +++ b/src/Ryujinx.Common/Utilities/FileSystemUtils.cs @@ -1,3 +1,4 @@ +using Ryujinx.Common.Logging; using System.Collections.Generic; using System.IO; using System.Linq; @@ -59,9 +60,15 @@ namespace Ryujinx.Common.Utilities if (pathInfo.Exists) { - return pathInfo.ResolveLinkTarget(true)?.FullName ?? pathInfo.FullName; + var fullPath = pathInfo.ResolveLinkTarget(true)?.FullName ?? pathInfo.FullName; + + Logger.Warning?.Print(LogClass.Application, $"Resolved: {path} -> {pathInfo.FullName}"); + + return fullPath; } + Logger.Warning?.Print(LogClass.Application, $"Can't resolve non-existent path: {path} -> {pathInfo.FullName}"); + return pathInfo.FullName; } @@ -85,7 +92,11 @@ namespace Ryujinx.Common.Utilities fullPath = ResolveFullPath(Path.Combine(fullPath, paths[i]), true); } - return ResolveFullPath(Path.Combine(fullPath, paths[^1]), isDirectory); + fullPath = ResolveFullPath(Path.Combine(fullPath, paths[^1]), isDirectory); + + Logger.Warning?.Print(LogClass.Application, $"Combined and resolved: {fullPath}"); + + return fullPath; } public static FileInfo GetActualFileInfo(this FileInfo fileInfo) diff --git a/src/Ryujinx.HLE/FileSystem/ContentPath.cs b/src/Ryujinx.HLE/FileSystem/ContentPath.cs index 5e612eb1fe..3cd1ad0acd 100644 --- a/src/Ryujinx.HLE/FileSystem/ContentPath.cs +++ b/src/Ryujinx.HLE/FileSystem/ContentPath.cs @@ -30,11 +30,11 @@ namespace Ryujinx.HLE.FileSystem { realPath = switchContentPath switch { - SystemContent => FileSystemUtils.CombineAndResolveFullPath(true, AppDataManager.BaseDirPath, SystemNandPath, Contents), - UserContent => FileSystemUtils.CombineAndResolveFullPath(true, AppDataManager.BaseDirPath, UserNandPath, Contents), + SystemContent => FileSystemUtils.CombineAndResolveFullPath(true, AppDataManager.BaseDirPath, AppDataManager.DefaultNandDir, "system", Contents), + UserContent => FileSystemUtils.CombineAndResolveFullPath(true, AppDataManager.BaseDirPath, AppDataManager.DefaultNandDir, "user", Contents), SdCardContent => FileSystemUtils.CombineAndResolveFullPath(true, GetSdCardPath(), Nintendo, Contents), - System => FileSystemUtils.CombineAndResolveFullPath(true, AppDataManager.BaseDirPath, SystemNandPath), - User => FileSystemUtils.CombineAndResolveFullPath(true, AppDataManager.BaseDirPath, UserNandPath), + System => FileSystemUtils.CombineAndResolveFullPath(true, AppDataManager.BaseDirPath, AppDataManager.DefaultNandDir, "system"), + User => FileSystemUtils.CombineAndResolveFullPath(true, AppDataManager.BaseDirPath, AppDataManager.DefaultNandDir, "user"), _ => null, }; diff --git a/src/Ryujinx.HLE/FileSystem/VirtualFileSystem.cs b/src/Ryujinx.HLE/FileSystem/VirtualFileSystem.cs index a1ff54c068..5db94de298 100644 --- a/src/Ryujinx.HLE/FileSystem/VirtualFileSystem.cs +++ b/src/Ryujinx.HLE/FileSystem/VirtualFileSystem.cs @@ -179,11 +179,11 @@ namespace Ryujinx.HLE.FileSystem break; } - string fullPath = Path.Combine(AppDataManager.BaseDirPath, path); + string fullPath = FileSystemUtils.CombineAndResolveFullPath(isDirectory, AppDataManager.BaseDirPath, path); if (isDirectory && !Directory.Exists(fullPath)) { - Directory.CreateDirectory(fullPath); + Directory.CreateDirectory(fullPath!); } return fullPath; diff --git a/src/Ryujinx.UI.Common/Configuration/ConfigurationFileFormat.cs b/src/Ryujinx.UI.Common/Configuration/ConfigurationFileFormat.cs index af3ad0a1da..7e7bf38d4e 100644 --- a/src/Ryujinx.UI.Common/Configuration/ConfigurationFileFormat.cs +++ b/src/Ryujinx.UI.Common/Configuration/ConfigurationFileFormat.cs @@ -395,7 +395,7 @@ namespace Ryujinx.UI.Common.Configuration { try { - configurationFileFormat = JsonHelper.DeserializeFromFile(path, ConfigurationFileFormatSettings.SerializerContext.ConfigurationFileFormat); + configurationFileFormat = JsonHelper.DeserializeFromFile(FileSystemUtils.ResolveFullPath(path, false), ConfigurationFileFormatSettings.SerializerContext.ConfigurationFileFormat); return configurationFileFormat.Version != 0; } @@ -413,7 +413,7 @@ namespace Ryujinx.UI.Common.Configuration /// The path to the JSON configuration file public void SaveConfig(string path) { - JsonHelper.SerializeToFile(path, this, ConfigurationFileFormatSettings.SerializerContext.ConfigurationFileFormat); + JsonHelper.SerializeToFile(FileSystemUtils.ResolveFullPath(path, false), this, ConfigurationFileFormatSettings.SerializerContext.ConfigurationFileFormat); } } }