2013-05-30 18:57:33 +00:00
|
|
|
<!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"
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2013-05-31 01:38:44 +00:00
|
|
|
require(["src/file-system"], function(IDBFS) {
|
2013-05-30 18:57:33 +00:00
|
|
|
|
|
|
|
var flags = 'FORMAT';
|
2013-07-12 15:11:05 +00:00
|
|
|
//var flags;
|
2013-05-30 18:57:33 +00:00
|
|
|
|
2013-05-31 15:30:01 +00:00
|
|
|
var fs = new IDBFS.FileSystem('local', flags);
|
2013-07-12 15:11:05 +00:00
|
|
|
fs.stat('/', function(error, result) {
|
|
|
|
console.log('stat /', error, result);
|
|
|
|
});
|
|
|
|
fs.stat('/tmp', function(error, result) {
|
|
|
|
console.log('stat /tmp', error, result);
|
|
|
|
});
|
|
|
|
/*
|
|
|
|
fs.mkdir('/tmp', function(error) {
|
|
|
|
if(error) throw error;
|
|
|
|
fs.stat('/tmp', function(error, result) {
|
|
|
|
console.log('stat /tmp', error, result);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
*/
|
2013-05-30 18:57:33 +00:00
|
|
|
|
2013-07-12 15:11:05 +00:00
|
|
|
/*
|
2013-05-30 18:57:33 +00:00
|
|
|
function make_tmp_directory() {
|
|
|
|
return fs.mkdir('/tmp');
|
|
|
|
};
|
|
|
|
|
2013-05-30 22:49:31 +00:00
|
|
|
function remove_tmp_directory() {
|
|
|
|
return fs.rmdir('/tmp');
|
|
|
|
};
|
|
|
|
|
2013-05-31 07:52:04 +00:00
|
|
|
function create_tmp_file() {
|
2013-05-31 19:03:18 +00:00
|
|
|
return fs.open('/tmp/1', 'w+');
|
2013-05-31 07:52:04 +00:00
|
|
|
};
|
|
|
|
|
2013-06-22 15:33:08 +00:00
|
|
|
function print_fd(fd) {
|
|
|
|
console.log(fd);
|
|
|
|
return fd;
|
|
|
|
};
|
|
|
|
|
|
|
|
function write_data(fd) {
|
|
|
|
var data = new Uint8Array([1, 2, 3, 4]);
|
|
|
|
return fs.write(fd, data, 0, 4);
|
|
|
|
};
|
|
|
|
|
|
|
|
function close_tmp_file(fd) {
|
|
|
|
return fs.close(fd);
|
|
|
|
};
|
|
|
|
|
2013-05-30 22:49:31 +00:00
|
|
|
fs.promise.then(make_tmp_directory)
|
2013-06-22 15:33:08 +00:00
|
|
|
.then(function() {
|
|
|
|
var fd = fs.open('/tmp/1', 'w+');
|
|
|
|
|
|
|
|
function write_data() {
|
|
|
|
var data = new Uint8Array([1, 2, 3, 4]);
|
|
|
|
return fs.write(fd, data, 0, 4);
|
|
|
|
};
|
|
|
|
|
|
|
|
fd.promise.then(write_data);
|
|
|
|
})
|
2013-05-31 07:52:04 +00:00
|
|
|
.then(create_tmp_file)
|
2013-06-22 15:33:08 +00:00
|
|
|
.then(print_fd)
|
|
|
|
.then(write_data)
|
2013-05-30 22:49:31 +00:00
|
|
|
.then(function() { console.log('done'); })
|
2013-06-22 15:33:08 +00:00
|
|
|
.otherwise(function(error) { console.error(error, error.message, error.stack); });
|
2013-07-12 15:11:05 +00:00
|
|
|
*/
|
2013-05-30 18:57:33 +00:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
</html>
|