diff options
author | Joyee Cheung <joyeec9h3@gmail.com> | 2018-04-07 17:01:06 +0800 |
---|---|---|
committer | Joyee Cheung <joyeec9h3@gmail.com> | 2018-06-07 22:05:23 +0800 |
commit | 1e7645c39ae5213a44267cff3d599264c2211f1a (patch) | |
tree | a000944a7267c0ad8b0dfe325d93f34f564844ed /src/node_file.h | |
parent | af2a1045631028dfad0dd5d3eb4c4866fdf55730 (diff) | |
download | node-new-1e7645c39ae5213a44267cff3d599264c2211f1a.tar.gz |
fs: support BigInt in fs.*stat and fs.watchFile
Add the `bigint: true` option to all the `fs.*stat` methods and
`fs.watchFile`.
PR-URL: https://github.com/nodejs/node/pull/20220
Fixes: https://github.com/nodejs/node/issues/12115
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'src/node_file.h')
-rw-r--r-- | src/node_file.h | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/node_file.h b/src/node_file.h index 03e41097d5..a14a1b0f85 100644 --- a/src/node_file.h +++ b/src/node_file.h @@ -26,8 +26,9 @@ class FSReqBase : public ReqWrap<uv_fs_t> { public: typedef MaybeStackBuffer<char, 64> FSReqBuffer; - FSReqBase(Environment* env, Local<Object> req, AsyncWrap::ProviderType type) - : ReqWrap(env, req, type) { + FSReqBase(Environment* env, Local<Object> req, AsyncWrap::ProviderType type, + bool use_bigint) + : ReqWrap(env, req, type), use_bigint_(use_bigint) { } void Init(const char* syscall, @@ -66,11 +67,13 @@ class FSReqBase : public ReqWrap<uv_fs_t> { enum encoding encoding() const { return encoding_; } size_t self_size() const override { return sizeof(*this); } + bool use_bigint() const { return use_bigint_; } private: enum encoding encoding_ = UTF8; bool has_data_ = false; const char* syscall_ = nullptr; + bool use_bigint_ = false; // Typically, the content of buffer_ is something like a file name, so // something around 64 bytes should be enough. @@ -81,8 +84,8 @@ class FSReqBase : public ReqWrap<uv_fs_t> { class FSReqWrap : public FSReqBase { public: - FSReqWrap(Environment* env, Local<Object> req) - : FSReqBase(env, req, AsyncWrap::PROVIDER_FSREQWRAP) { } + FSReqWrap(Environment* env, Local<Object> req, bool use_bigint) + : FSReqBase(env, req, AsyncWrap::PROVIDER_FSREQWRAP, use_bigint) { } void Reject(Local<Value> reject) override; void Resolve(Local<Value> value) override; @@ -96,11 +99,12 @@ class FSReqWrap : public FSReqBase { template <typename NativeT = double, typename V8T = v8::Float64Array> class FSReqPromise : public FSReqBase { public: - explicit FSReqPromise(Environment* env) + explicit FSReqPromise(Environment* env, bool use_bigint) : FSReqBase(env, env->fsreqpromise_constructor_template() ->NewInstance(env->context()).ToLocalChecked(), - AsyncWrap::PROVIDER_FSREQPROMISE), + AsyncWrap::PROVIDER_FSREQPROMISE, + use_bigint), stats_field_array_(env->isolate(), env->kFsStatsFieldsLength) { auto resolver = Promise::Resolver::New(env->context()).ToLocalChecked(); object()->Set(env->context(), env->promise_string(), @@ -135,8 +139,7 @@ class FSReqPromise : public FSReqBase { } void ResolveStat(const uv_stat_t* stat) override { - node::FillStatsArray(&stats_field_array_, stat); - Resolve(stats_field_array_.GetJSArray()); + Resolve(node::FillStatsArray(&stats_field_array_, stat)); } void SetReturnValue(const FunctionCallbackInfo<Value>& args) override { |