Handle empty files with fs.readFile

This commit is contained in:
Elijah Insua authored and Ryan Dahl committed 2010-05-13 12:42:17 -07:00
1 parent c6c77d535f
commit 976926376d
3 files changed
+14

No files matched your search

+4
View File
@@ -51,6 +51,10 @@ fs.readFile = function (path, encoding_, callback) {
var buffer = new Buffer(size);
var offset = 0;
function doRead() {
if (size < 1) {
callback(null, buffer);
return;
}
// position is offset or null so we can read files on unseekable mediums
binding.read(fd, buffer, offset, size - offset, offset || null, function (err, amount) {
if (err) {
View File
Whitespace-only changes.
+10
View File
@@ -0,0 +1,10 @@
require('../common');
var
path = require('path'),
fs = require('fs'),
fn = path.join(fixturesDir, 'empty.txt');
fs.readFile(fn, function(err, data) {
assert.ok(data);
});