50 lines
1.2 KiB
HTML
50 lines
1.2 KiB
HTML
<!DOCTYPE HTML>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
</head>
|
|
<body>
|
|
<div id="stdout"></div>
|
|
</body>
|
|
<script src="../lib/require.js"></script>
|
|
<script>
|
|
require.config({
|
|
baseUrl: "../lib",
|
|
paths: {
|
|
"src": "../src"
|
|
}
|
|
});
|
|
|
|
require(["src/filesystem"], function(IDBFS) {
|
|
|
|
IDBFS.mount("default", function(error, fs) {
|
|
fs.mkdir("/tmp", function(error) {
|
|
fs.open("/tmp/0", "CREATE", "RW", function(error, fd) {
|
|
|
|
var writeBuffer = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]);
|
|
fd.write(writeBuffer, function(error, bytes_written, buffer) {
|
|
if(!error) {
|
|
console.log("bytes written:", bytes_written);
|
|
}
|
|
fd.seek(-bytes_written);
|
|
var readBuffer = new Uint8Array(8);
|
|
fd.read(readBuffer, function(error, bytes_read, buffer) {
|
|
if(!error) {
|
|
console.log("bytes read:", bytes_read);
|
|
console.log("buffer:", buffer);
|
|
}
|
|
fs.close(fd, function(error) {
|
|
fs.unlink("/tmp/0", function(error) {
|
|
fs.dump(document.getElementById("stdout"));
|
|
});
|
|
});
|
|
});
|
|
});
|
|
|
|
});
|
|
});
|
|
}, true);
|
|
|
|
});
|
|
</script>
|
|
</html> |