protected override void BeforeRun() { try { Console.Clear(); Encoding.RegisterProvider(CosmosEncodingProvider.Instance); Console.InputEncoding = Encoding.GetEncoding(437); Console.OutputEncoding = Encoding.GetEncoding(437); screen = new TextScreen(); cnsl = new Sys.Console(screen); CustomConsole.WriteLineInfo("Booting Raindrop Operating System..."); #region Register filesystem Console.Write("Initialize file system? (Y/N) "); var fsc = Console.ReadLine().ToLowerInvariant(); if (fsc == "y" || fsc == "yes") { Sys.FileSystem.VFS.VFSManager.RegisterVFS(vFS); if (ContainsVolumes()) { CustomConsole.WriteLineOK("FileSystem Registration"); } else { CustomConsole.WriteLineError("FileSystem Registration"); } } else { CustomConsole.WriteLineWarning("FileSystem not registered!"); } #endregion CM = new CommandManager(); CustomConsole.WriteLineOK("Raindrop OS started."); Console.Write("Press any key to continue..."); Console.ReadKey(); Console.Clear(); current = new Prompt(); /*vFS.CreateDirectory(currentDirectory + @"Test"); * vFS.CreateDirectory(currentDirectory + @"Test\atabo"); * vFS.CreateFile(currentDirectory + @"Test\atabo.rd"); * vFS.CreateFile(currentDirectory + @"Test\passwd.nonono"); * vFS.CreateFile(currentDirectory + @"Test\.hiddenfile.txt"); * vFS.CreateFile(currentDirectory + @"root.conf");*/ } catch (Exception ex) { Crash.StopKernel(ex); } }
protected override void Run() { try { current.Run(); } catch (Exception ex) { Crash.StopKernel(ex); } }
/// <summary> /// Executes a command /// </summary> /// <param name="c">Command name</param> public bool Execute(string c) { comd = ""; y.Clear(); //var z = Regex.Matches(c, "(\"[^\"]+\" |[^\\s\"]+)"); Regex not plugged in CosmosOS :( var z = Parse(c); for (var i = 0; i < z.Count; i++) { if (i == 0) { comd = z[i].ToLowerInvariant(); } else { y.Add(z[i]); } } if (comd == "") { return(false); } var cmd = GetCommand(comd); if (cmd != null) { try { if (cmd.NeedsParam && y.Count == 0) { CustomConsole.WriteLineError("This command needs parameters"); comd = ""; return(true); } else { cmd.Run.Invoke(); comd = ""; return(true); } } catch (Exception ex) { Crash.StopKernel(ex); return(true); } } comd = ""; return(true); }