Skip to content

Commit b30a3f4

Browse files
authored
Merge pull request #66 from Atypical-Consulting/feature/move-and-rename
Add move and rename capabilities
2 parents 0ef9c72 + 4d8b432 commit b30a3f4

File tree

215 files changed

+3956
-3532
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

215 files changed

+3956
-3532
lines changed

Atypical.VirtualFileSystem.DemoCli/TreeExtensions.cs renamed to Atypical.VirtualFileSystem.DemoCli/Extensions/TreeExtensions.cs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,25 @@
11
using Atypical.VirtualFileSystem.Core.Contracts;
2-
using Spectre.Console;
2+
using Spectre.Console.Rendering;
33

4-
namespace Atypical.VirtualFileSystem.DemoCli;
4+
namespace Atypical.VirtualFileSystem.DemoCli.Extensions;
55

66
public static class TreeExtensions
77
{
8+
/// <summary>
9+
/// Populate a tree node with the contents of a virtual file system
10+
/// </summary>
11+
/// <param name="treeNode">The tree node to populate</param>
12+
/// <param name="vfs">The virtual file system to use as the source</param>
13+
/// <returns>The populated tree node</returns>
14+
public static IRenderable FillTree(this Tree treeNode, IVirtualFileSystem vfs)
15+
=> FillTree(treeNode, vfs.Root);
16+
817
/// <summary>
918
/// Recursive method to populate tree nodes
1019
/// </summary>
1120
/// <param name="treeNode">The tree node to populate</param>
1221
/// <param name="directoryNode">The directory node to use as the source</param>
13-
public static void FillTree(this Tree treeNode, IDirectoryNode directoryNode)
22+
private static Tree FillTree(this Tree treeNode, IDirectoryNode directoryNode)
1423
{
1524
foreach (var dir in directoryNode.Directories)
1625
{
@@ -24,5 +33,7 @@ public static void FillTree(this Tree treeNode, IDirectoryNode directoryNode)
2433
var tree = new Tree(file.Name);
2534
treeNode.AddNode(tree);
2635
}
36+
37+
return treeNode;
2738
}
2839
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// Global using directives
2+
3+
global using Spectre.Console;
Lines changed: 37 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
// See https://aka.ms/new-console-template for more information
2-
3-
using Atypical.VirtualFileSystem.Core;
4-
using Atypical.VirtualFileSystem.DemoCli;
5-
using Spectre.Console;
1+
using Atypical.VirtualFileSystem.Core;
2+
using Atypical.VirtualFileSystem.DemoCli.Extensions;
63

74
// Create a virtual file system
85
var factory = new VirtualFileSystemFactory();
@@ -15,22 +12,38 @@
1512
.Color(Color.Gold1));
1613

1714
// Create a directory structure
18-
vfs.CreateDirectory("/heroes");
19-
vfs.CreateFile("/heroes/ironman.txt", "Tony Stark");
20-
vfs.CreateFile("/heroes/captainamerica.txt", "Steve Rogers");
21-
vfs.CreateFile("/heroes/hulk.txt", "Bruce Banner");
22-
vfs.CreateFile("/heroes/thor.txt", "Thor Odinson");
23-
vfs.CreateFile("/heroes/blackwidow.txt", "Natasha Romanoff");
24-
vfs.CreateDirectory("/villains");
25-
vfs.CreateFile("/villains/loki.txt", "Loki Laufeyson");
26-
vfs.CreateFile("/villains/ultron.txt", "Ultron");
27-
vfs.CreateFile("/villains/killmonger.txt", "N'Jadaka");
28-
29-
// use spectre console to display a tree view of the file system
30-
var tree = new Tree("Marvel Universe");
31-
32-
// Start with the root node
33-
tree.FillTree(vfs.Root);
34-
35-
// Display the tree
36-
AnsiConsole.Write(tree);
15+
vfs.CreateDirectory(new VFSDirectoryPath("/heroes"));
16+
vfs.CreateFile(new VFSFilePath("/heroes/ironman.txt"), "Tony Stark");
17+
vfs.CreateFile(new VFSFilePath("/heroes/captain_america.txt"), "Steve Rogers");
18+
vfs.CreateFile(new VFSFilePath("/heroes/hulk.txt"), "Bruce Banner");
19+
vfs.CreateFile(new VFSFilePath("/heroes/thor.txt"), "Thor Odinson");
20+
vfs.CreateFile(new VFSFilePath("/heroes/black_widow.txt"), "Natasha Romanoff");
21+
22+
vfs.CreateDirectory(new VFSDirectoryPath("/villains"));
23+
vfs.CreateFile(new VFSFilePath("/villains/loki.txt"), "Loki Laufeyson");
24+
vfs.CreateFile(new VFSFilePath("/villains/ultron.txt"), "Ultron");
25+
vfs.CreateFile(new VFSFilePath("/villains/killmonger.txt"), "N'Jadaka");
26+
27+
AnsiConsole.WriteLine("Initial directory structure:");
28+
AnsiConsole.Write(new Tree("Marvel Universe").FillTree(vfs));
29+
AnsiConsole.WriteLine();
30+
31+
AnsiConsole.WriteLine("Rename a file:");
32+
vfs.RenameFile(new VFSFilePath("/heroes/ironman.txt"), "tony_stark.txt");
33+
AnsiConsole.Write(new Tree("Marvel Universe").FillTree(vfs));
34+
AnsiConsole.WriteLine();
35+
36+
AnsiConsole.WriteLine("Move a file:");
37+
vfs.MoveFile(new VFSFilePath("/heroes/tony_stark.txt"), new VFSFilePath("/villains/tony_stark.txt"));
38+
AnsiConsole.Write(new Tree("Marvel Universe").FillTree(vfs));
39+
AnsiConsole.WriteLine();
40+
41+
AnsiConsole.WriteLine("Delete a file:");
42+
vfs.DeleteFile(new VFSFilePath("/villains/tony_stark.txt"));
43+
AnsiConsole.Write(new Tree("Marvel Universe").FillTree(vfs));
44+
AnsiConsole.WriteLine();
45+
46+
AnsiConsole.WriteLine("Delete a directory:");
47+
vfs.DeleteDirectory(new VFSDirectoryPath("/villains"));
48+
AnsiConsole.Write(new Tree("Marvel Universe").FillTree(vfs));
49+
AnsiConsole.WriteLine();
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
2-
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=VFS/@EntryIndexedValue">VFS</s:String></wpf:ResourceDictionary>
2+
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/Abbreviations/=VFS/@EntryIndexedValue">VFS</s:String>
3+
<s:Boolean x:Key="/Default/Environment/Filtering/ExcludeCoverageFilters/=Atypical_002EVirtualFileSystem_002ECore_003B_002A_003BAtypical_002EVirtualFileSystem_002ECore_002E_002A_003B_002A/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

docs/api/DirectoryNode.AddChild(IDirectoryNode).md

Lines changed: 0 additions & 19 deletions
This file was deleted.

docs/api/DirectoryNode.AddChild(IFileNode).md

Lines changed: 0 additions & 19 deletions
This file was deleted.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#### [Atypical.VirtualFileSystem.Core](VirtualFileSystem.md 'VirtualFileSystem')
2+
### [Atypical.VirtualFileSystem.Core](VirtualFileSystem.md#Atypical.VirtualFileSystem.Core 'Atypical.VirtualFileSystem.Core').[DirectoryNode](DirectoryNode.md 'Atypical.VirtualFileSystem.Core.DirectoryNode')
3+
4+
## DirectoryNode.AddChild(IVirtualFileSystemNode) Method
5+
6+
x
7+
Adds a child node to the current directory.
8+
9+
```csharp
10+
public void AddChild(Atypical.VirtualFileSystem.Core.Contracts.IVirtualFileSystemNode node);
11+
```
12+
#### Parameters
13+
14+
<a name='Atypical.VirtualFileSystem.Core.DirectoryNode.AddChild(Atypical.VirtualFileSystem.Core.Contracts.IVirtualFileSystemNode).node'></a>
15+
16+
`node` [IVirtualFileSystemNode](IVirtualFileSystemNode.md 'Atypical.VirtualFileSystem.Core.Contracts.IVirtualFileSystemNode')
17+
18+
The child node to add.
19+
20+
Implements [AddChild(IVirtualFileSystemNode)](IDirectoryNode.AddChild(IVirtualFileSystemNode).md 'Atypical.VirtualFileSystem.Core.Contracts.IDirectoryNode.AddChild(Atypical.VirtualFileSystem.Core.Contracts.IVirtualFileSystemNode)')

docs/api/DirectoryNode.Directories.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#### [Atypical.VirtualFileSystem.Core](VirtualFileSystem.md 'VirtualFileSystem')
2-
### [Atypical.VirtualFileSystem.Core.Models](VirtualFileSystem.md#Atypical.VirtualFileSystem.Core.Models 'Atypical.VirtualFileSystem.Core.Models').[DirectoryNode](DirectoryNode.md 'Atypical.VirtualFileSystem.Core.Models.DirectoryNode')
2+
### [Atypical.VirtualFileSystem.Core](VirtualFileSystem.md#Atypical.VirtualFileSystem.Core 'Atypical.VirtualFileSystem.Core').[DirectoryNode](DirectoryNode.md 'Atypical.VirtualFileSystem.Core.DirectoryNode')
33

44
## DirectoryNode.Directories Property
55

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
#### [Atypical.VirtualFileSystem.Core](VirtualFileSystem.md 'VirtualFileSystem')
2-
### [Atypical.VirtualFileSystem.Core.Models](VirtualFileSystem.md#Atypical.VirtualFileSystem.Core.Models 'Atypical.VirtualFileSystem.Core.Models').[DirectoryNode](DirectoryNode.md 'Atypical.VirtualFileSystem.Core.Models.DirectoryNode')
2+
### [Atypical.VirtualFileSystem.Core](VirtualFileSystem.md#Atypical.VirtualFileSystem.Core 'Atypical.VirtualFileSystem.Core').[DirectoryNode](DirectoryNode.md 'Atypical.VirtualFileSystem.Core.DirectoryNode')
33

44
## DirectoryNode(VFSDirectoryPath) Constructor
55

6-
Initializes a new instance of the [DirectoryNode](DirectoryNode.md 'Atypical.VirtualFileSystem.Core.Models.DirectoryNode') class.
6+
Initializes a new instance of the [DirectoryNode](DirectoryNode.md 'Atypical.VirtualFileSystem.Core.DirectoryNode') class.
77
Creates a new directory node.
88
The directory is created with the current date and time as creation and last modification date.
99

1010
```csharp
11-
public DirectoryNode(Atypical.VirtualFileSystem.Core.ValueObjects.VFSDirectoryPath directoryPath);
11+
public DirectoryNode(Atypical.VirtualFileSystem.Core.VFSDirectoryPath directoryPath);
1212
```
1313
#### Parameters
1414

15-
<a name='Atypical.VirtualFileSystem.Core.Models.DirectoryNode.DirectoryNode(Atypical.VirtualFileSystem.Core.ValueObjects.VFSDirectoryPath).directoryPath'></a>
15+
<a name='Atypical.VirtualFileSystem.Core.DirectoryNode.DirectoryNode(Atypical.VirtualFileSystem.Core.VFSDirectoryPath).directoryPath'></a>
1616

17-
`directoryPath` [VFSDirectoryPath](VFSDirectoryPath.md 'Atypical.VirtualFileSystem.Core.ValueObjects.VFSDirectoryPath')
17+
`directoryPath` [VFSDirectoryPath](VFSDirectoryPath.md 'Atypical.VirtualFileSystem.Core.VFSDirectoryPath')
1818

1919
The path of the directory.

docs/api/DirectoryNode.Files.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#### [Atypical.VirtualFileSystem.Core](VirtualFileSystem.md 'VirtualFileSystem')
2-
### [Atypical.VirtualFileSystem.Core.Models](VirtualFileSystem.md#Atypical.VirtualFileSystem.Core.Models 'Atypical.VirtualFileSystem.Core.Models').[DirectoryNode](DirectoryNode.md 'Atypical.VirtualFileSystem.Core.Models.DirectoryNode')
2+
### [Atypical.VirtualFileSystem.Core](VirtualFileSystem.md#Atypical.VirtualFileSystem.Core 'Atypical.VirtualFileSystem.Core').[DirectoryNode](DirectoryNode.md 'Atypical.VirtualFileSystem.Core.DirectoryNode')
33

44
## DirectoryNode.Files Property
55

0 commit comments

Comments
 (0)