From 6beba13d3d7008d7b1a1bc68efacbd621f030af5 Mon Sep 17 00:00:00 2001 From: overflowerror Date: Sun, 21 Jul 2013 12:12:46 +0200 Subject: [PATCH] stream class; file create method; fix in BIOS --- BIOS.js | 2 +- wish-sys/sys-part/kernel0.1.js | 36 ++++++++++++++++++++++++++++++++-- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/BIOS.js b/BIOS.js index 00a5692..ae5944a 100644 --- a/BIOS.js +++ b/BIOS.js @@ -40,7 +40,7 @@ BIOS.main = function() { Emulator.unregisterTimer(BIOS.tickid); return; } - if (BIOSs.hdds.length > 1) { + if (BIOS.hdds.length > 1) { Emulator.output("\nPlease select booting device by pressing the device nr. "); BIOS.state = 0; } else { diff --git a/wish-sys/sys-part/kernel0.1.js b/wish-sys/sys-part/kernel0.1.js index dd762bc..2f6437f 100644 --- a/wish-sys/sys-part/kernel0.1.js +++ b/wish-sys/sys-part/kernel0.1.js @@ -10,6 +10,9 @@ const SIGUSR2 = 31; const APPND = 1; const OVWRT = 2; +const FILE = 1; +const DIR = 2; + const SYSHALT = 31415926 var OS = function() { @@ -287,6 +290,9 @@ File.prototype.forceUpdate = function() { File.prototype.exists = function() { return Kernel.Filesystem.getFile(this.path).exists() } +File.prototype.create = function() { + Kernel.Filesystem.create(this.path, FILE); +} File.prototype.read = function(length) { var val = Kernel.Filesystem.getFile(this.path).read(this.position, length); if (length) @@ -297,10 +303,10 @@ File.prototype.write = function(string) { this.writeFIFO(string); } File.prototype.writeFIFO = function(string) { - Kernel.Filesystem.getFile(this.path).writeFIFO(string, writeMode); + Kernel.Filesystem.getFile(this.path).writeFIFO(string, this.writeMode); } File.prototype.writeLIFO = function(string) { - Kernel.Filesystem.getFile(this.path).writeLIFO(string, writeMode); + Kernel.Filesystem.getFile(this.path).writeLIFO(string, this.writeMode); } var InnerFile = function(path) { @@ -329,6 +335,27 @@ InnerFile.prototype.writeLIFO = function(string, mode) { this.content = string; } +var AppStream = function() { +} +AppStream.prototype = new File; +AppStream.prototype.content; +AppStream.prototype.read = function() { + return this.content.pop(); +} +AppStream.prototype.read = function() { + return this.content.pop(); +} +AppStream.prototype.writeFIFO = function(string) { + this.content.input.reverse(); + for (var i = 0; i < string.length; i++) + this.content.push(char); + this.content.reverse(); +} +AppStream.prototype.writeLIFI = function(string) { + for(var i = 0; i < string.length; i++) + this.content.push(string[i]); +} + Kernel.Filesystem = function() { } Kernel.Filesystem.devices; @@ -344,6 +371,11 @@ Kernel.Filesystem.init = function() { Kernel.Filesystem.files = new Array(); } +Kernel.Filesystem.create = function(name, type) { + var file = new InnerFile(name); + file.content = ""; + Kernel.Filesystem.files[name] = file; +} Kernel.Filesystem.getFile = function(path) { if (Kernel.Filesystem.files[path]) return Kernel.Filesystem.files[path];