2024-09-03 18:33:35 +02:00
|
|
|
ISOTerminal.addEventListener('emulator-started', function(){
|
|
|
|
let emulator = this.emulator
|
|
|
|
let isoterminal = this
|
|
|
|
|
|
|
|
emulator.fs9p.update_file = async function(file,data){
|
|
|
|
|
|
|
|
const p = this.SearchPath(file);
|
|
|
|
|
|
|
|
if(p.id === -1)
|
|
|
|
{
|
2024-09-23 16:58:48 +02:00
|
|
|
return emulator.create_file(file,data)
|
2024-09-03 18:33:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
const inode = this.GetInode(p.id);
|
2024-09-23 16:58:48 +02:00
|
|
|
const buf = typeof data == 'string' ? isoterminal.convert.toUint8Array(data) : data
|
2024-09-03 18:33:35 +02:00
|
|
|
await this.Write(p.id,0, buf.length, buf )
|
|
|
|
// update inode
|
|
|
|
inode.size = buf.length
|
|
|
|
const now = Math.round(Date.now() / 1000);
|
|
|
|
inode.atime = inode.mtime = now;
|
2024-09-23 16:58:48 +02:00
|
|
|
isoterminal.exec(`touch ${file}`) // update inode
|
2024-09-03 18:33:35 +02:00
|
|
|
return new Promise( (resolve,reject) => resolve(buf) )
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
emulator.fs9p.append_file = async function(file,data){
|
|
|
|
|
|
|
|
const p = this.SearchPath(file);
|
|
|
|
|
|
|
|
if(p.id === -1)
|
|
|
|
{
|
|
|
|
return Promise.resolve(null);
|
|
|
|
}
|
|
|
|
|
|
|
|
const inode = this.GetInode(p.id);
|
2024-09-23 16:58:48 +02:00
|
|
|
const buf = typeof data == 'string' ? isoterminal.convert.toUint8Array(data) : data
|
2024-09-03 18:33:35 +02:00
|
|
|
await this.Write(p.id, inode.size, buf.length, buf )
|
|
|
|
// update inode
|
|
|
|
inode.size = inode.size + buf.length
|
|
|
|
const now = Math.round(Date.now() / 1000);
|
|
|
|
inode.atime = inode.mtime = now;
|
|
|
|
return new Promise( (resolve,reject) => resolve(buf) )
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|