diff --git a/com/isoterminal/worker.js b/com/isoterminal/worker.js index dbf1fd2..204af98 100644 --- a/com/isoterminal/worker.js +++ b/com/isoterminal/worker.js @@ -42,11 +42,17 @@ this.runISO = function(opts){ /* * forward events/functions so non-worker world can reach them */ - this.create_file = async function(){ return emulator.create_file.apply(emulator, arguments[0]) } - this.read_file = async function(){ return emulator.read_file.apply(emulator, arguments[0]) } - this.read_file_world = async function(){ return emulator.fs9p.read_file_world.apply(emulator.fs9p, arguments[0]) } - this.append_file = async function(){ emulator.fs9p.append_file.apply(emulator.fs9p, arguments[0]) } - this.update_file = async function(){ emulator.fs9p.update_file.apply(emulator.fs9p, arguments[0]) } + + // stripping '/mnt' is needed (the 9p mounted fs does not know about this) + const stripMountDir = (arr) => { + arr[0] = String(arr[0]).replace(/^\/mnt/,'') + return arr + } + this.create_file = async function(){ return emulator.create_file.apply(emulator, stripMountDir(arguments[0]) ) } + this.read_file = async function(){ return emulator.read_file.apply(emulator, stripMountDir(arguments[0]) ) } + this.read_file_world = async function(){ return emulator.fs9p.read_file_world.apply(emulator.fs9p, stripMountDir(arguments[0]) ) } + this.append_file = async function(){ emulator.fs9p.append_file.apply(emulator.fs9p, stripMountDir(arguments[0])) } + this.update_file = async function(){ emulator.fs9p.update_file.apply(emulator.fs9p, stripMountDir(arguments[0])) } // filename will be read from 9pfs: "/mnt/"+filename emulator.readFromPipe = function(filename,cb){