fix: bin/save
This commit is contained in:
parent
5261353fca
commit
a918280211
2 changed files with 12 additions and 7 deletions
|
|
@ -19,15 +19,20 @@ state(){
|
|||
file(){
|
||||
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 url = URL.createObjectURL(blob);
|
||||
|
||||
const a = document.createElement('a');
|
||||
const a = document.createElement("a");
|
||||
a.href = url;
|
||||
a.download = filename;
|
||||
a.download = filename.replace(/.*\//,"");
|
||||
|
||||
// Programmatically trigger the click event
|
||||
document.body.appendChild(a);
|
||||
|
|
@ -39,9 +44,9 @@ file(){
|
|||
}
|
||||
|
||||
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
|
||||
js "$javascript"
|
||||
|
|
@ -49,5 +54,5 @@ file(){
|
|||
}
|
||||
|
||||
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"
|
||||
|
|
|
|||
BIN
dist/v86-linux.iso
vendored
BIN
dist/v86-linux.iso
vendored
Binary file not shown.
Loading…
Add table
Reference in a new issue