mirror of
https://github.com/nodejs/node.git
synced 2026-11-21 12:59:16 -05:00
Add binding.close to fs.readFile
This commit is contained in:
1 parent
c07c601c3b
commit
bc45adcffa
1 file changed
+6
-1
@@ -53,12 +53,17 @@ fs.readFile = function (path, encoding_, callback) {
|
||||
function doRead() {
|
||||
// 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) { callback(err); return; }
|
||||
if (err) {
|
||||
callback(err);
|
||||
binding.close(fd);
|
||||
return;
|
||||
}
|
||||
if (amount + offset < size) {
|
||||
offset += amount;
|
||||
doRead();
|
||||
return;
|
||||
}
|
||||
binding.close(fd);
|
||||
if (encoding) {
|
||||
try {
|
||||
callback(null, buffer.toString(encoding));
|
||||
|
||||
Reference in new issue
Block a user