aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.HLE/FileSystem/ContentManager.cs
diff options
context:
space:
mode:
authorMarco Carvalho <marcolucio27@gmail.com>2024-04-07 17:55:34 -0300
committerGitHub <noreply@github.com>2024-04-07 17:55:34 -0300
commit3e0d67533f1d31f9d0d0ac0b48922c719c5d8424 (patch)
treeff5cf5177f1fa50349038c077d2a703732f695bb /src/Ryujinx.HLE/FileSystem/ContentManager.cs
parent0b55914864f225236ddbe4f4e80ad6c7eb5d2c01 (diff)
Enhance Error Handling with Try-Pattern Refactoring (#6610)
* Enhance Error Handling with Try-Pattern Refactoring * refactoring * refactoring * Update src/Ryujinx.HLE/FileSystem/ContentPath.cs Co-authored-by: gdkchan <gab.dark.100@gmail.com> --------- Co-authored-by: gdkchan <gab.dark.100@gmail.com>
Diffstat (limited to 'src/Ryujinx.HLE/FileSystem/ContentManager.cs')
-rw-r--r--src/Ryujinx.HLE/FileSystem/ContentManager.cs17
1 files changed, 6 insertions, 11 deletions
diff --git a/src/Ryujinx.HLE/FileSystem/ContentManager.cs b/src/Ryujinx.HLE/FileSystem/ContentManager.cs
index b27eb5ea..3c34a886 100644
--- a/src/Ryujinx.HLE/FileSystem/ContentManager.cs
+++ b/src/Ryujinx.HLE/FileSystem/ContentManager.cs
@@ -104,20 +104,15 @@ namespace Ryujinx.HLE.FileSystem
foreach (StorageId storageId in Enum.GetValues<StorageId>())
{
- string contentDirectory = null;
- string contentPathString = null;
- string registeredDirectory = null;
-
- try
+ if (!ContentPath.TryGetContentPath(storageId, out var contentPathString))
{
- contentPathString = ContentPath.GetContentPath(storageId);
- contentDirectory = ContentPath.GetRealPath(contentPathString);
- registeredDirectory = Path.Combine(contentDirectory, "registered");
+ continue;
}
- catch (NotSupportedException)
+ if (!ContentPath.TryGetRealPath(contentPathString, out var contentDirectory))
{
continue;
}
+ var registeredDirectory = Path.Combine(contentDirectory, "registered");
Directory.CreateDirectory(registeredDirectory);
@@ -471,8 +466,8 @@ namespace Ryujinx.HLE.FileSystem
public void InstallFirmware(string firmwareSource)
{
- string contentPathString = ContentPath.GetContentPath(StorageId.BuiltInSystem);
- string contentDirectory = ContentPath.GetRealPath(contentPathString);
+ ContentPath.TryGetContentPath(StorageId.BuiltInSystem, out var contentPathString);
+ ContentPath.TryGetRealPath(contentPathString, out var contentDirectory);
string registeredDirectory = Path.Combine(contentDirectory, "registered");
string temporaryDirectory = Path.Combine(contentDirectory, "temp");