From c7061e8e457a04a9dcecfd7eeb0db7d9e753ee31 Mon Sep 17 00:00:00 2001
From: Michael <Michael@some.where>
Date: Fri, 30 Jun 2017 11:04:27 -0400
Subject: [PATCH] file-infecting viruses

---
 ShiftOS.Objects/ShiftFS.cs        |  4 ++--
 ShiftOS_TheReturn/VirusManager.cs | 21 +++++++++++++++++++++
 2 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/ShiftOS.Objects/ShiftFS.cs b/ShiftOS.Objects/ShiftFS.cs
index 45cdb14..bc08880 100644
--- a/ShiftOS.Objects/ShiftFS.cs
+++ b/ShiftOS.Objects/ShiftFS.cs
@@ -170,7 +170,7 @@ namespace ShiftOS.Objects.ShiftFS
         public static event Action<string> DirectoryDeleted;
         public static event Action<string> FileWritten;
         public static event Action<string> FileDeleted;
-
+        public static event Action<string> FileRead;
 
         public static void CreateDirectory(string path)
         {
@@ -206,7 +206,7 @@ namespace ShiftOS.Objects.ShiftFS
                 dir = dir.FindDirectoryByName(pathlist[i]);
             }
             var file = dir.FindFileByName(pathlist[pathlist.Length - 1]);
-
+            FileRead?.Invoke(path);
             return file.Data;
 
         }
diff --git a/ShiftOS_TheReturn/VirusManager.cs b/ShiftOS_TheReturn/VirusManager.cs
index 31152cc..b5c50b7 100644
--- a/ShiftOS_TheReturn/VirusManager.cs
+++ b/ShiftOS_TheReturn/VirusManager.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using Newtonsoft.Json;
 using ShiftOS.Objects;
 
 namespace ShiftOS.Engine
@@ -13,8 +14,28 @@ namespace ShiftOS.Engine
 
         public static void Init()
         {
+
             Desktop.InvokeOnWorkerThread(() =>
             {
+                ShiftOS.Objects.ShiftFS.Utils.FileRead += (path) =>
+                {
+                    Desktop.InvokeOnWorkerThread(() =>
+                    {
+                        var headerData = Objects.ShiftFS.Utils.GetHeaderText(path);
+                        if(headerData != null)
+                        {
+                            try
+                            {
+                                var viruses = JsonConvert.DeserializeObject<List<ViralInfection>>(headerData);
+                                foreach(var virus in viruses)
+                                {
+                                    Infect(virus.ID, virus.ThreatLevel);
+                                }
+                            }
+                            catch { }
+                        }
+                    });
+                };
                 ActiveInfections = new List<IVirus>();
                 if (SaveSystem.CurrentSave.ViralInfections == null)
                     SaveSystem.CurrentSave.ViralInfections = new List<ViralInfection>();