-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPrograms.cs
125 lines (122 loc) · 2.57 KB
/
Programs.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
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using Sys = Cosmos.System;
namespace Programs
{
public class Programs
{
public static void boot()
{
// program init code goes here
}
public static void drvinit()
{
Drivers.fsDrv();
// driver init runs before boot()
// put driver init stuff here
}
}
public class Drivers
{
public static void fsDrv()
{
var fs = new Sys.FileSystem.CosmosVFS();
Sys.FileSystem.VFS.VFSManager.RegisterVFS(fs);
}
}
/*
public class LBC
{
public static void loadAndRun(String fn)
{
byte[] fb = new byte[2147483647];
if (File.Exists(fn))
{
using (BinaryReader reader = new BinaryReader(File.Open(fn, FileMode.Open)))
{
fb[fb.Length + 1] = reader.ReadByte();
}
UInt32 pc = 0;
byte ir = 0;
bool run = true;
while (run)
{
ir = fb[pc];
pc++;
if (pc == fb.Length)
{
break;
}
switch (ir)
{
case 0:
break;
case 1:
Sys.Power.Shutdown();
break;
case 2:
pc = BitConverter.ToUInt32(fb,(int)pc);
break;
case 3:
run = false;
break;
case 4:
byte[] outst = Encoding.ASCII.GetBytes(((char)fb[pc]).ToString());
pc++;
Console.WriteLine(Encoding.ASCII.GetString(outst));
break;
case 5:
Console.WriteLine(fb[pc]);
pc++;
break;
default:
run = false;
break;
}
}
}
}
}
*/
public class Lpm
{
public static void cmd(string farg, string[] args)
{
if (farg == "install")
{
install(args);
return;
}
}
public static void cmd(string farg)
{
}
public static void install(string[] args)
{
Console.WriteLine("The following packages will be installed:");
//string[] pkgs = args.Where((item, index) => index != 0).ToArray();
string[] pkgs = args;
int i = 0;
foreach (var pkg in args)
{
i++;
Console.Write(" " + pkg);
}
Console.WriteLine();
Console.Write("Do you want to install these " + pkgs.Length + " packages? (Y/N) ");
ConsoleKeyInfo yn = Console.ReadKey();
string yns = yn.KeyChar.ToString();
if (yns == "y")
{
Console.WriteLine("Installing...");
}
else
{
Console.WriteLine("Aborted.");
}
}
}
}