-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathKernel.cs
137 lines (131 loc) · 4.51 KB
/
Kernel.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using Sys = Cosmos.System;
namespace JetOS
{
public class Kernel : Sys.Kernel
{
protected override void BeforeRun()
{
// init file system
SystemProcess systemprocess = new SystemProcess();
systemprocess.InitFileSystem();
Console.WriteLine("JetOS booted successfully.");
Console.Clear();
Console.WriteLine(@" _ _ ____ _____ ");
Console.WriteLine(@" | | | | / __ \ / ____|");
Console.WriteLine(@" | | ___| |_| | | | (___ ");
Console.WriteLine(@" _ | |/ _ \ __| | | |\___ \ ");
Console.WriteLine(@" | |__| | __/ |_| |__| |____) |");
Console.WriteLine(@" \____/ \___|\__|\____/|_____/ ");
}
protected override void Run()
{
string currentDir = Directory.GetCurrentDirectory();
Console.Write("JetOS=>{0}>",currentDir);
string dir = "";
string func = "";
var input = Console.ReadLine();
// Call App Class
BasicApp CallBasicApp = new BasicApp();
// Connect to system cmd
SystemCmd CMD = new SystemCmd();
SystemUtils Utilities = new SystemUtils();
TextFile textfile = new TextFile();
if (input.Split().Length > 1)
{
func = input.Split()[0];
} else
{
func = input;
}
switch (func)
{
case "help":
CMD.Help();
break;
case "clear":
CMD.Clear();
break;
case "reboot":
CMD.Reboot();
break;
case "shutdown":
CMD.Shutdown();
break;
case "plus":
CallBasicApp.Plus();
break;
case "multiply":
CallBasicApp.Multiply();
break;
case "minus":
CallBasicApp.Minus();
break;
case "divide":
CallBasicApp.Divide();
break;
case "random":
CallBasicApp.RandomApp();
break;
case "decconvert":
CallBasicApp.DecimalConverter();
break;
case "create":
textfile.CreateFile();
break;
case "read":
textfile.Read();
break;
case "write":
textfile.Write();
break;
case "dir":
Utilities.InspectDirectory();
break;
case "mkdir":
dir = input.Split(" ", 2)[1];
Utilities.CreateDirectory(dir);
break;
case "rmvdir":
dir = input.Split(" ", 2)[1];
Utilities.RemoveDirectory(dir);
break;
case "cd":
dir = input.Split(" ", 2)[1];
Utilities.GoToDirectory(dir);
break;
case "rnm":
Utilities.RenameDirectory();
break;
case "tree":
Utilities.ViewDirectoryTree();
break;
case "say":
int i = 0; string speech = "";
if (input.Split().Length > 1)
{
for (i = 1; i < input.Split().Length; i++)
{
speech += input.Split()[i];
if (i < input.Split().Length - 1)
{
speech += " ";
}
}
Utilities.Say(string.Join(" ", speech));
} else
{
Utilities.Say("Can't hear you...");
}
break;
default:
Console.WriteLine("Unknow command. Try 'help' to see command can use");
break;
}
}
}
}