Skip to content

Commit 1672c22

Browse files
authored
Merge pull request #33 from Atypical-Consulting/method-getrootpath
Add method to IVirtualFileSystem + comments and test
2 parents 0b96ac6 + b2331b9 commit 1672c22

File tree

10 files changed

+63
-5
lines changed

10 files changed

+63
-5
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#### [Atypical.VirtualFileSystem.Core](VirtualFileSystem.md 'VirtualFileSystem')
2+
### [Atypical.VirtualFileSystem.Core.Contracts](VirtualFileSystem.md#Atypical.VirtualFileSystem.Core.Contracts 'Atypical.VirtualFileSystem.Core.Contracts').[IVirtualFileSystem](IVirtualFileSystem.md 'Atypical.VirtualFileSystem.Core.Contracts.IVirtualFileSystem')
3+
4+
## IVirtualFileSystem.GetRootPath() Method
5+
6+
Gets the path of the root directory.
7+
8+
```csharp
9+
Atypical.VirtualFileSystem.Core.Abstractions.VFSPath GetRootPath();
10+
```
11+
12+
#### Returns
13+
[VFSPath](VFSPath.md 'Atypical.VirtualFileSystem.Core.Abstractions.VFSPath')
14+
The path of the root directory.

docs/api/IVirtualFileSystem.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ Derived
3737
| [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. |
3838
| [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. |
3939
| [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. |
40+
| [GetRootPath()](IVirtualFileSystem.GetRootPath().md 'Atypical.VirtualFileSystem.Core.Contracts.IVirtualFileSystem.GetRootPath()') | Gets the path of the root directory. |
4041
| [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. |
4142
| [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`. |
4243
| [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`. |

docs/api/VFS.GetRootPath().md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#### [Atypical.VirtualFileSystem.Core](VirtualFileSystem.md 'VirtualFileSystem')
2+
### [Atypical.VirtualFileSystem.Core](VirtualFileSystem.md#Atypical.VirtualFileSystem.Core 'Atypical.VirtualFileSystem.Core').[VFS](VFS.md 'Atypical.VirtualFileSystem.Core.VFS')
3+
4+
## VFS.GetRootPath() Method
5+
6+
Gets the path of the root directory.
7+
8+
```csharp
9+
public Atypical.VirtualFileSystem.Core.Abstractions.VFSPath GetRootPath();
10+
```
11+
12+
Implements [GetRootPath()](IVirtualFileSystem.GetRootPath().md 'Atypical.VirtualFileSystem.Core.Contracts.IVirtualFileSystem.GetRootPath()')
13+
14+
#### Returns
15+
[VFSPath](VFSPath.md 'Atypical.VirtualFileSystem.Core.Abstractions.VFSPath')
16+
The path of the root directory.

docs/api/VFS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ Implements [IVirtualFileSystem](IVirtualFileSystem.md 'Atypical.VirtualFileSyste
4343
| [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. |
4444
| [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. |
4545
| [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. |
46+
| [GetRootPath()](VFS.GetRootPath().md 'Atypical.VirtualFileSystem.Core.VFS.GetRootPath()') | Gets the path of the root directory. |
4647
| [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. |
4748
| [ToString()](VFS.ToString().md 'Atypical.VirtualFileSystem.Core.VFS.ToString()') | Returns the index as an ASCII tree. |
4849
| [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`. |

docs/api/VirtualFileSystem.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
The path must be absolute.
4444
- **[GetFile(string)](VFS.GetFile(string).md 'Atypical.VirtualFileSystem.Core.VFS.GetFile(string)')** `Method` Gets a file node by its path.
4545
The path must be absolute.
46+
- **[GetRootPath()](VFS.GetRootPath().md 'Atypical.VirtualFileSystem.Core.VFS.GetRootPath()')** `Method` Gets the path of the root directory.
4647
- **[IsEmpty()](VFS.IsEmpty().md 'Atypical.VirtualFileSystem.Core.VFS.IsEmpty()')** `Method` Indicates whether the file system is empty.
4748
This is the case if the root directory is empty.
4849
- **[ToString()](VFS.ToString().md 'Atypical.VirtualFileSystem.Core.VFS.ToString()')** `Method` Returns the index as an ASCII tree.
@@ -171,6 +172,7 @@
171172
The path must be absolute.
172173
- **[GetFile(string)](IVirtualFileSystem.GetFile(string).md 'Atypical.VirtualFileSystem.Core.Contracts.IVirtualFileSystem.GetFile(string)')** `Method` Gets a file node by its path.
173174
The path must be absolute.
175+
- **[GetRootPath()](IVirtualFileSystem.GetRootPath().md 'Atypical.VirtualFileSystem.Core.Contracts.IVirtualFileSystem.GetRootPath()')** `Method` Gets the path of the root directory.
174176
- **[IsEmpty()](IVirtualFileSystem.IsEmpty().md 'Atypical.VirtualFileSystem.Core.Contracts.IVirtualFileSystem.IsEmpty()')** `Method` Indicates whether the file system is empty.
175177
This is the case if the root directory is empty.
176178
- **[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.

docs/links

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ M:Atypical.VirtualFileSystem.Core.VFS.DeleteFile(System.String)|VFS.DeleteFile(s
1212
M:Atypical.VirtualFileSystem.Core.VFS.#ctor|VFS.VFS().md|VFS()
1313
M:Atypical.VirtualFileSystem.Core.VFS.ToString|VFS.ToString().md|ToString()
1414
M:Atypical.VirtualFileSystem.Core.VFS.IsEmpty|VFS.IsEmpty().md|IsEmpty()
15+
M:Atypical.VirtualFileSystem.Core.VFS.GetRootPath|VFS.GetRootPath().md|GetRootPath()
1516
M:Atypical.VirtualFileSystem.Core.VFS.GetDirectory(Atypical.VirtualFileSystem.Core.ValueObjects.VFSDirectoryPath)|VFS.GetDirectory(VFSDirectoryPath).md|GetDirectory(VFSDirectoryPath)
1617
M:Atypical.VirtualFileSystem.Core.VFS.GetDirectory(System.String)|VFS.GetDirectory(string).md|GetDirectory(string)
1718
M:Atypical.VirtualFileSystem.Core.VFS.TryGetDirectory(Atypical.VirtualFileSystem.Core.ValueObjects.VFSDirectoryPath,Atypical.VirtualFileSystem.Core.Contracts.IDirectoryNode@)|VFS.TryGetDirectory(VFSDirectoryPath,IDirectoryNode).md|TryGetDirectory(VFSDirectoryPath, IDirectoryNode)
@@ -91,6 +92,7 @@ T:Atypical.VirtualFileSystem.Core.Contracts.IRootNode|IRootNode.md|IRootNode
9192
P:Atypical.VirtualFileSystem.Core.Contracts.IVirtualFileSystem.Root|IVirtualFileSystem.Root.md|Root
9293
P:Atypical.VirtualFileSystem.Core.Contracts.IVirtualFileSystem.Index|IVirtualFileSystem.Index.md|Index
9394
M:Atypical.VirtualFileSystem.Core.Contracts.IVirtualFileSystem.IsEmpty|IVirtualFileSystem.IsEmpty().md|IsEmpty()
95+
M:Atypical.VirtualFileSystem.Core.Contracts.IVirtualFileSystem.GetRootPath|IVirtualFileSystem.GetRootPath().md|GetRootPath()
9496
M:Atypical.VirtualFileSystem.Core.Contracts.IVirtualFileSystem.GetDirectory(Atypical.VirtualFileSystem.Core.ValueObjects.VFSDirectoryPath)|IVirtualFileSystem.GetDirectory(VFSDirectoryPath).md|GetDirectory(VFSDirectoryPath)
9597
M:Atypical.VirtualFileSystem.Core.Contracts.IVirtualFileSystem.GetDirectory(System.String)|IVirtualFileSystem.GetDirectory(string).md|GetDirectory(string)
9698
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)

src/Atypical.VirtualFileSystem.Core/Contracts/IVirtualFileSystem.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ public interface IVirtualFileSystem
3131
/// This is the case if the root directory is empty.
3232
/// </summary>
3333
bool IsEmpty();
34+
35+
/// <summary>
36+
/// Gets the path of the root directory.
37+
/// </summary>
38+
/// <returns>The path of the root directory.</returns>
39+
VFSPath GetRootPath();
3440

3541
/// <summary>
3642
/// Gets a directory node by its path.

src/Atypical.VirtualFileSystem.Core/VFS.Commands.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
namespace Atypical.VirtualFileSystem.Core;
22

33
public partial record VFS
4-
: IVirtualFileSystem
54
{
65
/// <inheritdoc cref="IVirtualFileSystem.CreateDirectory(VFSDirectoryPath)" />
76
public IVirtualFileSystem CreateDirectory(VFSDirectoryPath directoryPath)

src/Atypical.VirtualFileSystem.Core/VFS.Queries.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
namespace Atypical.VirtualFileSystem.Core;
22

33
public partial record VFS
4-
: IVirtualFileSystem
54
{
6-
public VFSPath GetRootPath()
7-
=> this.Root.Path;
8-
95
/// <inheritdoc cref="IVirtualFileSystem.IsEmpty()" />
106
public bool IsEmpty()
117
=> this.Index.Count == 0;
8+
9+
/// <inheritdoc cref="IVirtualFileSystem.GetRootPath()" />
10+
public VFSPath GetRootPath()
11+
=> this.Root.Path;
1212

1313
/// <inheritdoc cref="IVirtualFileSystem.GetDirectory(VFSDirectoryPath)" />
1414
public IDirectoryNode GetDirectory(VFSDirectoryPath directoryPath)

tests/Atypical.VirtualFileSystem.UnitTests/Models/VirtualFileSystemTests.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,23 @@ public void Constructor_creates_a_new_file_system()
2929
}
3030
}
3131

32+
public class MethodGetRootPath
33+
{
34+
[Fact]
35+
public void GetRootPath_returns_the_root_path()
36+
{
37+
// Arrange
38+
IVirtualFileSystem vfs = new VFS();
39+
40+
// Act
41+
var rootPath = vfs.GetRootPath();
42+
43+
// Assert
44+
rootPath.Should().NotBeNull();
45+
rootPath.Value.Should().Be("vfs://");
46+
}
47+
}
48+
3249
public class MethodGetDirectory
3350
{
3451
[Fact]

0 commit comments

Comments
 (0)