diff --git a/Flow.Launcher.Core/Configuration/Portable.cs b/Flow.Launcher.Core/Configuration/Portable.cs index 631e94845..21bd04bda 100644 --- a/Flow.Launcher.Core/Configuration/Portable.cs +++ b/Flow.Launcher.Core/Configuration/Portable.cs @@ -1,17 +1,11 @@ -using Microsoft.Win32; -using System; +using System; using System.IO; -using System.Reflection; using System.Windows; using Flow.Launcher.Infrastructure; using Flow.Launcher.Infrastructure.Logger; using Flow.Launcher.Infrastructure.UserSettings; using Flow.Launcher.Plugin.SharedCommands; -using System.Linq; using Flow.Launcher.Core.Plugin; -using Velopack; -using Velopack.Locators; -using Velopack.Windows; namespace Flow.Launcher.Core.Configuration { @@ -84,8 +78,7 @@ namespace Flow.Launcher.Core.Configuration // if not create the portable data folder // Don't create the folder if the version is 1.0.0 (Dev) to allow potential debugging with data in the project folder // It is still possible to create the UserData folder for dev version manually but we want to keep the current behavior - if (!Constant.ProgramDirectory.IsSubPathOf( - Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)) + if (!Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData).PathContains(Constant.ProgramDirectory) && Constant.Version != "1.0.0") { Directory.CreateDirectory(DataLocation.PortableDataPath); diff --git a/Flow.Launcher.Plugin/SharedCommands/FilesFolders.cs b/Flow.Launcher.Plugin/SharedCommands/FilesFolders.cs index 39ad6304c..a835c5b96 100644 --- a/Flow.Launcher.Plugin/SharedCommands/FilesFolders.cs +++ b/Flow.Launcher.Plugin/SharedCommands/FilesFolders.cs @@ -15,24 +15,6 @@ namespace Flow.Launcher.Plugin.SharedCommands { private const string FileExplorerProgramName = "explorer"; - /// - /// Checks if is a subpath of - /// - /// - /// - /// - public static bool IsSubPathOf(this string subPath, string basePath) - { - var rel = Path.GetRelativePath( - basePath.Replace('\\', '/'), - subPath.Replace('\\', '/')); - return rel != "." - && rel != ".." - && !rel.StartsWith("../") - && !Path.IsPathRooted(rel); - } - - /// /// Copies the folder and all of its files and folders /// including subFolders to the target location @@ -287,7 +269,7 @@ namespace Flow.Launcher.Plugin.SharedCommands /// Sub path /// If , when and are equal, returns /// - public static bool PathContains(string parentPath, string subPath, bool allowEqual = false) + public static bool PathContains(this string parentPath, string subPath, bool allowEqual = false) { var rel = Path.GetRelativePath(parentPath.EnsureTrailingSlash(), subPath); return (rel != "." || allowEqual)