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
36 changes: 18 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ building upon `Microsoft.Extensions.FileProviders`.

## Projects

This repository contains projects:
This repository contains the following projects:

### Ramstack.FileProviders.Extensions
Offers useful and convenient extensions for `IFileProviders`, bringing its capabilities and experience
closer to what's provided by the `DirectoryInfo` and `FileInfo` standard classes.
Offers useful and convenient extensions for `IFileProvider`, bringing its capabilities and experience
closer to what's provided by the `DirectoryInfo` and `FileInfo` classes.

To install the `Ramstack.FileProviders.Extensions` [NuGet package](https://www.nuget.org/packages/Ramstack.FileProviders.Extensions) in your project,
run the following command:
Expand Down Expand Up @@ -87,12 +87,12 @@ This is useful when you need to organize files in a virtual hierarchy.

Example:
```csharp
IFileProvider provider = new PrefixedFileProvider(innerProvider, "/project/app");
IFileProvider provider = new PrefixedFileProvider("/project/app", innerProvider);
IFileInfo file = provider.GetFileInfo("/project/app/docs/README");
Console.WriteLine(file.Exists);
```

This is how you can add virtual directories to your project that are external to the project root:
This is how you can add virtual directories to your project that are outside the project root:
```csharp
string packagesPath = Path.Combine(environment.ContentRootPath, "../Packages");
string themesPath = Path.Combine(environment.ContentRootPath, "../Themes");
Expand Down Expand Up @@ -129,11 +129,11 @@ as if they were originally defined within your project.
├── Models
├── Views
├── Packages <-- (virtual)
│ ├── package1
│ └── package2
│ ├── package-1
│ └── package-2
├── Themes <-- (virtual)
│ ├── theme1
│ └── theme2
│ ├── theme-1
│ └── theme-2
└── wwwroot
```

Expand All @@ -143,29 +143,29 @@ as if they were originally defined within your project.

Example:
```csharp
IFileProvider provider = new SubFileProvider(innerProvider, "/docs");
IFileProvider provider = new SubFileProvider("/docs", innerProvider);
IFileInfo file = provider.GetFileInfo("/README");
Console.WriteLine(file.Exists);
```

### Ramstack.FileProviders.Globbing

`GlobbingFileProvider` class filters files using include and/or exclude glob patterns. Include patterns make only matching files visible,
The `GlobbingFileProvider` class filters files using include and/or exclude glob patterns. Include patterns make only matching files visible,
while exclude patterns hide specific files. Both include and exclude patterns can be combined for flexible file visibility control.

It relies on the [Ramstack.Globbing](https://www.nuget.org/packages/Ramstack.Globbing) package for its globbing capabilities.

Example:
```csharp
IFileProvider provider = new GlobbingFileProvider(innerProvider, patterns: ["**/*.txt", "docs/*.md" ], excludes: ["**/README.md"]);
IFileProvider provider = new GlobbingFileProvider(innerProvider, patterns: ["**/*.txt", "docs/*.md"], excludes: ["**/README.md"]);
foreach (IFileInfo file in provider.GetDirectoryContents("/"))
Console.WriteLine(file.Name);
```

### Ramstack.FileProviders.Extensions

Provides useful extensions for `IFileProvider`, bringing its capabilities and experience closer to what's being
provided by `DirectoryInfo` and `FileInfo` classes.
Provides useful extensions for `IFileProvider`, bringing its capabilities and experience closer to what's
provided by the `DirectoryInfo` and `FileInfo` classes.

Simply stated, a `FileNode` knows which directory it is located in, and a directory represented by the `DirectoryNode` class can access
its parent directory and list all files within it, recursively.
Expand Down Expand Up @@ -242,15 +242,15 @@ builder.Environment.ContentRootFileProvider = FileProviderComposer.FlattenProvid
#### Composing Providers

The `ComposeProviders` method combines a list of `IFileProvider` instances into a single `IFileProvider`.
During this process, all encountered `CompositeFileProvider` instances recursively flattened and merged into a single level.
This eliminates unnecessary indirectness and streamline the file provider hierarchy.
During this process, all encountered `CompositeFileProvider` instances are recursively flattened and merged into a single level.
This eliminates unnecessary indirectness and streamlines the file provider hierarchy.

```csharp
string packagesPath = Path.Combine(environment.ContentRootPath, "../Packages");
string themesPath = Path.Combine(environment.ContentRootPath, "../Themes");

environment.ContentRootFileProvider = FileProviderComposer.ComposeProviders(
// Inject external Modules directory
// Inject external Packages directory
new PrefixedFileProvider("/Packages", new PhysicalFileProvider(packagesPath)),

// Inject external Themes directory
Expand All @@ -261,7 +261,7 @@ environment.ContentRootFileProvider = FileProviderComposer.ComposeProviders(
```

In this example, the `ComposeProviders` method handles any unnecessary nesting that might occur, including when the current
`environment.ContentRootFileProvider` is a `CompositeFileProvider`. This ensures that all file providers merged into a single
`environment.ContentRootFileProvider` is a `CompositeFileProvider`. This ensures that all file providers are merged into a single
flat structure, avoiding unnecessary indirectness.

#### Flattening Change Tokens
Expand Down
6 changes: 3 additions & 3 deletions src/Ramstack.FileProviders.Composition/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ builder.Environment.ContentRootFileProvider = FileProviderComposer.FlattenProvid

## Composing Providers
The `ComposeProviders` method combines a list of `IFileProvider` instances into a single `IFileProvider`.
During this process, all encountered `CompositeFileProvider` instances recursively flattened and merged into a single level.
This eliminates unnecessary indirectness and streamline the file provider hierarchy.
During this process, all encountered `CompositeFileProvider` instances are recursively flattened and merged into a single level.
This eliminates unnecessary indirectness and streamlines the file provider hierarchy.

```csharp
string packagesPath = Path.Combine(environment.ContentRootPath, "../Packages");
string themesPath = Path.Combine(environment.ContentRootPath, "../Themes");

environment.ContentRootFileProvider = FileProviderComposer.ComposeProviders(
// Inject external Modules directory
// Inject external Packages directory
new PrefixedFileProvider("/Packages", new PhysicalFileProvider(packagesPath)),

// Inject external Themes directory
Expand Down
2 changes: 1 addition & 1 deletion src/Ramstack.FileProviders.Extensions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ dotnet add package Ramstack.FileProviders.Extensions
## Overview

The library provides useful extensions for `IFileProvider`, bringing its capabilities and experience
closer to what's being provided by `DirectoryInfo` and `FileInfo` classes.
closer to what's provided by the `DirectoryInfo` and `FileInfo` classes.

Simply stated, a `FileNode` knows which directory it is located in, and a directory represented
by the `DirectoryNode` class can access its parent directory and list all files within it, recursively.
Expand Down
4 changes: 2 additions & 2 deletions src/Ramstack.FileProviders.Globbing/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ dotnet add package Ramstack.FileProviders.Globbing
```

## GlobbingFileProvider
`GlobbingFileProvider` class filters files using include and/or exclude glob patterns. Include patterns make only matching files visible,
The `GlobbingFileProvider` class filters files using include and/or exclude glob patterns. Include patterns make only matching files visible,
while exclude patterns hide specific files. Both include and exclude patterns can be combined for flexible file visibility control.

It relies on the [Ramstack.Globbing](https://www.nuget.org/packages/Ramstack.Globbing) package for its globbing capabilities.

Example:
```csharp
IFileProvider provider = new GlobbingFileProvider(innerProvider, patterns: ["**/*.txt", "docs/*.md" ], excludes: ["**/README.md"]);
IFileProvider provider = new GlobbingFileProvider(innerProvider, patterns: ["**/*.txt", "docs/*.md"], excludes: ["**/README.md"]);
foreach (IFileInfo file in provider.GetDirectoryContents("/"))
Console.WriteLine(file.Name);
```
Expand Down
2 changes: 1 addition & 1 deletion src/Ramstack.FileProviders/PrefixedFileProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public void Dispose() =>
// Strategy:
// - Preserve '**' to allow arbitrary depth
// - Drop ambiguous intermediate segments
// - Keep only the final segment if it is a file pattern (e.g. '*.js')
// - Keep only the final segment after '**', if any (e.g. '*.js')
//
// This guarantees:
// - No false negatives caused by prefix misalignment
Expand Down
16 changes: 8 additions & 8 deletions src/Ramstack.FileProviders/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
[![NuGet](https://img.shields.io/nuget/v/Ramstack.FileProviders.svg)](https://nuget.org/packages/Ramstack.FileProviders)
[![MIT](https://img.shields.io/github/license/rameel/ramstack.fileproviders)](https://github.com/rameel/ramstack.fileproviders/blob/main/LICENSE)

Represents a .NET library that provides additional implementations for `Microsoft.Extensions.FileProviders` including:
Represents a .NET library that provides additional implementations of `IFileProvider` including:
- `PrefixedFileProvider`
- `SubFileProvider`

Expand All @@ -22,12 +22,12 @@ This is useful when you need to organize files in a virtual hierarchy.

Example:
```csharp
IFileProvider provider = new PrefixedFileProvider(innerProvider, "/project/app");
IFileProvider provider = new PrefixedFileProvider("/project/app", innerProvider);
IFileInfo file = provider.GetFileInfo("/project/app/docs/README");
Console.WriteLine(file.Exists);
```

This is how you can add virtual directories to your project that are external to the project root:
This is how you can add virtual directories to your project that are outside the project root:
```csharp
string packagesPath = Path.Combine(environment.ContentRootPath, "../Packages");
string themesPath = Path.Combine(environment.ContentRootPath, "../Themes");
Expand Down Expand Up @@ -64,11 +64,11 @@ as if they were originally defined within your project.
├── Models
├── Views
├── Packages <-- (virtual)
│ ├── package1
│ └── package2
│ ├── package-1
│ └── package-2
├── Themes <-- (virtual)
│ ├── theme1
│ └── theme2
│ ├── theme-1
│ └── theme-2
└── wwwroot
```

Expand All @@ -77,7 +77,7 @@ as if they were originally defined within your project.

Example:
```csharp
IFileProvider provider = new SubFileProvider(innerProvider, "/docs");
IFileProvider provider = new SubFileProvider("/docs", innerProvider);
IFileInfo file = provider.GetFileInfo("/README");
Console.WriteLine(file.Exists);
```
Expand Down
Loading