Skip to content
This repository has been archived by the owner on Jul 10, 2024. It is now read-only.

Commit

Permalink
improve relative path, local path, full path search system
Browse files Browse the repository at this point in the history
  • Loading branch information
HendrikMennen committed Mar 17, 2024
1 parent b0c1dc2 commit 919ff55
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
8 changes: 7 additions & 1 deletion src/OneWare.Essentials/Extensions/StringExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@ public static bool ContainsSubPath(this string pathToFile, string subPath)
return containsIt;
}

public static string ToLinuxPath(this string input)
public static string ToPlatformPath(this string input)
{
return input.Replace('/', Path.DirectorySeparatorChar)
.Replace('\\', Path.DirectorySeparatorChar);
}

public static string ToUnixPath(this string input)
{
return input.Replace('\\', '/');
}
Expand Down
2 changes: 1 addition & 1 deletion src/OneWare.Essentials/Helpers/ProjectHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static bool MatchWildCards(string path, IEnumerable<string> include, IEnu
return include.Any(includePattern => FileSystemName.MatchesSimpleExpression(includePattern, path))
&& (exclude is null || !exclude.Any(excludePattern => FileSystemName.MatchesSimpleExpression(excludePattern, path)
|| Enumerable
.SkipLast<string>(path.ToLinuxPath()
.SkipLast<string>(path.ToUnixPath()
.Split('/', StringSplitOptions.RemoveEmptyEntries), 1)
.Any(x => FileSystemName.MatchesSimpleExpression(excludePattern, x))));
}
Expand Down
6 changes: 3 additions & 3 deletions src/OneWare.Essentials/Models/IProjectFolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ public interface IProjectFolder : IProjectEntry

public IProjectFolder AddFolder(string path, bool createNew = false);

public IProjectEntry? SearchName(string path, bool recursive = true);
public IProjectEntry? SearchName(string path);

public IProjectEntry? SearchRelativePath(string path, bool recursive = true);
public IProjectEntry? SearchRelativePath(string path);

public IProjectEntry? SearchFullPath(string path, bool recursive = true);
public IProjectEntry? SearchFullPath(string path);
}

0 comments on commit 919ff55

Please sign in to comment.