Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ The `IsMatch` method attempts to match the specified path against the provided w

By default, the system's default path separators are used. You can override this behavior by specifying one of the following flags:

| Name | Description |
|---------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Auto | Automatically determines whether to treat backslashes (`\ `) as escape sequences or path separators based on the platform's separator convention. |
| Windows | Treats backslashes (`\ `) as path separators instead of escape sequences.<br>Provides behavior consistent with Windows-style paths.<br>Both backslashes (`\ `) and forward slashes (`/`) are considered as path separators in this mode. |
| Unix | Treats backslashes (`\ `) as escape sequences, allowing for special character escaping.<br>Provides behavior consistent with Unix-style paths. |
| Name | Description |
|---------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Auto | Automatically determines whether to treat backslashes (`\`) as escape sequences or path separators based on the platform's separator convention. |
| Windows | Treats backslashes (`\`) as path separators instead of escape sequences.<br>Provides behavior consistent with Windows-style paths.<br>Both backslashes (`\`) and forward slashes (`/`) are considered as path separators in this mode. |
| Unix | Treats backslashes (`\`) as escape sequences, allowing for special character escaping.<br>Provides behavior consistent with Unix-style paths. |

Example with a specific flag:
```csharp
Expand All @@ -45,7 +45,7 @@ From [Wikipedia](https://en.wikipedia.org/wiki/Glob_(programming)#Syntax)
| [!abc] | matches one character that is not given in the bracket | [!C]at | Bat, bat, or cat | Cat |
| [!a-z] | matches one character that is not from the range given in the bracket | Letter[!3-5] | Letter1, Letter2, Letter6 up to Letter9 and Letterx etc. | Letter3, Letter4, Letter5 or Letterxx |

### Pattern specific for directories
### Pattern-specific for directories

| Pattern | Description | Example | Matches | Does not match |
|---------|-----------------------------------------------------|---------|--------------------------------|----------------|
Expand All @@ -68,7 +68,7 @@ Brace patterns allow for matching multiple alternatives in a single pattern. Her

## Escaping characters

The meta characters `?`, `*`, `[`, `\ ` can be escaped by using the `[]`, which means *match one character listed in the bracket*.
The meta characters `?`, `*`, `[`, `\` can be escaped by using the `[]`, which means *match one character listed in the bracket*.
* `[[]` matches the literal `[`
* `[*]` matches the literal `*`

Expand Down Expand Up @@ -217,9 +217,9 @@ await foreach (string filePath in enumeration)

## Supported versions

| | Version |
|------|------------|
| .NET | 6, 7, 8, 9 |
| | Version |
|------|----------------|
| .NET | 6, 7, 8, 9, 10 |

## Contributions

Expand Down
38 changes: 0 additions & 38 deletions Ramstack.Globbing.sln

This file was deleted.

10 changes: 10 additions & 0 deletions Ramstack.Globbing.slnx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Solution>
<Folder Name="/Solution Items/">
<File Path=".editorconfig" />
<File Path=".gitignore" />
<File Path="LICENSE" />
<File Path="README.md" />
</Folder>
<Project Path="Ramstack.Globbing.Tests/Ramstack.Globbing.Tests.csproj" />
<Project Path="Ramstack.Globbing/Ramstack.Globbing.csproj" />
</Solution>
11 changes: 6 additions & 5 deletions Ramstack.Globbing/Matcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ namespace Ramstack.Globbing;
public static unsafe class Matcher
{
/// <summary>
/// Represents a marker structure that is used to indicate that the '\' character
/// Represents a marker structure used to indicate that the '\' character
/// should be treated as an escape character in the context of glob pattern processing.
/// This enables the JIT compiler to generate optimized versions of functions
/// for different options, enhancing performance.
/// </summary>
private readonly struct Unix;

/// <summary>
/// Represents a marker structure that is used to indicate that the escape character '\'
/// Represents a marker structure used to indicate that the escape character '\'
/// should not be treated as an escape character, but as a path separator instead,
/// in the context of glob pattern processing.
/// This enables the JIT compiler to generate optimized versions of functions
Expand Down Expand Up @@ -257,7 +257,7 @@ static int Length(char* s, char* e)
// 2. At any deeper level (level > 0), an empty segment indicates that a required directory or file is missing,
// making the path invalid for patterns expecting something at that level.
//
// For example:
// For example
// Pattern: "*/*" and path: "a" - This pattern requires at least one directory level, so "a" is not a match.
// Pattern: "*/{,b}" and path: "a" - Similarly, this pattern requires a directory or a specific file ("b")
// at the next level, so "a" doesn't match.
Expand Down Expand Up @@ -356,10 +356,11 @@ static int Length(char* s, char* e)

case '*':
{
// *** --> *
// *** => *
// Treats consecutive stars as one
// ReSharper disable once RedundantJumpStatement
while (++p < pend && p[0] == '*')
continue; // ReSharper disable once RedundantJumpStatement
continue;

// Trailing '*' matches everything
if (p == pend)
Expand Down
3 changes: 2 additions & 1 deletion Ramstack.Globbing/Traversal/Files.Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ private static int GetRelativePathLength(ref FileSystemEntry entry)
// This method is 47 bytes of IL code consisting solely of calls (6 calls),
// and JIT refuses to inline it, even though the x86-64 output results
// in a small set of instructions.

return entry.Directory.Length - entry.RootDirectory.Length + entry.FileName.Length + 1;
}

Expand All @@ -146,7 +147,7 @@ private static void UpdatePathSeparators(scoped Span<char> path, MatchFlags flag
// To enable escaping in Windows systems, we convert backslashes (\) to forward slashes (/).
// This is safe because in Windows, backslashes are only used as path separators.
// Otherwise, the backslash (\) in the path will be treated as an escape character,
// and as a result, the `Unix` flag will essentially not work on a Windows system.
// and as a result, the MatchFlags.Unix flag will essentially not work on a Windows system.
if (Path.DirectorySeparatorChar == '\\' && flags == MatchFlags.Unix)
PathHelper.ConvertPathToPosixStyle(path);
}
Expand Down