mirror of
https://github.com/sigmasternchen/Wish
synced 2025-03-15 15:38:54 +00:00
fixed real-filename-creator; basic version of ls; fixed quit on signal in login; lineShift reset in login; scandir serverside
This commit is contained in:
parent
0ebe15bfaf
commit
3a3f36f407
4 changed files with 32 additions and 2 deletions
|
@ -34,6 +34,7 @@
|
||||||
<div id="output"></div>
|
<div id="output"></div>
|
||||||
<input type="button" onclick="powerOn()" value="Power Button" />
|
<input type="button" onclick="powerOn()" value="Power Button" />
|
||||||
<input type="button" onclick="window.clearInterval(Emulator.mainTickId)" value="clear system timer" />
|
<input type="button" onclick="window.clearInterval(Emulator.mainTickId)" value="clear system timer" />
|
||||||
|
<a href="https://github.com/overflowerror/Wish">GitHub repo</a>
|
||||||
<form id="form" name="form" onsubmit="return false;">
|
<form id="form" name="form" onsubmit="return false;">
|
||||||
<input type="text" name="input" id="input" />
|
<input type="text" name="input" id="input" />
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -22,6 +22,7 @@ WshClass.prototype.tick = function() {
|
||||||
switch(this.state) {
|
switch(this.state) {
|
||||||
case 0:
|
case 0:
|
||||||
stdout.write("Welcome to WishOS 0.1 (WOSKernel 0.1)\n\n");
|
stdout.write("Welcome to WishOS 0.1 (WOSKernel 0.1)\n\n");
|
||||||
|
console.log("wsh: loading profile");
|
||||||
this.files['profile.d'] = new File("/etc/profile.d/env.json");
|
this.files['profile.d'] = new File("/etc/profile.d/env.json");
|
||||||
var array = JSON.parse(this.files['profile.d'].read());
|
var array = JSON.parse(this.files['profile.d'].read());
|
||||||
for (var i = 0; i < array.length; i++) {
|
for (var i = 0; i < array.length; i++) {
|
||||||
|
@ -34,7 +35,7 @@ WshClass.prototype.tick = function() {
|
||||||
case 1:
|
case 1:
|
||||||
var prompt = this.Environment.array['PS1'];
|
var prompt = this.Environment.array['PS1'];
|
||||||
while (prompt.indexOf("\\w") != -1)
|
while (prompt.indexOf("\\w") != -1)
|
||||||
prompt = prompt.replace("\\w", (this.Environment.array['PWD'] == this.Environment.array['HOME']) ? "~" : this.Environment.array['PWD']);
|
prompt = prompt.replace("\\w", (this.Environment.array['PWD'].substring(0, this.Environment.array['HOME'].length) == this.Environment.array['HOME']) ? "~" : this.Environment.array['PWD']);
|
||||||
while (prompt.indexOf("\\u") != -1)
|
while (prompt.indexOf("\\u") != -1)
|
||||||
prompt = prompt.replace("\\u", this.username);
|
prompt = prompt.replace("\\u", this.username);
|
||||||
while (prompt.indexOf("\\u") != -1)
|
while (prompt.indexOf("\\u") != -1)
|
||||||
|
|
|
@ -357,6 +357,21 @@ Kernel.Filesystem.update = function(path) {
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
Kernel.Filesystem.getRealPath = function(name) {
|
Kernel.Filesystem.getRealPath = function(name) {
|
||||||
|
var index;
|
||||||
|
while ((index = name.indexOf("/../")) != -1) {
|
||||||
|
name = name.replace("/../", "/");
|
||||||
|
var index2 = 0;
|
||||||
|
var index3 = 0;
|
||||||
|
while(index2 < index) {
|
||||||
|
index3 = index2;
|
||||||
|
index2 = name.indexOf("/", index3);
|
||||||
|
}
|
||||||
|
if (!index3)
|
||||||
|
return undefined;
|
||||||
|
name = name.substring(index3, index);
|
||||||
|
}
|
||||||
|
while ((index = name.indexOf("/./")) != -1)
|
||||||
|
name = name.replace("/./", "/");
|
||||||
return Kernel.Filesystem.root + name;
|
return Kernel.Filesystem.root + name;
|
||||||
}
|
}
|
||||||
Kernel.Filesystem.addTTY = function(path, output, input) {
|
Kernel.Filesystem.addTTY = function(path, output, input) {
|
||||||
|
@ -390,6 +405,17 @@ Kernel.Filesystem.addTTY = function(path, output, input) {
|
||||||
Kernel.Filesystem.files[path + "/o"] = out;
|
Kernel.Filesystem.files[path + "/o"] = out;
|
||||||
Kernel.Filesystem.files[path + "/i"] = inp
|
Kernel.Filesystem.files[path + "/i"] = inp
|
||||||
}
|
}
|
||||||
|
Kernel.Filesystem.getDirectory = function(path) {
|
||||||
|
console.log("Kernel: trying to read directory " + path);
|
||||||
|
var response = Emulator.Request.get(Kernel.Filesystem.getRealPath("/lib/kernel/files.php"), "scandir=" + encodeURIComponent(path), false, ret);
|
||||||
|
response = JSON.parse(response);
|
||||||
|
if (response.error) {
|
||||||
|
console.log("Kernel: error on reading: " + response.error);
|
||||||
|
return response.error;
|
||||||
|
}
|
||||||
|
return response;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Kernel.IO = function() {
|
Kernel.IO = function() {
|
||||||
|
|
|
@ -100,6 +100,8 @@ LoginClass.prototype.tick = function() {
|
||||||
case 7:
|
case 7:
|
||||||
stdout.write("\n");
|
stdout.write("\n");
|
||||||
console.log("login: okay, user='" + this.user.username + "' shell='" + this.user.shell + "' dir='" + this.user.home + "'");
|
console.log("login: okay, user='" + this.user.username + "' shell='" + this.user.shell + "' dir='" + this.user.home + "'");
|
||||||
|
Emulator.Output.shiftKey = 1;
|
||||||
|
OS.staticShift = 1;
|
||||||
this.execProgram(this.user);
|
this.execProgram(this.user);
|
||||||
this.state++;
|
this.state++;
|
||||||
break;
|
break;
|
||||||
|
@ -169,7 +171,7 @@ LoginClass.prototype.signalHandler = function(signal) {
|
||||||
//break;
|
//break;
|
||||||
default: //SIGKILL
|
default: //SIGKILL
|
||||||
console.log("PID " + this.pid + " got Signal " + signal);
|
console.log("PID " + this.pid + " got Signal " + signal);
|
||||||
Kernel.ProcessManager.remove(this);
|
this.exit(1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue