v0.0.23
This commit is contained in:
parent
a467711c90
commit
3e9b77a37a
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "filer",
|
"name": "filer",
|
||||||
"version": "0.0.22",
|
"version": "0.0.23",
|
||||||
"main": "dist/filer.js",
|
"main": "dist/filer.js",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"mocha": "1.17.1",
|
"mocha": "1.17.1",
|
||||||
|
|
|
@ -13942,7 +13942,7 @@ function readFile(fs, context, path, options, callback) {
|
||||||
|
|
||||||
var flags = validate_flags(options.flag || 'r');
|
var flags = validate_flags(options.flag || 'r');
|
||||||
if(!flags) {
|
if(!flags) {
|
||||||
callback(new Errors.EINVAL('flags is not valid'));
|
return callback(new Errors.EINVAL('flags is not valid'));
|
||||||
}
|
}
|
||||||
|
|
||||||
open_file(context, path, flags, function(err, fileNode) {
|
open_file(context, path, flags, function(err, fileNode) {
|
||||||
|
@ -13952,21 +13952,33 @@ function readFile(fs, context, path, options, callback) {
|
||||||
var ofd = new OpenFileDescription(path, fileNode.id, flags, 0);
|
var ofd = new OpenFileDescription(path, fileNode.id, flags, 0);
|
||||||
var fd = fs.allocDescriptor(ofd);
|
var fd = fs.allocDescriptor(ofd);
|
||||||
|
|
||||||
fstat_file(context, ofd, function(err2, fstatResult) {
|
function cleanup() {
|
||||||
if(err2) {
|
fs.releaseDescriptor(fd);
|
||||||
return callback(err2);
|
}
|
||||||
|
|
||||||
|
fstat_file(context, ofd, function(err, fstatResult) {
|
||||||
|
if(err) {
|
||||||
|
cleanup();
|
||||||
|
return callback(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
var stats = new Stats(fstatResult, fs.name);
|
var stats = new Stats(fstatResult, fs.name);
|
||||||
|
|
||||||
|
if(stats.isDirectory()) {
|
||||||
|
cleanup();
|
||||||
|
return callback(new Errors.EISDIR('illegal operation on directory'));
|
||||||
|
}
|
||||||
|
|
||||||
var size = stats.size;
|
var size = stats.size;
|
||||||
var buffer = new Buffer(size);
|
var buffer = new Buffer(size);
|
||||||
buffer.fill(0);
|
buffer.fill(0);
|
||||||
|
|
||||||
read_data(context, ofd, buffer, 0, size, 0, function(err3, nbytes) {
|
read_data(context, ofd, buffer, 0, size, 0, function(err, nbytes) {
|
||||||
if(err3) {
|
cleanup();
|
||||||
return callback(err3);
|
|
||||||
|
if(err) {
|
||||||
|
return callback(err);
|
||||||
}
|
}
|
||||||
fs.releaseDescriptor(fd);
|
|
||||||
|
|
||||||
var data;
|
var data;
|
||||||
if(options.encoding === 'utf8') {
|
if(options.encoding === 'utf8') {
|
||||||
|
@ -14023,11 +14035,12 @@ function writeFile(fs, context, path, data, options, callback) {
|
||||||
var ofd = new OpenFileDescription(path, fileNode.id, flags, 0);
|
var ofd = new OpenFileDescription(path, fileNode.id, flags, 0);
|
||||||
var fd = fs.allocDescriptor(ofd);
|
var fd = fs.allocDescriptor(ofd);
|
||||||
|
|
||||||
replace_data(context, ofd, data, 0, data.length, function(err2, nbytes) {
|
replace_data(context, ofd, data, 0, data.length, function(err, nbytes) {
|
||||||
if(err2) {
|
|
||||||
return callback(err2);
|
|
||||||
}
|
|
||||||
fs.releaseDescriptor(fd);
|
fs.releaseDescriptor(fd);
|
||||||
|
|
||||||
|
if(err) {
|
||||||
|
return callback(err);
|
||||||
|
}
|
||||||
callback(null);
|
callback(null);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -14059,11 +14072,12 @@ function appendFile(fs, context, path, data, options, callback) {
|
||||||
var ofd = new OpenFileDescription(path, fileNode.id, flags, fileNode.size);
|
var ofd = new OpenFileDescription(path, fileNode.id, flags, fileNode.size);
|
||||||
var fd = fs.allocDescriptor(ofd);
|
var fd = fs.allocDescriptor(ofd);
|
||||||
|
|
||||||
write_data(context, ofd, data, 0, data.length, ofd.position, function(err2, nbytes) {
|
write_data(context, ofd, data, 0, data.length, ofd.position, function(err, nbytes) {
|
||||||
if(err2) {
|
|
||||||
return callback(err2);
|
|
||||||
}
|
|
||||||
fs.releaseDescriptor(fd);
|
fs.releaseDescriptor(fd);
|
||||||
|
|
||||||
|
if(err) {
|
||||||
|
return callback(err);
|
||||||
|
}
|
||||||
callback(null);
|
callback(null);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -11,7 +11,7 @@
|
||||||
"idb",
|
"idb",
|
||||||
"websql"
|
"websql"
|
||||||
],
|
],
|
||||||
"version": "0.0.22",
|
"version": "0.0.23",
|
||||||
"author": "Alan K <ack@modeswitch.org> (http://blog.modeswitch.org)",
|
"author": "Alan K <ack@modeswitch.org> (http://blog.modeswitch.org)",
|
||||||
"homepage": "http://js-platform.github.io/filer",
|
"homepage": "http://js-platform.github.io/filer",
|
||||||
"bugs": "https://github.com/js-platform/filer/issues",
|
"bugs": "https://github.com/js-platform/filer/issues",
|
||||||
|
|
Loading…
Reference in New Issue