fix: bin/save

This commit is contained in:
Leon van Kammen 2025-04-08 18:42:07 +02:00
parent 5261353fca
commit a918280211
2 changed files with 12 additions and 7 deletions

View file

@ -19,15 +19,20 @@ state(){
file(){ file(){
javascript=' javascript='
filename='$1' filename="'$(pwd)/$1'"
res = ""
function saveUint8Array(uint8Array, filename = 'download.bin', mimeType = 'application/octet-stream') { function saveUint8Array(uint8Array, filename = "download.bin", mimeType = "application/octet-stream") {
if( !uint8Array ){
console.log( res = "file not found" )
return false
}
const blob = new Blob([uint8Array], { type: mimeType }); const blob = new Blob([uint8Array], { type: mimeType });
const url = URL.createObjectURL(blob); const url = URL.createObjectURL(blob);
const a = document.createElement('a'); const a = document.createElement("a");
a.href = url; a.href = url;
a.download = filename; a.download = filename.replace(/.*\//,"");
// Programmatically trigger the click event // Programmatically trigger the click event
document.body.appendChild(a); document.body.appendChild(a);
@ -39,9 +44,9 @@ file(){
} }
let term = document.querySelector("[isoterminal]") let term = document.querySelector("[isoterminal]")
term.emit("read_file", [filename, (str,buf) > saveUint8Array(buf, filename) ) term.emit("read_file", [filename, (str,buf) => saveUint8Array(buf, filename) ] )
return "" return res
' '
hook save hook save
js "$javascript" js "$javascript"
@ -49,5 +54,5 @@ file(){
} }
test -z "$1" && state test -z "$1" && state
test -n "$1" && file test -n "$1" && file "$1"
echo "Usage: save [file] # pass no argument to save VM state to localStorage" echo "Usage: save [file] # pass no argument to save VM state to localStorage"

BIN
dist/v86-linux.iso vendored

Binary file not shown.