Using st_size to read non-regular files can lead to not reading all the
data.
PR-URL: https://github.com/iojs/io.js/pull/1074
Reviewed-By: Bert Belder <bertbelder@gmail.com>
if (err)
return context.close(err);
- var size = context.size = st.size;
+ var size = context.size = st.isFile() ? st.size : 0;
if (size === 0) {
context.buffers = [];
var flag = options.flag || 'r';
var fd = fs.openSync(path, flag, 0o666);
+ var st;
var size;
var threw = true;
try {
- size = fs.fstatSync(fd).size;
+ st = fs.fstatSync(fd);
+ size = st.isFile() ? st.size : 0;
threw = false;
} finally {
if (threw) fs.closeSync(fd);