aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS.Engine/ShiftFS/ShiftDirectory.cs
diff options
context:
space:
mode:
authorJohn T <[email protected]>2017-11-05 18:47:46 -0500
committerJohn T <[email protected]>2017-11-05 18:47:46 -0500
commita10440a45c40652b13e883aec832a0c8ded685e8 (patch)
treeab64311e47f8e59c7c46cd50c94bec424165ecc2 /ShiftOS.Engine/ShiftFS/ShiftDirectory.cs
parent019da5b9ebf67b758a31dd05c4b17de66fa682f2 (diff)
downloadshiftos-rewind-a10440a45c40652b13e883aec832a0c8ded685e8.tar.gz
shiftos-rewind-a10440a45c40652b13e883aec832a0c8ded685e8.tar.bz2
shiftos-rewind-a10440a45c40652b13e883aec832a0c8ded685e8.zip
Added a half-complete ShiftFS and did some code cleanup
Diffstat (limited to 'ShiftOS.Engine/ShiftFS/ShiftDirectory.cs')
-rw-r--r--ShiftOS.Engine/ShiftFS/ShiftDirectory.cs50
1 files changed, 50 insertions, 0 deletions
diff --git a/ShiftOS.Engine/ShiftFS/ShiftDirectory.cs b/ShiftOS.Engine/ShiftFS/ShiftDirectory.cs
new file mode 100644
index 0000000..64ac4f2
--- /dev/null
+++ b/ShiftOS.Engine/ShiftFS/ShiftDirectory.cs
@@ -0,0 +1,50 @@
+using System.Collections.ObjectModel;
+using System.IO;
+using System.Linq;
+
+namespace ShiftOS.Engine.ShiftFS
+{
+ public class ShiftDirectory : ShiftFsObject
+ {
+ public ShiftDirectory(string path) : base(path)
+ {
+ path = path.Replace(ShiftFs.SavePath, "");
+ var dir = new DirectoryInfo(Path.Combine(ShiftFs.SavePath, path));
+ Name = dir.Name;
+ FullDiskName = dir.FullName;
+ FullName = path;
+
+ Children.CollectionChanged += (sender, e) => { };
+ }
+
+ public ShiftFsObject this[string name] => Children.First(f => f.Name == name);
+ public ShiftFsObject this[int index] => Children[index];
+
+ public new ShiftDirectory Parent => new ShiftDirectory(new DirectoryInfo(FullDiskName).Parent.FullName);
+
+ public ObservableCollection<ShiftFsObject> Children
+ {
+ get
+ {
+ var collection = new ObservableCollection<ShiftFsObject>();
+
+ foreach (var dir in new DirectoryInfo(Path.Combine(ShiftFs.SavePath, FullName)).EnumerateDirectories())
+ {
+ collection.Add(new ShiftDirectory(dir.FullName));
+ }
+
+ foreach (var file in new DirectoryInfo(Path.Combine(ShiftFs.SavePath, FullName)).EnumerateFiles())
+ {
+ collection.Add(new ShiftFile(file.FullName.Replace(ShiftFs.SavePath, "")));
+ }
+
+ return collection;
+ }
+ }
+
+ public ObservableCollection<ShiftFile> Files => new ObservableCollection<ShiftFile>(Children.OfType<ShiftFile>());
+
+ public ObservableCollection<ShiftDirectory> Directories
+ => new ObservableCollection<ShiftDirectory>(Children.OfType<ShiftDirectory>());
+ }
+} \ No newline at end of file