filer/examples/test5.html

35 lines
645 B
HTML
Raw Normal View History

2013-05-30 18:57:33 +00:00
var write_buffer = new Uint8Array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]);
var read_buffer = new Uint8Array(16);
2013-05-30 18:57:33 +00:00
var fs = new FileSystem('local');
2013-06-22 15:33:08 +00:00
fs.mkdir('/tmp');
fs.open('/tmp/', 'w+', function(error, fd) {
if(error) return console.error(error);
fs.write(fd, ...);
fs.read(fd, ...);
});
2013-05-30 18:57:33 +00:00
fs.then(
function() {
return this.mkdir('/tmp');
}
);
2013-05-30 18:57:33 +00:00
var fd = fs.open('/myfile.txt', fs.RW);
2013-05-30 18:57:33 +00:00
fd.then(
function() {
return this.write(write_buffer);
}
).then(
function(nbytes) {
this.seek(-nbytes);
return this.read(read_buffer);
}
).then(
function(nbytes) {
console.log(read_buffer);
}
);
});