Skip to content

Commit

Permalink
Add method to IVirtualFileSystem + comments and test
Browse files Browse the repository at this point in the history
  • Loading branch information
phmatray committed Mar 11, 2023
1 parent 0b96ac6 commit b2331b9
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 5 deletions.
14 changes: 14 additions & 0 deletions docs/api/IVirtualFileSystem.GetRootPath().md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#### [Atypical.VirtualFileSystem.Core](VirtualFileSystem.md 'VirtualFileSystem')
### [Atypical.VirtualFileSystem.Core.Contracts](VirtualFileSystem.md#Atypical.VirtualFileSystem.Core.Contracts 'Atypical.VirtualFileSystem.Core.Contracts').[IVirtualFileSystem](IVirtualFileSystem.md 'Atypical.VirtualFileSystem.Core.Contracts.IVirtualFileSystem')

## IVirtualFileSystem.GetRootPath() Method

Gets the path of the root directory.

```csharp
Atypical.VirtualFileSystem.Core.Abstractions.VFSPath GetRootPath();
```

#### Returns
[VFSPath](VFSPath.md 'Atypical.VirtualFileSystem.Core.Abstractions.VFSPath')
The path of the root directory.
1 change: 1 addition & 0 deletions docs/api/IVirtualFileSystem.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Derived
| [GetDirectory(string)](IVirtualFileSystem.GetDirectory(string).md 'Atypical.VirtualFileSystem.Core.Contracts.IVirtualFileSystem.GetDirectory(string)') | Gets a file node by its path.<br/>The path must be absolute. |
| [GetFile(VFSFilePath)](IVirtualFileSystem.GetFile(VFSFilePath).md 'Atypical.VirtualFileSystem.Core.Contracts.IVirtualFileSystem.GetFile(Atypical.VirtualFileSystem.Core.ValueObjects.VFSFilePath)') | Gets a file node by its path.<br/>The path must be absolute. |
| [GetFile(string)](IVirtualFileSystem.GetFile(string).md 'Atypical.VirtualFileSystem.Core.Contracts.IVirtualFileSystem.GetFile(string)') | Gets a file node by its path.<br/>The path must be absolute. |
| [GetRootPath()](IVirtualFileSystem.GetRootPath().md 'Atypical.VirtualFileSystem.Core.Contracts.IVirtualFileSystem.GetRootPath()') | Gets the path of the root directory. |
| [IsEmpty()](IVirtualFileSystem.IsEmpty().md 'Atypical.VirtualFileSystem.Core.Contracts.IVirtualFileSystem.IsEmpty()') | Indicates whether the file system is empty.<br/>This is the case if the root directory is empty. |
| [TryGetDirectory(VFSDirectoryPath, IDirectoryNode)](IVirtualFileSystem.TryGetDirectory(VFSDirectoryPath,IDirectoryNode).md 'Atypical.VirtualFileSystem.Core.Contracts.IVirtualFileSystem.TryGetDirectory(Atypical.VirtualFileSystem.Core.ValueObjects.VFSDirectoryPath, Atypical.VirtualFileSystem.Core.Contracts.IDirectoryNode)') | Try to get a directory node by its path.<br/>The path must be absolute.<br/>If the directory node does not exist, this method returns `false`<br/>and [directory](IVirtualFileSystem.TryGetDirectory(VFSDirectoryPath,IDirectoryNode).md#Atypical.VirtualFileSystem.Core.Contracts.IVirtualFileSystem.TryGetDirectory(Atypical.VirtualFileSystem.Core.ValueObjects.VFSDirectoryPath,Atypical.VirtualFileSystem.Core.Contracts.IDirectoryNode).directory 'Atypical.VirtualFileSystem.Core.Contracts.IVirtualFileSystem.TryGetDirectory(Atypical.VirtualFileSystem.Core.ValueObjects.VFSDirectoryPath, Atypical.VirtualFileSystem.Core.Contracts.IDirectoryNode).directory') is set to `null`. |
| [TryGetDirectory(string, IDirectoryNode)](IVirtualFileSystem.TryGetDirectory(string,IDirectoryNode).md 'Atypical.VirtualFileSystem.Core.Contracts.IVirtualFileSystem.TryGetDirectory(string, Atypical.VirtualFileSystem.Core.Contracts.IDirectoryNode)') | Try to get a directory node by its path.<br/>The path must be absolute.<br/>If the directory node does not exist, this method returns `false`<br/>and [directory](IVirtualFileSystem.TryGetDirectory(string,IDirectoryNode).md#Atypical.VirtualFileSystem.Core.Contracts.IVirtualFileSystem.TryGetDirectory(string,Atypical.VirtualFileSystem.Core.Contracts.IDirectoryNode).directory 'Atypical.VirtualFileSystem.Core.Contracts.IVirtualFileSystem.TryGetDirectory(string, Atypical.VirtualFileSystem.Core.Contracts.IDirectoryNode).directory') is set to `null`. |
Expand Down
16 changes: 16 additions & 0 deletions docs/api/VFS.GetRootPath().md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#### [Atypical.VirtualFileSystem.Core](VirtualFileSystem.md 'VirtualFileSystem')
### [Atypical.VirtualFileSystem.Core](VirtualFileSystem.md#Atypical.VirtualFileSystem.Core 'Atypical.VirtualFileSystem.Core').[VFS](VFS.md 'Atypical.VirtualFileSystem.Core.VFS')

## VFS.GetRootPath() Method

Gets the path of the root directory.

```csharp
public Atypical.VirtualFileSystem.Core.Abstractions.VFSPath GetRootPath();
```

Implements [GetRootPath()](IVirtualFileSystem.GetRootPath().md 'Atypical.VirtualFileSystem.Core.Contracts.IVirtualFileSystem.GetRootPath()')

#### Returns
[VFSPath](VFSPath.md 'Atypical.VirtualFileSystem.Core.Abstractions.VFSPath')
The path of the root directory.
1 change: 1 addition & 0 deletions docs/api/VFS.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Implements [IVirtualFileSystem](IVirtualFileSystem.md 'Atypical.VirtualFileSyste
| [GetDirectory(string)](VFS.GetDirectory(string).md 'Atypical.VirtualFileSystem.Core.VFS.GetDirectory(string)') | Gets a file node by its path.<br/>The path must be absolute. |
| [GetFile(VFSFilePath)](VFS.GetFile(VFSFilePath).md 'Atypical.VirtualFileSystem.Core.VFS.GetFile(Atypical.VirtualFileSystem.Core.ValueObjects.VFSFilePath)') | Gets a file node by its path.<br/>The path must be absolute. |
| [GetFile(string)](VFS.GetFile(string).md 'Atypical.VirtualFileSystem.Core.VFS.GetFile(string)') | Gets a file node by its path.<br/>The path must be absolute. |
| [GetRootPath()](VFS.GetRootPath().md 'Atypical.VirtualFileSystem.Core.VFS.GetRootPath()') | Gets the path of the root directory. |
| [IsEmpty()](VFS.IsEmpty().md 'Atypical.VirtualFileSystem.Core.VFS.IsEmpty()') | Indicates whether the file system is empty.<br/>This is the case if the root directory is empty. |
| [ToString()](VFS.ToString().md 'Atypical.VirtualFileSystem.Core.VFS.ToString()') | Returns the index as an ASCII tree. |
| [TryGetDirectory(VFSDirectoryPath, IDirectoryNode)](VFS.TryGetDirectory(VFSDirectoryPath,IDirectoryNode).md 'Atypical.VirtualFileSystem.Core.VFS.TryGetDirectory(Atypical.VirtualFileSystem.Core.ValueObjects.VFSDirectoryPath, Atypical.VirtualFileSystem.Core.Contracts.IDirectoryNode)') | Try to get a directory node by its path.<br/>The path must be absolute.<br/>If the directory node does not exist, this method returns `false`<br/>and [directory](VFS.TryGetDirectory(VFSDirectoryPath,IDirectoryNode).md#Atypical.VirtualFileSystem.Core.VFS.TryGetDirectory(Atypical.VirtualFileSystem.Core.ValueObjects.VFSDirectoryPath,Atypical.VirtualFileSystem.Core.Contracts.IDirectoryNode).directory 'Atypical.VirtualFileSystem.Core.VFS.TryGetDirectory(Atypical.VirtualFileSystem.Core.ValueObjects.VFSDirectoryPath, Atypical.VirtualFileSystem.Core.Contracts.IDirectoryNode).directory') is set to `null`. |
Expand Down
2 changes: 2 additions & 0 deletions docs/api/VirtualFileSystem.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
The path must be absolute.
- **[GetFile(string)](VFS.GetFile(string).md 'Atypical.VirtualFileSystem.Core.VFS.GetFile(string)')** `Method` Gets a file node by its path.
The path must be absolute.
- **[GetRootPath()](VFS.GetRootPath().md 'Atypical.VirtualFileSystem.Core.VFS.GetRootPath()')** `Method` Gets the path of the root directory.
- **[IsEmpty()](VFS.IsEmpty().md 'Atypical.VirtualFileSystem.Core.VFS.IsEmpty()')** `Method` Indicates whether the file system is empty.
This is the case if the root directory is empty.
- **[ToString()](VFS.ToString().md 'Atypical.VirtualFileSystem.Core.VFS.ToString()')** `Method` Returns the index as an ASCII tree.
Expand Down Expand Up @@ -171,6 +172,7 @@
The path must be absolute.
- **[GetFile(string)](IVirtualFileSystem.GetFile(string).md 'Atypical.VirtualFileSystem.Core.Contracts.IVirtualFileSystem.GetFile(string)')** `Method` Gets a file node by its path.
The path must be absolute.
- **[GetRootPath()](IVirtualFileSystem.GetRootPath().md 'Atypical.VirtualFileSystem.Core.Contracts.IVirtualFileSystem.GetRootPath()')** `Method` Gets the path of the root directory.
- **[IsEmpty()](IVirtualFileSystem.IsEmpty().md 'Atypical.VirtualFileSystem.Core.Contracts.IVirtualFileSystem.IsEmpty()')** `Method` Indicates whether the file system is empty.
This is the case if the root directory is empty.
- **[TryGetDirectory(VFSDirectoryPath, IDirectoryNode)](IVirtualFileSystem.TryGetDirectory(VFSDirectoryPath,IDirectoryNode).md 'Atypical.VirtualFileSystem.Core.Contracts.IVirtualFileSystem.TryGetDirectory(Atypical.VirtualFileSystem.Core.ValueObjects.VFSDirectoryPath, Atypical.VirtualFileSystem.Core.Contracts.IDirectoryNode)')** `Method` Try to get a directory node by its path.
Expand Down
2 changes: 2 additions & 0 deletions docs/links
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ M:Atypical.VirtualFileSystem.Core.VFS.DeleteFile(System.String)|VFS.DeleteFile(s
M:Atypical.VirtualFileSystem.Core.VFS.#ctor|VFS.VFS().md|VFS()
M:Atypical.VirtualFileSystem.Core.VFS.ToString|VFS.ToString().md|ToString()
M:Atypical.VirtualFileSystem.Core.VFS.IsEmpty|VFS.IsEmpty().md|IsEmpty()
M:Atypical.VirtualFileSystem.Core.VFS.GetRootPath|VFS.GetRootPath().md|GetRootPath()
M:Atypical.VirtualFileSystem.Core.VFS.GetDirectory(Atypical.VirtualFileSystem.Core.ValueObjects.VFSDirectoryPath)|VFS.GetDirectory(VFSDirectoryPath).md|GetDirectory(VFSDirectoryPath)
M:Atypical.VirtualFileSystem.Core.VFS.GetDirectory(System.String)|VFS.GetDirectory(string).md|GetDirectory(string)
M:Atypical.VirtualFileSystem.Core.VFS.TryGetDirectory(Atypical.VirtualFileSystem.Core.ValueObjects.VFSDirectoryPath,Atypical.VirtualFileSystem.Core.Contracts.IDirectoryNode@)|VFS.TryGetDirectory(VFSDirectoryPath,IDirectoryNode).md|TryGetDirectory(VFSDirectoryPath, IDirectoryNode)
Expand Down Expand Up @@ -91,6 +92,7 @@ T:Atypical.VirtualFileSystem.Core.Contracts.IRootNode|IRootNode.md|IRootNode
P:Atypical.VirtualFileSystem.Core.Contracts.IVirtualFileSystem.Root|IVirtualFileSystem.Root.md|Root
P:Atypical.VirtualFileSystem.Core.Contracts.IVirtualFileSystem.Index|IVirtualFileSystem.Index.md|Index
M:Atypical.VirtualFileSystem.Core.Contracts.IVirtualFileSystem.IsEmpty|IVirtualFileSystem.IsEmpty().md|IsEmpty()
M:Atypical.VirtualFileSystem.Core.Contracts.IVirtualFileSystem.GetRootPath|IVirtualFileSystem.GetRootPath().md|GetRootPath()
M:Atypical.VirtualFileSystem.Core.Contracts.IVirtualFileSystem.GetDirectory(Atypical.VirtualFileSystem.Core.ValueObjects.VFSDirectoryPath)|IVirtualFileSystem.GetDirectory(VFSDirectoryPath).md|GetDirectory(VFSDirectoryPath)
M:Atypical.VirtualFileSystem.Core.Contracts.IVirtualFileSystem.GetDirectory(System.String)|IVirtualFileSystem.GetDirectory(string).md|GetDirectory(string)
M:Atypical.VirtualFileSystem.Core.Contracts.IVirtualFileSystem.TryGetDirectory(Atypical.VirtualFileSystem.Core.ValueObjects.VFSDirectoryPath,Atypical.VirtualFileSystem.Core.Contracts.IDirectoryNode@)|IVirtualFileSystem.TryGetDirectory(VFSDirectoryPath,IDirectoryNode).md|TryGetDirectory(VFSDirectoryPath, IDirectoryNode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ public interface IVirtualFileSystem
/// This is the case if the root directory is empty.
/// </summary>
bool IsEmpty();

/// <summary>
/// Gets the path of the root directory.
/// </summary>
/// <returns>The path of the root directory.</returns>
VFSPath GetRootPath();

/// <summary>
/// Gets a directory node by its path.
Expand Down
1 change: 0 additions & 1 deletion src/Atypical.VirtualFileSystem.Core/VFS.Commands.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
namespace Atypical.VirtualFileSystem.Core;

public partial record VFS
: IVirtualFileSystem
{
/// <inheritdoc cref="IVirtualFileSystem.CreateDirectory(VFSDirectoryPath)" />
public IVirtualFileSystem CreateDirectory(VFSDirectoryPath directoryPath)
Expand Down
8 changes: 4 additions & 4 deletions src/Atypical.VirtualFileSystem.Core/VFS.Queries.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
namespace Atypical.VirtualFileSystem.Core;

public partial record VFS
: IVirtualFileSystem
{
public VFSPath GetRootPath()
=> this.Root.Path;

/// <inheritdoc cref="IVirtualFileSystem.IsEmpty()" />
public bool IsEmpty()
=> this.Index.Count == 0;

/// <inheritdoc cref="IVirtualFileSystem.GetRootPath()" />
public VFSPath GetRootPath()
=> this.Root.Path;

/// <inheritdoc cref="IVirtualFileSystem.GetDirectory(VFSDirectoryPath)" />
public IDirectoryNode GetDirectory(VFSDirectoryPath directoryPath)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,23 @@ public void Constructor_creates_a_new_file_system()
}
}

public class MethodGetRootPath
{
[Fact]
public void GetRootPath_returns_the_root_path()
{
// Arrange
IVirtualFileSystem vfs = new VFS();

// Act
var rootPath = vfs.GetRootPath();

// Assert
rootPath.Should().NotBeNull();
rootPath.Value.Should().Be("vfs://");
}
}

public class MethodGetDirectory
{
[Fact]
Expand Down

0 comments on commit b2331b9

Please sign in to comment.