aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.Engine/ShiftFS/ShiftTree.cs
diff options
context:
space:
mode:
authorAlex-TIMEHACK <[email protected]>2017-11-18 16:29:54 +0000
committerAlex-TIMEHACK <[email protected]>2017-11-18 16:29:54 +0000
commit4037be53b29a122732cfc10693e9c0027f606bb0 (patch)
tree8533ea9ee0ac8f5f7f696b85cb039f783657ada0 /ShiftOS.Engine/ShiftFS/ShiftTree.cs
parent65b7ac2b8cbc4478f6d31a21f106048aeb075078 (diff)
parent97722fbe9d474adffbba0b92e9727c48a8205234 (diff)
downloadshiftos-rewind-4037be53b29a122732cfc10693e9c0027f606bb0.tar.gz
shiftos-rewind-4037be53b29a122732cfc10693e9c0027f606bb0.tar.bz2
shiftos-rewind-4037be53b29a122732cfc10693e9c0027f606bb0.zip
Updated my fork!
Conflicts: ShiftOS.Engine/ShiftOS.Engine.csproj ShiftOS.Engine/Terminal/Commands/Hello.cs ShiftOS.Engine/Terminal/TerminalBackend.cs ShiftOS.Engine/Terminal/TerminalCommand.cs ShiftOS.Main/ShiftOS.Main.csproj ShiftOS.Main/ShiftOS/Apps/Terminal.cs ShiftOS.Main/ShiftOS/Desktop.cs
Diffstat (limited to 'ShiftOS.Engine/ShiftFS/ShiftTree.cs')
-rw-r--r--ShiftOS.Engine/ShiftFS/ShiftTree.cs66
1 files changed, 66 insertions, 0 deletions
diff --git a/ShiftOS.Engine/ShiftFS/ShiftTree.cs b/ShiftOS.Engine/ShiftFS/ShiftTree.cs
new file mode 100644
index 0000000..33c300a
--- /dev/null
+++ b/ShiftOS.Engine/ShiftFS/ShiftTree.cs
@@ -0,0 +1,66 @@
+using System;
+using System.Collections.Generic;
+using Whoa;
+
+namespace ShiftOS.Engine.ShiftFS
+{
+ [Serializable]
+ public class ShiftTree : ShiftDirectory, IShiftNode
+ {
+ public ShiftTree(string name, char letter) : base(name)
+ {
+ Name = name;
+ Letter = letter;
+ }
+
+
+ public new IEnumerable<ShiftFile> Flatten()
+ {
+ foreach (var item in this)
+ {
+ switch (item)
+ {
+ case ShiftFile file:
+ yield return file;
+ break;
+ case ShiftDirectory dir:
+ foreach (var shiftNode in dir.Flatten())
+ {
+ yield return shiftNode;
+ }
+ break;
+ }
+ }
+ }
+
+ public new IEnumerable<ShiftDirectory> FlattenFolders()
+ {
+ foreach (var item in this)
+ {
+ if (!(item is ShiftDirectory dir)) continue;
+ yield return dir;
+
+ foreach (var subdir in dir.FlattenFolders())
+ {
+ yield return subdir;
+ }
+ }
+ }
+
+
+ public new string Name { get; set; }
+
+
+ public char Letter { get; }
+
+ public new string FullName => $@"{Name}:\";
+
+ public new ShiftDirectory Parent
+ {
+ get => null;
+ set => throw new InvalidOperationException("Cannot set parent of ShiftTree");
+ }
+
+ public new ShiftTree Drive => this;
+ }
+} \ No newline at end of file