aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Ui.Common/Helper/OpenHelper.cs
diff options
context:
space:
mode:
authorIsaac Marovitz <42140194+IsaacMarovitz@users.noreply.github.com>2024-02-11 02:09:18 +0000
committerGitHub <noreply@github.com>2024-02-11 03:09:18 +0100
commitf06d22d6f01e657ebbc0c8ef082739cd468e47b5 (patch)
treec10a566438d3801b33c1d7b4eff73ea62b2f1a63 /src/Ryujinx.Ui.Common/Helper/OpenHelper.cs
parent84d6e8d121a1b329d26cc0e462aadd1108d99a04 (diff)
Infra: Capitalisation Consistency (#6296)
* Rename Ryujinx.UI.Common * Rename Ryujinx.UI.LocaleGenerator * Update in Files AboutWindow * Configuration State * Rename projects * Ryujinx/UI * Fix build * Main remaining inconsistencies * HLE.UI Namespace * HLE.UI Files * Namespace * Ryujinx.UI.Common.Configuration.UI * Ryujinx.UI.Common,Configuration.UI Files * More instances
Diffstat (limited to 'src/Ryujinx.Ui.Common/Helper/OpenHelper.cs')
-rw-r--r--src/Ryujinx.Ui.Common/Helper/OpenHelper.cs112
1 files changed, 0 insertions, 112 deletions
diff --git a/src/Ryujinx.Ui.Common/Helper/OpenHelper.cs b/src/Ryujinx.Ui.Common/Helper/OpenHelper.cs
deleted file mode 100644
index 04ebbf3b..00000000
--- a/src/Ryujinx.Ui.Common/Helper/OpenHelper.cs
+++ /dev/null
@@ -1,112 +0,0 @@
-using Ryujinx.Common.Logging;
-using System;
-using System.Diagnostics;
-using System.IO;
-using System.Runtime.InteropServices;
-
-namespace Ryujinx.Ui.Common.Helper
-{
- public static partial class OpenHelper
- {
- [LibraryImport("shell32.dll", SetLastError = true)]
- private static partial int SHOpenFolderAndSelectItems(IntPtr pidlFolder, uint cidl, IntPtr apidl, uint dwFlags);
-
- [LibraryImport("shell32.dll", SetLastError = true)]
- private static partial void ILFree(IntPtr pidlList);
-
- [LibraryImport("shell32.dll", SetLastError = true)]
- private static partial IntPtr ILCreateFromPathW([MarshalAs(UnmanagedType.LPWStr)] string pszPath);
-
- public static void OpenFolder(string path)
- {
- if (Directory.Exists(path))
- {
- Process.Start(new ProcessStartInfo
- {
- FileName = path,
- UseShellExecute = true,
- Verb = "open",
- });
- }
- else
- {
- Logger.Notice.Print(LogClass.Application, $"Directory \"{path}\" doesn't exist!");
- }
- }
-
- public static void LocateFile(string path)
- {
- if (File.Exists(path))
- {
- if (OperatingSystem.IsWindows())
- {
- IntPtr pidlList = ILCreateFromPathW(path);
- if (pidlList != IntPtr.Zero)
- {
- try
- {
- Marshal.ThrowExceptionForHR(SHOpenFolderAndSelectItems(pidlList, 0, IntPtr.Zero, 0));
- }
- finally
- {
- ILFree(pidlList);
- }
- }
- }
- else if (OperatingSystem.IsMacOS())
- {
- ObjectiveC.NSString nsStringPath = new(path);
- ObjectiveC.Object nsUrl = new("NSURL");
- var urlPtr = nsUrl.GetFromMessage("fileURLWithPath:", nsStringPath);
-
- ObjectiveC.Object nsArray = new("NSArray");
- ObjectiveC.Object urlArray = nsArray.GetFromMessage("arrayWithObject:", urlPtr);
-
- ObjectiveC.Object nsWorkspace = new("NSWorkspace");
- ObjectiveC.Object sharedWorkspace = nsWorkspace.GetFromMessage("sharedWorkspace");
-
- sharedWorkspace.SendMessage("activateFileViewerSelectingURLs:", urlArray);
- }
- else if (OperatingSystem.IsLinux())
- {
- Process.Start("dbus-send", $"--session --print-reply --dest=org.freedesktop.FileManager1 --type=method_call /org/freedesktop/FileManager1 org.freedesktop.FileManager1.ShowItems array:string:\"file://{path}\" string:\"\"");
- }
- else
- {
- OpenFolder(Path.GetDirectoryName(path));
- }
- }
- else
- {
- Logger.Notice.Print(LogClass.Application, $"File \"{path}\" doesn't exist!");
- }
- }
-
- public static void OpenUrl(string url)
- {
- if (OperatingSystem.IsWindows())
- {
- Process.Start(new ProcessStartInfo("cmd", $"/c start {url.Replace("&", "^&")}"));
- }
- else if (OperatingSystem.IsLinux())
- {
- Process.Start("xdg-open", url);
- }
- else if (OperatingSystem.IsMacOS())
- {
- ObjectiveC.NSString nsStringPath = new(url);
- ObjectiveC.Object nsUrl = new("NSURL");
- var urlPtr = nsUrl.GetFromMessage("URLWithString:", nsStringPath);
-
- ObjectiveC.Object nsWorkspace = new("NSWorkspace");
- ObjectiveC.Object sharedWorkspace = nsWorkspace.GetFromMessage("sharedWorkspace");
-
- sharedWorkspace.GetBoolFromMessage("openURL:", urlPtr);
- }
- else
- {
- Logger.Notice.Print(LogClass.Application, $"Cannot open url \"{url}\" on this platform!");
- }
- }
- }
-}