protected override void BeforeRun() { //filesystem A: var fs = new Sys.FileSystem.CosmosVFS(); Sys.FileSystem.VFS.VFSManager.RegisterVFS(fs); fs.Initialize(); fs.CreateDirectory("0:\\PROGRAM"); fs.CreateDirectory("0:\\OS"); fs.CreateDirectory("0:\\document"); var CD = fs.CreateFile("0:\\document\\test.txt"); var GD = fs.GetFile("0:\\document\\test.txt"); string RD = GD.ToString(); Console.WriteLine(RD); //text color var textscr = Cosmos.HAL.Global.TextScreen; Cosmos.System.Global.Console = new Cosmos.System.Console(textscr); Cosmos.HAL.Global.TextScreen = textscr; Console.ForegroundColor = ConsoleColor.Green; Console.BackgroundColor = ConsoleColor.Black; //debug Kernel.PrintDebug("test"); //login E: Console.WriteLine("RF OS V 1.0 TERMLINK"); Console.Write("login user password:"******"admin"; string inputp = Console.ReadLine(); if (inputp == password) { Console.Clear(); Run(); } else { Console.WriteLine("ENTRY DENIED TRY AGAIN"); Console.WriteLine("press any key to repeat"); Console.ReadKey(); Console.Clear(); goto E; } if (inputp == "rundebugmode") { Console.Clear(); goto A; } if (inputp == "shutdown") { Sys.Power.Shutdown(); } }
protected override void BeforeRun() { // Inizializza File system var fs = new Sys.FileSystem.CosmosVFS(); Sys.FileSystem.VFS.VFSManager.RegisterVFS(fs); #region Installation if (!File.Exists("0:\\System\\users")) { Console.Clear(); #region Create User Console.Clear(); Console.WriteLine("GUIDED JGKOS INSTALLATION"); Console.WriteLine(); Console.WriteLine("Create a default username and password:"******"Username: "******"******", password = "******"; while (password != cPassword) { Console.Write("Password: "******"Confirm your password:"******"Le due password non corrispondono"); } } #endregion Create User #region Create Directory //Console.WriteLine("Deleating default dirs..."); //Directory.Delete("0:\\Dir Testing\\"); //Directory.Delete("0:\\TEST\\"); //File.Delete("0:\\Kudzu.txt"); //File.Delete("0:\\Root.txt"); Console.WriteLine(); Console.WriteLine("Creating system files..."); Console.WriteLine(); fs.CreateDirectory("0:\\System\\"); fs.CreateFile("0:\\System\\USERS"); fs.CreateFile("0:\\System\\readme.txt"); fs.CreateFile("0:\\System\\CONFIG.cnf"); string FirstUserFile = "root:0:password1\n" + username + ":1001:" + cPassword; File.WriteAllText("0:\\System\\users", FirstUserFile); #region Config Config.Default(); Config.SaveCustom(); #endregion Config #endregion Create Directory Console.WriteLine(); Console.WriteLine(); Console.WriteLine("Installation done"); } #endregion Installation Config.LoadCustom(); #region Logo Console.Clear(); Console.ForegroundColor = ConsoleColor.Blue; Console.Write($@" _________ _______ _ _______ _______ \__ _/( ____ \| \ /\ ( ___ )( ____ \ ) ( | ( \/| \ / / | ( ) || ( \/ | | | | | (_/ / | | | || (_____ | | | | ____ | _ ( | | | |(_____ ) | | | | \_ )| ( \ \ | | | | ) | |\_) ) | (___) || / \ \ | (___) |/\____) | (____/ (_______)|_/ \/_____(_______)\_______) (_____) Username : developer Password : dev ---------------------------------------------- JKG OS has been booted ({version}) Type help for command list ---------------------------------------------- "); Console.WriteLine(); Console.ForegroundColor = ConsoleColor.White; #endregion Logo Crypto.Login(); }
///<summary> ///Operating System ///</summary> protected override void Run() { Utilities(); Console.Write(current_directory + "> "); string userinput = Console.ReadLine(); string[] args = userinput.Split(' '); switch (args[0].ToLower()) { case "restart": Sys.Power.Reboot(); break; case "shutdown": throw new Exception("Shuting Down..."); #pragma warning disable CS0162 // Unreachable code detected break; #pragma warning restore CS0162 // Unreachable code detected case "help": Console.WriteLine("Found 13 in the directory: \n HELP: Shows a list of commands \n RESTART: Restarts client \n SHUTDOWN: Shuts down client \n CLEAR: Clears the console \n ECHO: Echoes a line of text into the console \n COLOR: Changes the console color based on the user prefrences \n SYSINFO: Gives the system infomation \n DIR: Lists the volume directories \n CSPAD: csOS Text Editor. Can write to files \n DEL: Deletes the specified file \n LSDIR: Lists the files in a directory \n PRINT: Displays the text of the file \n MKDIR: Makes the directory of the users choice \n CD: Goes to the user-specified directory"); break; case "clear": Console.Clear(); break; case "echo": Console.Write("Line to echo:"); string input1 = Console.ReadLine(); Console.WriteLine(input1); break; case "color": Console.WriteLine("Valid colors: ROYGBIV, Black, and White"); Console.Write("Color:"); string input2 = Console.ReadLine(); switch (input2) { case "red": Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Color changed"); break; case "orange": Console.ForegroundColor = ConsoleColor.DarkYellow; break; case "yellow": Console.ForegroundColor = ConsoleColor.Yellow; break; case "green": Console.ForegroundColor = ConsoleColor.Green; break; case "blue": Console.ForegroundColor = ConsoleColor.DarkBlue; break; case "indigo": Console.ForegroundColor = ConsoleColor.Blue; break; case "violet": Console.ForegroundColor = ConsoleColor.Magenta; break; case "black": Console.ForegroundColor = ConsoleColor.Black; break; case "white": Console.ForegroundColor = ConsoleColor.White; break; case "reset": Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Color reset."); break; default: Console.WriteLine("The color you have inputed is not a valid color. Please use ROYGBIV and Black and White."); break; } break; case "cspad": Console.WriteLine("Entering CSPad..."); Console.WriteLine("Press enter to enter CSPad"); Console.ReadLine(); Console.Clear(); Console.BackgroundColor = ConsoleColor.White; Console.ForegroundColor = ConsoleColor.Black; Console.Write("File to save as:"); string fileName = Console.ReadLine(); fs.CreateFile(current_directory + fileName); Console.Write("Text to save:"); string input = Console.ReadLine(); File.WriteAllText(current_directory + fileName, input); Console.WriteLine("File Saved!"); break; case "del": Console.WriteLine("***WARNING*** \\ This cannot be undone!"); Console.Write("File to Delete:"); string del = Console.ReadLine(); File.Delete(del); break; case "print": Console.WriteLine("Entering print mode..."); Console.Write("File to read:"); string file = Console.ReadLine(); if (File.Exists(file)) { Console.WriteLine(File.ReadAllText(file)); } else { if (File.Exists(file) == false) { Console.WriteLine("The file you have inputed does not exist. Please try again"); } } break; case "sysinfo": Console.WriteLine("csOS (C-Sharp Operating System) \n CREATOR: Lskywalker48 \n VERSION: 1.0.1"); break; case "dir": var vols = fs.GetVolumes(); Console.WriteLine("NAME\tSIZE"); foreach (var vol in vols) { Console.WriteLine(vol.mName + "\t" + vol.mSize.ToString()); } break; case "mkdir": Console.Write("Name of Directory:"); string dirAdd = Console.ReadLine(); fs.CreateDirectory(current_directory + dirAdd); Console.WriteLine("Directory Created!"); break; case "cd": Console.Write("DIR to go to:"); string dirtogo = Console.ReadLine(); if (fs.GetDirectory(current_directory + dirtogo) != null) { current_directory = current_directory + dirtogo + "\\"; } else { if (dirtogo == "goback") { if (current_directory.Length > 3) { var dirGet = fs.GetDirectory(Directory.GetCurrentDirectory()); } } } break; case "lsdir": Console.WriteLine("TYPE\tNAME"); foreach (var dir in Directory.GetDirectories(Directory.GetCurrentDirectory())) { Console.WriteLine("<DIR>\t" + dir); } foreach (var dir in Directory.GetFiles(Directory.GetCurrentDirectory())) { Console.WriteLine(Directory.GetFiles(Directory.GetCurrentDirectory()).ToString() + "\t" + dir); } break; case "": break; default: Console.WriteLine("The entered command: '" + userinput + "' does not exist. Please try again."); break; } }