Allow sending and downloading files from the 9p filesystem
This commit is contained in:
parent
36762e41fa
commit
747cec8aa1
12
debug.html
12
debug.html
|
@ -193,6 +193,18 @@
|
|||
<!-- Keyboard: <span id="info_keyboard_enabled">-</span><br> -->
|
||||
</div>
|
||||
|
||||
<div id="filesystem_panel" style="display: none">
|
||||
<label>
|
||||
Send files to emulator<br>
|
||||
<input type="file" id="filesystem_send_file" multiple>
|
||||
</label>
|
||||
<br><br>
|
||||
<label>
|
||||
Get file from emulator<br>
|
||||
<input type="text" id="filesystem_get_file" placeholder="Absolute path">
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<br style="clear:both"><br>
|
||||
|
||||
<textarea readonly id="log" style="display:none"></textarea>
|
||||
|
|
12
index.html
12
index.html
|
@ -171,6 +171,18 @@
|
|||
<!-- Keyboard: <span id="info_keyboard_enabled">-</span><br> -->
|
||||
</div>
|
||||
|
||||
<div id="filesystem_panel" style="display: none">
|
||||
<label title="Files will appear in / of the 9p filesystem">
|
||||
Send files to emulator<br>
|
||||
<input type="file" id="filesystem_send_file" multiple>
|
||||
</label>
|
||||
<br><br>
|
||||
<label>
|
||||
Get file from emulator<br>
|
||||
<input type="text" id="filesystem_get_file" placeholder="Absolute path">
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<br style="clear:both"><br>
|
||||
|
||||
<textarea cols="40" rows="12" id="serial" style="display: none">This is the serial console. Whatever you type or paste here will be send to COM1.
|
||||
|
|
|
@ -560,7 +560,7 @@
|
|||
debug_start(emulator);
|
||||
}
|
||||
|
||||
init_ui({}, emulator);
|
||||
init_ui(settings, emulator);
|
||||
|
||||
result.done(emulator);
|
||||
});
|
||||
|
@ -583,6 +583,11 @@
|
|||
$("runtime_infos").style.display = "block";
|
||||
document.getElementsByClassName("phone_keyboard")[0].style.display = "block";
|
||||
|
||||
if(settings.filesystem)
|
||||
{
|
||||
init_filesystem_panel(emulator);
|
||||
}
|
||||
|
||||
var news_element = $("news");
|
||||
if(news_element)
|
||||
{
|
||||
|
@ -915,6 +920,57 @@
|
|||
}
|
||||
}
|
||||
|
||||
function init_filesystem_panel(emulator)
|
||||
{
|
||||
$("filesystem_panel").style.display = "block";
|
||||
|
||||
$("filesystem_send_file").onchange = function()
|
||||
{
|
||||
Array.prototype.forEach.call(this.files, function(file)
|
||||
{
|
||||
var loader = new v86util.SyncFileBuffer(file);
|
||||
loader.onload = function()
|
||||
{
|
||||
loader.get_buffer(function(buffer)
|
||||
{
|
||||
emulator.create_file("/" + file.name, new Uint8Array(buffer));
|
||||
});
|
||||
};
|
||||
loader.load();
|
||||
}, this);
|
||||
|
||||
this.value = "";
|
||||
};
|
||||
|
||||
$("filesystem_get_file").onkeypress = function(e)
|
||||
{
|
||||
if(e.which !== 13)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this.disabled = true;
|
||||
|
||||
emulator.read_file(this.value, function(err, uint8array)
|
||||
{
|
||||
this.disabled = false;
|
||||
|
||||
if(uint8array)
|
||||
{
|
||||
var filename = this.value.replace(/\/$/, "").split("/");
|
||||
filename = filename[filename.length - 1] || "root";
|
||||
|
||||
dump_file(uint8array.buffer, filename);
|
||||
this.value = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
alert("Can't read file");
|
||||
}
|
||||
}.bind(this));
|
||||
};
|
||||
}
|
||||
|
||||
function debug_start(emulator)
|
||||
{
|
||||
// called as soon as soon as emulation is started, in debug mode
|
||||
|
|
Loading…
Reference in a new issue