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-11-08 05:12:41 +00:00
|
|
|
require(["src/fs"], function(IDBFS) {
|
2012-10-11 06:20:58 +00:00
|
|
|
|
2012-11-15 15:57:55 +00:00
|
|
|
IDBFS.mount("default", "format", function(error, fs) {
|
2012-11-08 05:12:41 +00:00
|
|
|
if(error) {
|
2012-11-09 16:10:55 +00:00
|
|
|
return console.error(error);
|
2012-11-08 05:12:41 +00:00
|
|
|
}
|
|
|
|
fs.mkdir("/tmp", function() {
|
2012-11-08 10:29:05 +00:00
|
|
|
if(error) {
|
2012-11-09 16:10:55 +00:00
|
|
|
return console.error(error);
|
2012-11-08 10:29:05 +00:00
|
|
|
}
|
|
|
|
fs.stat("/tmp", function(error, result) {
|
|
|
|
if(error) {
|
2012-11-09 16:10:55 +00:00
|
|
|
return console.error(error);
|
2012-11-08 10:29:05 +00:00
|
|
|
}
|
2012-11-14 00:05:57 +00:00
|
|
|
console.info("stat /tmp", result);
|
2012-11-09 16:10:55 +00:00
|
|
|
fs.open("/tmp/0", "create", "rw", function(error, fd) {
|
|
|
|
if(error) {
|
|
|
|
return console.error(error);
|
|
|
|
}
|
2012-11-14 00:05:57 +00:00
|
|
|
var writeBuffer = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]);
|
|
|
|
fd.write(writeBuffer, function(error, bytes_written, buffer) {
|
2012-11-09 16:10:55 +00:00
|
|
|
if(error) {
|
|
|
|
return console.error(error);
|
|
|
|
}
|
2012-11-14 00:05:57 +00:00
|
|
|
console.info("bytes written:", bytes_written);
|
|
|
|
var readBuffer = new Uint8Array(8);
|
|
|
|
fd.seek(-bytes_written, "current", function(error) {
|
|
|
|
if(error) {
|
|
|
|
return console.error(error);
|
|
|
|
}
|
|
|
|
fd.read(readBuffer, function(error, bytes_read, buffer) {
|
|
|
|
if(error) {
|
|
|
|
return console.error(error);
|
|
|
|
}
|
|
|
|
console.info("bytes read:", bytes_read);
|
|
|
|
console.info("buffer:", buffer);
|
|
|
|
fs.close(fd, function(error) {
|
|
|
|
fs.stat("/tmp/0", function(error, result) {
|
|
|
|
if(error) {
|
|
|
|
return console.error(error);
|
|
|
|
}
|
|
|
|
console.info("stat /tmp/0", result);
|
2012-11-14 16:19:04 +00:00
|
|
|
fs.link("/tmp/0", "/tmp/1", function(error) {
|
|
|
|
if(error) {
|
|
|
|
return console.error(error);
|
|
|
|
}
|
|
|
|
fs.stat("/tmp/1", function(error, result) {
|
|
|
|
if(error) {
|
|
|
|
return console.error(error);
|
|
|
|
}
|
|
|
|
console.info("stat /tmp/1", result);
|
|
|
|
fs.unlink("/tmp/0", function(error) {
|
|
|
|
if(error) {
|
|
|
|
return console.error(error);
|
|
|
|
}
|
|
|
|
fs.stat("/tmp/1", function(error, result) {
|
|
|
|
if(error) {
|
|
|
|
return console.error(error);
|
|
|
|
}
|
|
|
|
console.info("stat /tmp/1", result);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2012-11-14 00:05:57 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2012-11-09 16:10:55 +00:00
|
|
|
});
|
|
|
|
});
|
2012-11-08 10:29:05 +00:00
|
|
|
});
|
2012-10-11 06:20:58 +00:00
|
|
|
});
|
2012-11-08 05:12:41 +00:00
|
|
|
});
|
2012-10-11 06:20:58 +00:00
|
|
|
|
2012-10-07 05:42:58 +00:00
|
|
|
});
|
|
|
|
</script>
|
2012-10-15 15:33:56 +00:00
|
|
|
</html>
|