stream class; file create method; fix in BIOS

This commit is contained in:
overflowerror 2013-07-21 12:12:46 +02:00
parent 4a3f033087
commit 6beba13d3d
2 changed files with 35 additions and 3 deletions

View file

@ -40,7 +40,7 @@ BIOS.main = function() {
Emulator.unregisterTimer(BIOS.tickid); Emulator.unregisterTimer(BIOS.tickid);
return; return;
} }
if (BIOSs.hdds.length > 1) { if (BIOS.hdds.length > 1) {
Emulator.output("\nPlease select booting device by pressing the device nr. "); Emulator.output("\nPlease select booting device by pressing the device nr. ");
BIOS.state = 0; BIOS.state = 0;
} else { } else {

View file

@ -10,6 +10,9 @@ const SIGUSR2 = 31;
const APPND = 1; const APPND = 1;
const OVWRT = 2; const OVWRT = 2;
const FILE = 1;
const DIR = 2;
const SYSHALT = 31415926 const SYSHALT = 31415926
var OS = function() { var OS = function() {
@ -287,6 +290,9 @@ File.prototype.forceUpdate = function() {
File.prototype.exists = function() { File.prototype.exists = function() {
return Kernel.Filesystem.getFile(this.path).exists() return Kernel.Filesystem.getFile(this.path).exists()
} }
File.prototype.create = function() {
Kernel.Filesystem.create(this.path, FILE);
}
File.prototype.read = function(length) { File.prototype.read = function(length) {
var val = Kernel.Filesystem.getFile(this.path).read(this.position, length); var val = Kernel.Filesystem.getFile(this.path).read(this.position, length);
if (length) if (length)
@ -297,10 +303,10 @@ File.prototype.write = function(string) {
this.writeFIFO(string); this.writeFIFO(string);
} }
File.prototype.writeFIFO = function(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) { 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) { var InnerFile = function(path) {
@ -329,6 +335,27 @@ InnerFile.prototype.writeLIFO = function(string, mode) {
this.content = string; 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 = function() {
} }
Kernel.Filesystem.devices; Kernel.Filesystem.devices;
@ -344,6 +371,11 @@ Kernel.Filesystem.init = function() {
Kernel.Filesystem.files = new Array(); 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) { Kernel.Filesystem.getFile = function(path) {
if (Kernel.Filesystem.files[path]) if (Kernel.Filesystem.files[path])
return Kernel.Filesystem.files[path]; return Kernel.Filesystem.files[path];