2012-10-07 05:42:58 +00:00
|
|
|
<!DOCTYPE HTML>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<meta charset="utf-8" />
|
|
|
|
</head>
|
2012-10-11 06:20:58 +00:00
|
|
|
<body>
|
|
|
|
<div id="stdout"></div>
|
|
|
|
</body>
|
2012-10-07 05:42:58 +00:00
|
|
|
<script src="../lib/require.js"></script>
|
|
|
|
<script>
|
|
|
|
require.config({
|
|
|
|
baseUrl: "../lib",
|
|
|
|
paths: {
|
|
|
|
"src": "../src"
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2012-10-14 22:49:06 +00:00
|
|
|
require(["src/filesystem", "src/buffer"], function(IDBFS, Buffer) {
|
2012-10-11 06:20:58 +00:00
|
|
|
|
|
|
|
IDBFS.mount("default", function(error, fs) {
|
|
|
|
fs.mkdir("/tmp", function(error) {
|
2012-10-12 03:51:18 +00:00
|
|
|
fs.open("/tmp/0", "CREATE", "RW", function(error, fd) {
|
2012-10-12 21:46:12 +00:00
|
|
|
|
|
|
|
var writeBuffer = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]);
|
|
|
|
fd.write(writeBuffer, function(error, bytes_written, buffer) {
|
2012-10-12 15:35:39 +00:00
|
|
|
if(!error) {
|
2012-10-12 21:46:12 +00:00
|
|
|
console.log("bytes written:", bytes_written);
|
2012-10-12 15:35:39 +00:00
|
|
|
}
|
2012-10-13 15:06:17 +00:00
|
|
|
fs.dump(document.getElementById("stdout"), function() {
|
|
|
|
var readBuffer = new Uint8Array(8);
|
|
|
|
fd.seek(-bytes_written);
|
|
|
|
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"));
|
|
|
|
});
|
2012-10-12 22:54:12 +00:00
|
|
|
});
|
2012-10-12 21:46:12 +00:00
|
|
|
});
|
2012-10-13 15:06:17 +00:00
|
|
|
}, true);
|
2012-10-12 22:54:12 +00:00
|
|
|
});
|
2012-10-12 21:46:12 +00:00
|
|
|
|
2012-10-11 18:58:36 +00:00
|
|
|
});
|
2012-10-11 06:20:58 +00:00
|
|
|
});
|
2012-10-13 15:06:17 +00:00
|
|
|
}, IDBFS.FORMAT);
|
2012-10-11 06:20:58 +00:00
|
|
|
|
2012-10-07 05:42:58 +00:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
</html>
|