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:
overflowerror 2013-07-20 20:43:34 +02:00
parent 0ebe15bfaf
commit 3a3f36f407
4 changed files with 32 additions and 2 deletions

View file

@ -34,6 +34,7 @@
<div id="output"></div>
<input type="button" onclick="powerOn()" value="Power Button" />
<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;">
<input type="text" name="input" id="input" />
</form>

View file

@ -22,6 +22,7 @@ WshClass.prototype.tick = function() {
switch(this.state) {
case 0:
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");
var array = JSON.parse(this.files['profile.d'].read());
for (var i = 0; i < array.length; i++) {
@ -34,7 +35,7 @@ WshClass.prototype.tick = function() {
case 1:
var prompt = this.Environment.array['PS1'];
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)
prompt = prompt.replace("\\u", this.username);
while (prompt.indexOf("\\u") != -1)

View file

@ -357,6 +357,21 @@ Kernel.Filesystem.update = function(path) {
return file;
}
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;
}
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 + "/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() {

View file

@ -100,6 +100,8 @@ LoginClass.prototype.tick = function() {
case 7:
stdout.write("\n");
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.state++;
break;
@ -169,7 +171,7 @@ LoginClass.prototype.signalHandler = function(signal) {
//break;
default: //SIGKILL
console.log("PID " + this.pid + " got Signal " + signal);
Kernel.ProcessManager.remove(this);
this.exit(1);
break;
}
}