fix for fs.readFile to return string when encoding specified on zero length read
This commit is contained in:
parent
9c7c6e93e1
commit
af9aa93e0c
@ -56,7 +56,7 @@ fs.readFile = function (path, encoding_, callback) {
|
|||||||
function doRead() {
|
function doRead() {
|
||||||
if (size < 1) {
|
if (size < 1) {
|
||||||
binding.close(fd);
|
binding.close(fd);
|
||||||
callback(null, buffer);
|
callback(null, encoding ? '' : buffer);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// position is offset or null so we can read files on unseekable mediums
|
// position is offset or null so we can read files on unseekable mediums
|
||||||
|
@ -9,3 +9,7 @@ var
|
|||||||
fs.readFile(fn, function(err, data) {
|
fs.readFile(fn, function(err, data) {
|
||||||
assert.ok(data);
|
assert.ok(data);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
fs.readFile(fn, 'utf8', function(err, data) {
|
||||||
|
assert.strictEqual('', data);
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user