Added support for readdir().

This commit is contained in:
Alan Kligman 2012-11-30 13:51:56 -05:00
parent 9053d67146
commit b1b94d91a9
2 changed files with 67 additions and 0 deletions

67
examples/idbfs-test2.html Normal file
View File

@ -0,0 +1,67 @@
<!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/fs"], function(IDBFS) {
IDBFS.mount("default", "format", function(error, fs) {
if(error) {
return console.error(error);
}
fs.mkdir("/tmp", function(error) {
if(error) {
return console.error(error);
}
fs.stat("/tmp", function(error, result) {
if(error) {
return console.error(error);
}
console.info("stat /tmp", result);
fs.open("/tmp/file-0", "create", "rw", function(error, fd) {
if(error) {
return console.error(error);
}
fs.link("/tmp/file-0", "/tmp/file-1", function(error) {
if(error) {
return console.error(error);
}
fs.stat("/tmp", function(error, result) {
if(error) {
return console.error(error);
}
console.info("stat /tmp", result);
fs.open("/tmp", "", "ro", function(error, fd) {
if(error) {
return console.error(error);
}
var dirBuffer = [];
fd.readdir(dirBuffer, 4, function(error, count, buffer) {
if(error) {
return console.error(error);
}
console.info(count, buffer);
});
});
});
});
});
});
});
});
});
</script>
</html>