filer/examples/refactoring-test.html

52 lines
1.1 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/file-system"], function(IDBFS) {
var flags = 'FORMAT';
//var flags;
var fs = new IDBFS.FileSystem('local', flags);
var buffer = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]);
console.log('buffer', buffer);
var data = new Uint8Array(buffer.length);
fs.open('/myfile', 'w+', function(error, fd) {
if(error) throw error;
console.log('descriptor:', fd);
fs.write(fd, buffer, 0, buffer.length, undefined, function(error, nbytes) {
console.log('write:', nbytes)
if(error) throw error;
fs.close(fd, function(error) {
if(error) throw error;
console.log('closed');
fs.write(fd, buffer, 0, buffer.length, undefined, function(error, nbytes) {
if(error) throw error;
console.log('write:', nbytes);
fs.stat('/myfile', function(error, stats) {
if(error) throw error;
console.log(stats);
});
});
});
});
});
});
</script>
</html>