From 763fee0c1400ef3cf3b1cfb49cd0e54ec5c0ce7b Mon Sep 17 00:00:00 2001
From: Jack251970 <1160210343@qq.com>
Date: Mon, 22 Sep 2025 20:58:22 +0800
Subject: [PATCH] Add new helper method & Improve code quality
---
Flow.Launcher.Plugin/SharedCommands/FilesFolders.cs | 10 ++++++++++
Flow.Launcher/PublicAPIInstance.cs | 11 +++++------
2 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/Flow.Launcher.Plugin/SharedCommands/FilesFolders.cs b/Flow.Launcher.Plugin/SharedCommands/FilesFolders.cs
index 6c506cfc0..3af57f00d 100644
--- a/Flow.Launcher.Plugin/SharedCommands/FilesFolders.cs
+++ b/Flow.Launcher.Plugin/SharedCommands/FilesFolders.cs
@@ -150,6 +150,16 @@ namespace Flow.Launcher.Plugin.SharedCommands
return File.Exists(filePath);
}
+ ///
+ /// Checks if a file or directory exists
+ ///
+ ///
+ ///
+ public static bool FileOrLocationExists(this string path)
+ {
+ return LocationExists(path) || FileExists(path);
+ }
+
///
/// Open a directory window (using the OS's default handler, usually explorer)
///
diff --git a/Flow.Launcher/PublicAPIInstance.cs b/Flow.Launcher/PublicAPIInstance.cs
index cbd793dc8..b4c3aa92b 100644
--- a/Flow.Launcher/PublicAPIInstance.cs
+++ b/Flow.Launcher/PublicAPIInstance.cs
@@ -74,7 +74,6 @@ namespace Flow.Launcher
_mainVM.ChangeQueryText(query, requery);
}
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "VSTHRD100:Avoid async void methods", Justification = "")]
public void RestartApp()
{
_mainVM.Hide();
@@ -179,7 +178,7 @@ namespace Flow.Launcher
Clipboard.SetFileDropList(paths);
});
-
+
if (exception == null)
{
if (showDefaultNotification)
@@ -218,7 +217,7 @@ namespace Flow.Launcher
{
LogException(nameof(PublicAPIInstance), "Failed to copy text to clipboard", exception);
ShowMsgError(GetTranslation("failedToCopy"));
- }
+ }
}
}
@@ -327,7 +326,7 @@ namespace Flow.Launcher
((PluginJsonStorage)_pluginJsonStorages[type]).Save();
}
-
+
public void OpenDirectory(string directoryPath, string fileNameOrFilePath = null)
{
try
@@ -412,7 +411,7 @@ namespace Flow.Launcher
private void OpenUri(Uri uri, bool? inPrivate = null, bool forceBrowser = false)
{
- if (uri.IsFile && !File.Exists(uri.LocalPath) && !Directory.Exists(uri.LocalPath))
+ if (uri.IsFile && !FilesFolders.FileOrLocationExists(uri.LocalPath))
{
ShowMsgError(GetTranslation("errorTitle"), string.Format(GetTranslation("fileNotFoundError"), uri.LocalPath));
return;
@@ -493,7 +492,7 @@ namespace Flow.Launcher
OpenUri(appUri);
}
- public void ToggleGameMode()
+ public void ToggleGameMode()
{
_mainVM.ToggleGameMode();
}