commit c721aeb101f25c169854fea892c4f6f3a409aec6
Author: Tom Hughes <tom@compton.nu>
Date: Fri Jul 20 15:40:30 2018 +0100
Fix stat calls to work with changes in Node 10
diff --git a/lib/binding.js b/lib/binding.js
index 8d2ed6e..28ff37f 100644
--- a/lib/binding.js
+++ b/lib/binding.js
@@ -329,7 +329,11 @@ function fillStatsArray(stats, statValues) {
* that should be filled with stat values.
* @return {Stats|undefined} Stats or undefined (if sync).
*/
-Binding.prototype.stat = function(filepath, callback) {
+Binding.prototype.stat = function(filepath, options, callback) {
+ if (arguments.length < 3) {
+ callback = options;
+ options = {};
+ }
return maybeCallback(wrapStatsCallback(callback), this, function() {
var item = this._system.getItem(filepath);
if (item instanceof SymbolicLink) {
@@ -345,7 +349,8 @@ Binding.prototype.stat = function(filepath, callback) {
// In Node 7.7.0+, binding.stat accepts a Float64Array as the second argument,
// which should be filled with stat values.
// In prior versions of Node, binding.stat simply returns a Stats instance.
- if (callback instanceof Float64Array) {
+ if (callback instanceof Float64Array ||
+ callback instanceof BigUint64Array) {
fillStatsArray(stats, callback);
} else {
fillStatsArray(stats, statValues);
@@ -361,7 +366,11 @@ Binding.prototype.stat = function(filepath, callback) {
* that should be filled with stat values.
* @return {Stats|undefined} Stats or undefined (if sync).
*/
-Binding.prototype.fstat = function(fd, callback) {
+Binding.prototype.fstat = function(fd, options, callback) {
+ if (arguments.length < 3) {
+ callback = options;
+ options = {};
+ }
return maybeCallback(wrapStatsCallback(callback), this, function() {
var descriptor = this._getDescriptorById(fd);
var item = descriptor.getItem();
@@ -370,7 +379,8 @@ Binding.prototype.fstat = function(fd, callback) {
// In Node 7.7.0+, binding.stat accepts a Float64Array as the second argument,
// which should be filled with stat values.
// In prior versions of Node, binding.stat simply returns a Stats instance.
- if (callback instanceof Float64Array) {
+ if (callback instanceof Float64Array ||
+ callback instanceof BigUint64Array) {
fillStatsArray(stats, callback);
} else {
fillStatsArray(stats, statValues);
@@ -1070,7 +1080,11 @@ Binding.prototype.readlink = function(pathname, encoding, callback) {
* that should be filled with stat values.
* @return {Stats|undefined} Stats or undefined (if sync).
*/
-Binding.prototype.lstat = function(filepath, callback) {
+Binding.prototype.lstat = function(filepath, options, callback) {
+ if (arguments.length < 3) {
+ callback = options;
+ options = {};
+ }
return maybeCallback(wrapStatsCallback(callback), this, function() {
var item = this._system.getItem(filepath);
if (!item) {
@@ -1081,7 +1095,8 @@ Binding.prototype.lstat = function(filepath, callback) {
// In Node 7.7.0+, binding.stat accepts a Float64Array as the second argument,
// which should be filled with stat values.
// In prior versions of Node, binding.stat simply returns a Stats instance.
- if (callback instanceof Float64Array) {
+ if (callback instanceof Float64Array ||
+ callback instanceof BigUint64Array) {
fillStatsArray(stats, callback);
} else {
fillStatsArray(stats, statValues);