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
2 changes: 1 addition & 1 deletion src/Ramstack.FileSystem.Abstractions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ Console.WriteLine(await reader.ReadToEndAsync());

### VirtualDirectory

The `VirtualDirectory` class provides properties and methods for creating, deleting, and enumerating directories and subdirectories.
The `VirtualDirectory` class provides properties and methods for creating, deleting and enumerating directories and subdirectories.

```csharp
public static async Task PrintFilesAsync(VirtualDirectory directory, string padding = "", CancellationToken cancellationToken = default)
Expand Down
8 changes: 4 additions & 4 deletions src/Ramstack.FileSystem.Abstractions/VirtualFileExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ namespace Ramstack.FileSystem;
/// </summary>
public static class VirtualFileExtensions
{
private static Encoding? _utf8NoBom;
private static Encoding? s_utf8NoBom;

/// <summary>
/// Gets an instance of <c>UTF8</c> encoding without BOM.
/// Gets an instance of the <see cref="UTF8Encoding"/> without BOM.
/// </summary>
private static Encoding Utf8NoBom => _utf8NoBom ??= new UTF8Encoding(encoderShouldEmitUTF8Identifier: false, throwOnInvalidBytes: true);
private static Encoding Utf8NoBom => s_utf8NoBom ??= new UTF8Encoding(encoderShouldEmitUTF8Identifier: false, throwOnInvalidBytes: true);

/// <summary>
/// Asynchronously returns a <see cref="StreamReader"/> with <see cref="Encoding.UTF8"/>
Expand Down Expand Up @@ -279,7 +279,7 @@ public static ValueTask WriteAllTextAsync(this VirtualFile file, string contents
WriteAllTextAsync(file, contents.AsMemory(), encoding, cancellationToken);

/// <summary>
/// Asynchronously writes the specified string to current the file. If the file already exists, it is truncated and overwritten.
/// Asynchronously writes the specified string to the current file. If the file already exists, it is truncated and overwritten.
/// </summary>
/// <param name="file">The file to write to.</param>
/// <param name="contents">The contents to write to the file.</param>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public static ValueTask WriteAllTextAsync(this IVirtualFileSystem fs, string pat
fs.GetFile(path).WriteAllTextAsync(contents, encoding, cancellationToken);

/// <summary>
/// Asynchronously writes the specified string to specified the file. If the file already exists, it is truncated and overwritten.
/// Asynchronously writes the specified string to the specified the file. If the file already exists, it is truncated and overwritten.
/// </summary>
/// <param name="fs">The file system to use.</param>
/// <param name="path">The file to write to.</param>
Expand Down
6 changes: 3 additions & 3 deletions src/Ramstack.FileSystem.Abstractions/VirtualPath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public static ReadOnlySpan<char> GetExtension(ReadOnlySpan<char> path)
/// <summary>
/// Returns the file name and extension for the specified path.
/// </summary>
/// <param name="path">The path from which to obtain the file name and extension.</param>
/// <param name="path">The path from which to get the file name and extension.</param>
/// <returns>
/// The file name and extension for the <paramref name="path"/>.
/// </returns>
Expand All @@ -100,7 +100,7 @@ public static string GetFileName(string path)
/// <summary>
/// Returns the file name and extension for the specified path.
/// </summary>
/// <param name="path">The path from which to obtain the file name and extension.</param>
/// <param name="path">The path from which to get the file name and extension.</param>
/// <returns>
/// The file name and extension for the <paramref name="path"/>.
/// </returns>
Expand All @@ -118,7 +118,7 @@ public static ReadOnlySpan<char> GetFileName(ReadOnlySpan<char> path)
/// </summary>
/// <param name="path">The path to retrieve the directory portion from.</param>
/// <returns>
/// Directory portion for <paramref name="path"/>, or an empty string if path denotes a root directory.
/// Directory portion for <paramref name="path"/>, or an empty string if the path denotes a root directory.
/// </returns>
public static string GetDirectoryName(string path)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Ramstack.FileSystem.Amazon/S3UploadStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public override Task WriteAsync(byte[] buffer, int offset, int count, Cancellati
WriteAsync(buffer.AsMemory(offset, count), cancellationToken).AsTask();

/// <inheritdoc />
public override async ValueTask WriteAsync(ReadOnlyMemory<byte> buffer, CancellationToken cancellationToken = new CancellationToken())
public override async ValueTask WriteAsync(ReadOnlyMemory<byte> buffer, CancellationToken cancellationToken = default)
{
try
{
Expand Down
2 changes: 1 addition & 1 deletion src/Ramstack.FileSystem.Azure/AzureFileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public ValueTask CreateContainerAsync(CancellationToken cancellationToken = defa
/// <item>
/// <description>
/// <see cref="PublicAccessType.BlobContainer" />: Specifies full public read access for both the container and blob data.
/// Clients can enumerate blobs within the container via anonymous requests, but cannot enumerate containers within the storage account.
/// Clients can enumerate blobs within the container via anonymous requests but cannot enumerate containers within the storage account.
/// </description>
/// </item>
/// <item>
Expand Down
14 changes: 7 additions & 7 deletions src/Ramstack.FileSystem.Physical/PhysicalDirectory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ internal sealed class PhysicalDirectory : VirtualDirectory
/// including system and hidden files, not recurse through subdirectories,
/// and ignore inaccessible files.
/// </summary>
private static readonly EnumerationOptions DefaultOptions = new()
private static readonly EnumerationOptions s_defaultOptions = new()
{
AttributesToSkip = 0,
RecurseSubdirectories = false,
Expand Down Expand Up @@ -85,7 +85,7 @@ protected override IAsyncEnumerable<VirtualNode> GetFileNodesCoreAsync(Cancellat
// its existence was checked.

var nodes = Directory.Exists(_physicalPath)
? new FileSystemEnumerable<VirtualNode>(_physicalPath, FindTransform, DefaultOptions)
? new FileSystemEnumerable<VirtualNode>(_physicalPath, FindTransform, s_defaultOptions)
: Enumerable.Empty<VirtualNode>();

return nodes.ToAsyncEnumerable();
Expand All @@ -108,17 +108,17 @@ protected override IAsyncEnumerable<VirtualFile> GetFilesCoreAsync(CancellationT

if (Directory.Exists(_physicalPath))
{
nodes = new FileSystemEnumerable<VirtualFile>(_physicalPath, FindTransform, DefaultOptions)
nodes = new FileSystemEnumerable<VirtualFile>(_physicalPath, FindTransform, s_defaultOptions)
{
ShouldIncludePredicate = (ref FileSystemEntry entry) => !entry.IsDirectory
ShouldIncludePredicate = (ref entry) => !entry.IsDirectory
};
}

return nodes.ToAsyncEnumerable();

VirtualFile FindTransform(ref FileSystemEntry entry)
{
Debug.Assert(entry.IsDirectory == false);
Debug.Assert(!entry.IsDirectory);

var fullName = VirtualPath.Join(FullName, entry.FileName);
var physicalPath = entry.ToFullPath();
Expand All @@ -134,9 +134,9 @@ protected override IAsyncEnumerable<VirtualDirectory> GetDirectoriesCoreAsync(Ca

if (Directory.Exists(_physicalPath))
{
nodes = new FileSystemEnumerable<VirtualDirectory>(_physicalPath, FindTransform, DefaultOptions)
nodes = new FileSystemEnumerable<VirtualDirectory>(_physicalPath, FindTransform, s_defaultOptions)
{
ShouldIncludePredicate = (ref FileSystemEntry entry) => entry.IsDirectory
ShouldIncludePredicate = (ref entry) => entry.IsDirectory
};
}

Expand Down
4 changes: 2 additions & 2 deletions src/Ramstack.FileSystem.Physical/PhysicalFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ protected override ValueTask<Stream> OpenWriteCoreAsync(CancellationToken cancel

var stream = new FileStream(_physicalPath, FileMode.OpenOrCreate, FileAccess.Write, FileShare.None, DefaultBufferSize, options);

// Since, FileMode.OpenOrCreate doesn't truncate the file, we manually
// Since FileMode.OpenOrCreate doesn't truncate the file, we manually
// set the file length to zero to remove any leftover data.
stream.SetLength(0);

Expand All @@ -90,7 +90,7 @@ protected override async ValueTask WriteCoreAsync(Stream stream, bool overwrite,

await using var fs = new FileStream(_physicalPath, fileMode, FileAccess.Write, FileShare.None, DefaultBufferSize, options);

// Since, FileMode.OpenOrCreate doesn't truncate the file, we manually
// Since FileMode.OpenOrCreate doesn't truncate the file, we manually
// set the file length to zero to remove any leftover data.
fs.SetLength(0);

Expand Down
2 changes: 1 addition & 1 deletion src/Ramstack.FileSystem.Prefixed/PrefixedFileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public PrefixedFileSystem(string prefix, IVirtualFileSystem fileSystem)
prefix = VirtualPath.Normalize(prefix);
(_prefix, _fs) = (prefix, fileSystem);

// Create artificial directory list
// Create an artificial directory list
_directories = CreateArtificialDirectories(this, prefix);

static VirtualDirectory[] CreateArtificialDirectories(PrefixedFileSystem fs, string path)
Expand Down