From db563c54aedf5e9d96ca70eec08c560ccbc42d8d Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 21 Apr 2017 18:53:41 -0400 Subject: Add ShiftOS->Host Shared Persistence ShiftOS can now write to the shared folder when saving files/deleting files to the 1:/ drive. --- ShiftOS_TheReturn/Paths.cs | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) (limited to 'ShiftOS_TheReturn/Paths.cs') diff --git a/ShiftOS_TheReturn/Paths.cs b/ShiftOS_TheReturn/Paths.cs index 2fc55fd..a7d32e7 100644 --- a/ShiftOS_TheReturn/Paths.cs +++ b/ShiftOS_TheReturn/Paths.cs @@ -40,7 +40,6 @@ namespace ShiftOS.Engine public static void Init() { Locations = new Dictionary(); - Locations.Add("classic", "C:\\ShiftOS"); Locations.Add("root", "0:"); AddPath("root", "system"); @@ -133,6 +132,46 @@ namespace ShiftOS.Engine mount.Name = "Shared"; Utils.Mount(JsonConvert.SerializeObject(mount)); ScanForDirectories(SharedFolder, 1); + Utils.DirectoryCreated += (dir) => + { + if (dir.StartsWith("1:/")) + { + string real = dir.Replace("/", "\\").Replace("1:", SharedFolder); + if (!System.IO.Directory.Exists(real)) + System.IO.Directory.CreateDirectory(real); + } + }; + + Utils.DirectoryDeleted += (dir) => + { + if (dir.StartsWith("1:/")) + { + string real = dir.Replace("/", "\\").Replace("1:", SharedFolder); + if (System.IO.Directory.Exists(real)) + System.IO.Directory.Delete(real, true); + } + }; + + Utils.FileWritten += (dir) => + { + if (dir.StartsWith("1:/")) + { + string real = dir.Replace("/", "\\").Replace("1:", SharedFolder); + System.IO.File.WriteAllBytes(real, ReadAllBytes(dir)); + } + }; + + Utils.FileDeleted += (dir) => + { + if (dir.StartsWith("1:/")) + { + string real = dir.Replace("/", "\\").Replace("1:", SharedFolder); + if (System.IO.File.Exists(real)) + System.IO.File.Delete(real); + } + }; + + } -- cgit v1.2.3