Remove duplicate function

This commit is contained in:
VictoriousRaptor 2024-05-23 23:02:24 +08:00
parent 61238641cb
commit 75b1c4b15e
2 changed files with 3 additions and 28 deletions

View file

@ -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);

View file

@ -15,24 +15,6 @@ namespace Flow.Launcher.Plugin.SharedCommands
{
private const string FileExplorerProgramName = "explorer";
/// <summary>
/// Checks if <paramref name="subPath"/> is a subpath of <paramref name="basePath"/>
/// </summary>
/// <param name="subPath"></param>
/// <param name="basePath"></param>
/// <returns></returns>
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);
}
/// <summary>
/// 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
/// <param name="subPath">Sub path</param>
/// <param name="allowEqual">If <see langword="true"/>, when <paramref name="parentPath"/> and <paramref name="subPath"/> are equal, returns <see langword="true"/></param>
/// <returns></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)