-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKernel.cs
83 lines (73 loc) · 2.7 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
// main file
/* Copyright (C) 2021 Dinuda Yaggahavita, Tarith Jayasooriya
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
using System;
using System.Collections.Generic;
using System.Text;
using Sys = Cosmos.System;
namespace sphere_os
{
public class Kernel : Sys.Kernel
{
filesystem.Dir currentDir;
Sys.FileSystem.CosmosVFS fs;
protected override void BeforeRun()
{
// this will be used to keep track of the current sessions dir
currentDir = new filesystem.Dir();
// filesytem
fs = new Sys.FileSystem.CosmosVFS();
Sys.FileSystem.VFS.VFSManager.RegisterVFS(fs);
Console.WriteLine("Sphere OS Copyright(C) 2021 Dinuda Yaggahavita, Tarith Jayasooriya");
Console.WriteLine("This program comes with ABSOLUTELY NO WARRANTY; This is free software, and you are welcome to redistribute it");
}
protected override void Run()
{
Console.Write(currentDir.dir+": ");
var input = Console.ReadLine();
// tokens
var tokens = input.Split(" ");
var ci = new CommandInput { dir = currentDir, input = tokens, vfs = fs };
switch (tokens[0])
{
// commands here
case "cd":
new commands.CD().Run(ci);
break;
case "echo":
new commands.echo().Run(ci);
break;
case "ls":
new commands.Ls().Run(ci);
break;
case "shutdown":
new commands.Shutdown().Run(ci);
break;
case "mkdir":
new commands.Mkdir().Run(ci);
break;
case "mkfile":
new commands.Mkfile().Run(ci);
break;
case "clear":
new commands.Clear().Run(ci);
break;
case "read":
new commands.Read().Run(ci);
break;
default:
Console.WriteLine("command not found");
break;
}
Console.WriteLine();
}
}
}