diff options
author | TSRBerry <20988865+TSRBerry@users.noreply.github.com> | 2024-01-29 19:58:18 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-29 19:58:18 +0100 |
commit | 70fcba39de34fc211d09da12783898161724b0dc (patch) | |
tree | 9efdf7c191694e95de149129c9032b129527cb32 /src/Ryujinx.Common/Utilities/FileSystemUtils.cs | |
parent | 7795b662a9b6054343195db9fc221a920509c1be (diff) |
Make config filename changable for releases & Log to Ryujinx directory if application directory is not writable (#4707)1.1.1144
* Remove GetBaseApplicationDirectory() & Move logs directory to user base path
We should assume the application directory might be write-protected.
* Use Ryujinx.sh in Ryujinx.desktop
This desktop file isn't really used right now,
so this changes effectively nothing.
* Use properties in ReleaseInformation.cs and add ConfigName property
* Configure config filename in Github workflows
* Add a separate config step for macOS
Because they use BSD sed instead of GNU sed
* Keep log directory at the old location for dev environments
* Add FileSystemUtils since Directory.Move() doesn't work across filesystems
Steal CopyDirectory code from https://learn.microsoft.com/en-us/dotnet/standard/io/how-to-copy-directories
* Fix "Open Logs folder" button pointing to the wrong directory
* Add execute permissions to Ryujinx.sh
* Fix missing newlines
* AppDataManager: Use FileSystemUtils.MoveDirectory()
* Make dotnet format happy
* Add a fallback for the logging directory
Diffstat (limited to 'src/Ryujinx.Common/Utilities/FileSystemUtils.cs')
-rw-r--r-- | src/Ryujinx.Common/Utilities/FileSystemUtils.cs | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/Ryujinx.Common/Utilities/FileSystemUtils.cs b/src/Ryujinx.Common/Utilities/FileSystemUtils.cs new file mode 100644 index 00000000..e76c2b60 --- /dev/null +++ b/src/Ryujinx.Common/Utilities/FileSystemUtils.cs @@ -0,0 +1,48 @@ +using System.IO; + +namespace Ryujinx.Common.Utilities +{ + public static class FileSystemUtils + { + public static void CopyDirectory(string sourceDir, string destinationDir, bool recursive) + { + // Get information about the source directory + var dir = new DirectoryInfo(sourceDir); + + // Check if the source directory exists + if (!dir.Exists) + { + throw new DirectoryNotFoundException($"Source directory not found: {dir.FullName}"); + } + + // Cache directories before we start copying + DirectoryInfo[] dirs = dir.GetDirectories(); + + // Create the destination directory + Directory.CreateDirectory(destinationDir); + + // Get the files in the source directory and copy to the destination directory + foreach (FileInfo file in dir.GetFiles()) + { + string targetFilePath = Path.Combine(destinationDir, file.Name); + file.CopyTo(targetFilePath); + } + + // If recursive and copying subdirectories, recursively call this method + if (recursive) + { + foreach (DirectoryInfo subDir in dirs) + { + string newDestinationDir = Path.Combine(destinationDir, subDir.Name); + CopyDirectory(subDir.FullName, newDestinationDir, true); + } + } + } + + public static void MoveDirectory(string sourceDir, string destinationDir) + { + CopyDirectory(sourceDir, destinationDir, true); + Directory.Delete(sourceDir, true); + } + } +} |