From 33ae820937ba42bd0aa582a387b6506d4f9656f0 Mon Sep 17 00:00:00 2001 From: zhuhongtao66 Date: Wed, 23 Nov 2022 11:05:16 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=9B=9E=E5=90=88monthly]write=E5=BC=82?= =?UTF-8?q?=E6=AD=A5=E5=8F=82=E6=95=B0=E8=B5=8B=E7=A9=BA=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E8=A7=84=E9=81=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhuhongtao66 --- .../kits/js/src/mod_fileio/properties/prop_n_exporter.cpp | 5 +++-- .../kits/js/src/mod_fileio/properties/prop_n_exporter_v9.cpp | 5 +++-- interfaces/kits/js/src/mod_fileio/properties/read_text.cpp | 4 ++++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/interfaces/kits/js/src/mod_fileio/properties/prop_n_exporter.cpp b/interfaces/kits/js/src/mod_fileio/properties/prop_n_exporter.cpp index e7fbbb12e..a7a1acbac 100644 --- a/interfaces/kits/js/src/mod_fileio/properties/prop_n_exporter.cpp +++ b/interfaces/kits/js/src/mod_fileio/properties/prop_n_exporter.cpp @@ -510,7 +510,7 @@ napi_value PropNExporter::Read(napi_env env, napi_callback_info info) bool hasOp = false; if (argc == NARG_CNT::THREE) { NVal op = NVal(env, funcArg[NARG_POS::THIRD]); - if (op.HasProp("offset") || op.HasProp("position") || op.HasProp("length")) { + if (op.HasProp("offset") || op.HasProp("position") || op.HasProp("length")|| !op.TypeIs(napi_function)) { hasOp = true; } } @@ -589,7 +589,8 @@ napi_value PropNExporter::Write(napi_env env, napi_callback_info info) size_t argc = funcArg.GetArgc(); if (argc == NARG_CNT::THREE) { NVal op = NVal(env, funcArg[NARG_POS::THIRD]); - if (op.HasProp("offset") || op.HasProp("position") || op.HasProp("length") || op.HasProp("encoding")) { + if (op.HasProp("offset") || op.HasProp("position") || op.HasProp("length") || + op.HasProp("encoding") || !op.TypeIs(napi_function)) { hasOp = true; } } diff --git a/interfaces/kits/js/src/mod_fileio/properties/prop_n_exporter_v9.cpp b/interfaces/kits/js/src/mod_fileio/properties/prop_n_exporter_v9.cpp index bd27e241c..0c94dcc94 100644 --- a/interfaces/kits/js/src/mod_fileio/properties/prop_n_exporter_v9.cpp +++ b/interfaces/kits/js/src/mod_fileio/properties/prop_n_exporter_v9.cpp @@ -135,7 +135,7 @@ napi_value PropNExporterV9::Read(napi_env env, napi_callback_info info) bool hasOp = false; if (funcArg.GetArgc() == NARG_CNT::THREE) { NVal op = NVal(env, funcArg[NARG_POS::THIRD]); - if (op.HasProp("offset") || op.HasProp("length")) { + if (op.HasProp("offset") || op.HasProp("length")|| !op.TypeIs(napi_function)) { hasOp = true; } } @@ -215,7 +215,8 @@ napi_value PropNExporterV9::Write(napi_env env, napi_callback_info info) bool hasOp = false; if (funcArg.GetArgc() == NARG_CNT::THREE) { NVal op = NVal(env, funcArg[NARG_POS::THIRD]); - if (op.HasProp("offset") || op.HasProp("position") || op.HasProp("length") || op.HasProp("encoding")) { + if (op.HasProp("offset") || op.HasProp("position") || op.HasProp("length") || + op.HasProp("encoding") || !op.TypeIs(napi_function)) { hasOp = true; } } diff --git a/interfaces/kits/js/src/mod_fileio/properties/read_text.cpp b/interfaces/kits/js/src/mod_fileio/properties/read_text.cpp index 331227632..afd1135f5 100644 --- a/interfaces/kits/js/src/mod_fileio/properties/read_text.cpp +++ b/interfaces/kits/js/src/mod_fileio/properties/read_text.cpp @@ -65,6 +65,10 @@ static tuple, bool> GetReadText hasOp = true; } + if (!op.TypeIs(napi_function)) { + hasOp = true; + } + return { true, position, hasLen, len, move(encoding), hasOp }; } -- Gitee