diff --git a/Flow.Launcher.Plugin/SharedCommands/FilesFolders.cs b/Flow.Launcher.Plugin/SharedCommands/FilesFolders.cs index 6e00b8a27..5f003e351 100644 --- a/Flow.Launcher.Plugin/SharedCommands/FilesFolders.cs +++ b/Flow.Launcher.Plugin/SharedCommands/FilesFolders.cs @@ -22,7 +22,7 @@ namespace Flow.Launcher.Plugin.SharedCommands /// /// /// - public static void CopyAll(this string sourcePath, string targetPath, Func messageBoxExShow) + public static void CopyAll(this string sourcePath, string targetPath, Func messageBoxExShow = null) { // Get the subdirectories for the specified directory. DirectoryInfo dir = new DirectoryInfo(sourcePath); @@ -63,6 +63,7 @@ namespace Flow.Launcher.Plugin.SharedCommands #if DEBUG throw; #else + messageBoxExShow ??= MessageBox.Show; messageBoxExShow(string.Format("Copying path {0} has failed, it will now be deleted for consistency", targetPath)); RemoveFolderIfExists(targetPath, messageBoxExShow); #endif @@ -78,7 +79,7 @@ namespace Flow.Launcher.Plugin.SharedCommands /// /// /// - public static bool VerifyBothFolderFilesEqual(this string fromPath, string toPath, Func messageBoxExShow) + public static bool VerifyBothFolderFilesEqual(this string fromPath, string toPath, Func messageBoxExShow = null) { try { @@ -98,6 +99,7 @@ namespace Flow.Launcher.Plugin.SharedCommands #if DEBUG throw; #else + messageBoxExShow ??= MessageBox.Show; messageBoxExShow(string.Format("Unable to verify folders and files between {0} and {1}", fromPath, toPath)); return false; #endif @@ -110,7 +112,7 @@ namespace Flow.Launcher.Plugin.SharedCommands /// /// /// - public static void RemoveFolderIfExists(this string path, Func messageBoxExShow) + public static void RemoveFolderIfExists(this string path, Func messageBoxExShow = null) { try { @@ -122,6 +124,7 @@ namespace Flow.Launcher.Plugin.SharedCommands #if DEBUG throw; #else + messageBoxExShow ??= MessageBox.Show; messageBoxExShow(string.Format("Not able to delete folder {0}, please go to the location and manually delete it", path)); #endif } @@ -152,7 +155,7 @@ namespace Flow.Launcher.Plugin.SharedCommands /// /// /// - public static void OpenPath(string fileOrFolderPath, Func messageBoxExShow) + public static void OpenPath(string fileOrFolderPath, Func messageBoxExShow = null) { var psi = new ProcessStartInfo { @@ -170,6 +173,7 @@ namespace Flow.Launcher.Plugin.SharedCommands #if DEBUG throw; #else + messageBoxExShow ??= MessageBox.Show; messageBoxExShow(string.Format("Unable to open the path {0}, please check if it exists", fileOrFolderPath)); #endif } @@ -179,10 +183,10 @@ namespace Flow.Launcher.Plugin.SharedCommands /// Open a file with associated application /// /// File path - /// /// Working directory /// Open as Administrator - public static void OpenFile(string filePath, Func messageBoxExShow, string workingDir = "", bool asAdmin = false) + /// + public static void OpenFile(string filePath, string workingDir = "", bool asAdmin = false, Func messageBoxExShow = null) { var psi = new ProcessStartInfo { @@ -201,6 +205,7 @@ namespace Flow.Launcher.Plugin.SharedCommands #if DEBUG throw; #else + messageBoxExShow ??= MessageBox.Show; messageBoxExShow(string.Format("Unable to open the path {0}, please check if it exists", filePath)); #endif }