diff --git a/interfaces/kits/js/src/mod_fileio/class_dir/dir_n_exporter.cpp b/interfaces/kits/js/src/mod_fileio/class_dir/dir_n_exporter.cpp index 30d8295277d7c630b5d2b0b4d4fd189ec95232c5..7f04651a3295880471e96087c6c6a2a1c16d7d14 100644 --- a/interfaces/kits/js/src/mod_fileio/class_dir/dir_n_exporter.cpp +++ b/interfaces/kits/js/src/mod_fileio/class_dir/dir_n_exporter.cpp @@ -171,31 +171,10 @@ napi_value DirNExporter::Read(napi_env env, napi_callback_info info) auto cbExec = [arg, dir, dirEntity](napi_env env) -> UniError { struct dirent tmpDirent; lock_guard(dirEntity->lock_); - char dirBuff[DIR_BUFF_LEN]; - (void)memset_s(dirBuff, DIR_BUFF_LEN, 0x00, DIR_BUFF_LEN); - - if (EOK == memcpy_s(dirBuff, DIR_BUFF_LEN, dir, DIR_BUFF_LEN - 1)) { - HILOGE("[0]struct DIR member fd = %{public}02x-%{public}02x-%{public}02x-%{public}02x," - "buf_pos = %{public}02x-%{public}02x-%{public}02x-%{public}02x," - "buf_end = %{public}02x-%{public}02x-%{public}02x-%{public}02x", - dirBuff[8], dirBuff[9], dirBuff[10], dirBuff[11], dirBuff[12], dirBuff[13], dirBuff[14], - dirBuff[15], dirBuff[16], dirBuff[17], dirBuff[18], dirBuff[19]); - } errno = 0; dirent *res = nullptr; do { res = readdir(dir); - if (res != nullptr) { - HILOGE("res filelength = %{public}u, type = %{public}d", res->d_reclen, res->d_type); - } - - if (EOK == memcpy_s(dirBuff, DIR_BUFF_LEN, dir, DIR_BUFF_LEN - 1)) { - HILOGE("struct DIR member fd = %{public}02x-%{public}02x-%{public}02x-%{public}02x," - "buf_pos = %{public}02x-%{public}02x-%{public}02x-%{public}02x," - "buf_end = %{public}02x-%{public}02x-%{public}02x-%{public}02x", - dirBuff[8], dirBuff[9], dirBuff[10], dirBuff[11], dirBuff[12], dirBuff[13], - dirBuff[14], dirBuff[15], dirBuff[16], dirBuff[17], dirBuff[18], dirBuff[19]); - } if (res == nullptr && errno) { return UniError(errno); } else if (res == nullptr) { @@ -228,9 +207,6 @@ napi_value DirNExporter::Read(napi_env env, napi_callback_info info) napi_value DirNExporter::ReadSync(napi_env env, napi_callback_info info) { - char dirBuff[DIR_BUFF_LEN]; - (void)memset_s(dirBuff, DIR_BUFF_LEN, 0x00, DIR_BUFF_LEN); - NFuncArg funcArg(env, info); if (!funcArg.InitArgs(NARG_CNT::ZERO)) { UniError(EINVAL).ThrowErr(env, "Number of arguments unmatched"); @@ -243,13 +219,6 @@ napi_value DirNExporter::ReadSync(napi_env env, napi_callback_info info) return nullptr; } DIR *dir = dirEntity->dir_.get(); - if (EOK == memcpy_s(dirBuff, DIR_BUFF_LEN, dir, DIR_BUFF_LEN -1)) { - HILOGE("[0]struct DIR member fd = %{public}02x-%{public}02x-%{public}02x-%{public}02x," - "buf_pos = %{public}02x-%{public}02x-%{public}02x-%{public}02x," - "buf_end = %{public}02x-%{public}02x-%{public}02x-%{public}02x", - dirBuff[8], dirBuff[9], dirBuff[10], dirBuff[11], dirBuff[12], dirBuff[13], - dirBuff[14], dirBuff[15], dirBuff[16], dirBuff[17], dirBuff[18], dirBuff[19]); - } struct dirent tmpDirent; { @@ -258,18 +227,6 @@ napi_value DirNExporter::ReadSync(napi_env env, napi_callback_info info) dirent *res = nullptr; do { res = readdir(dir); - if (res != nullptr) { - HILOGE("res filelength = %{public}u, type = %{public}d", res->d_reclen, res->d_type); - } - - if (EOK == memcpy_s(dirBuff, DIR_BUFF_LEN, dir, DIR_BUFF_LEN - 1)) { - HILOGE("struct DIR member fd = %{public}02x-%{public}02x-%{public}02x-%{public}02x," - "buf_pos = %{public}02x-%{public}02x-%{public}02x-%{public}02x," - "buf_end = %{public}02x-%{public}02x-%{public}02x-%{public}02x", - dirBuff[8], dirBuff[9], dirBuff[10], dirBuff[11], dirBuff[12], dirBuff[13], - dirBuff[14], dirBuff[15], dirBuff[16], dirBuff[17], dirBuff[18], dirBuff[19]); - } - if (res == nullptr && errno) { UniError(errno).ThrowErr(env); return nullptr; diff --git a/interfaces/kits/js/src/mod_fileio/class_dir/dir_n_exporter.h b/interfaces/kits/js/src/mod_fileio/class_dir/dir_n_exporter.h index f67c114e071d26dc98e08bb6e5848ee6de20aded..a40ed03d2b542f5ef501fdd4cd3c922bae2d2e2f 100644 --- a/interfaces/kits/js/src/mod_fileio/class_dir/dir_n_exporter.h +++ b/interfaces/kits/js/src/mod_fileio/class_dir/dir_n_exporter.h @@ -42,7 +42,6 @@ public: ~DirNExporter() override; }; const std::string listfileProcedureName = "fileioDirListFile"; -constexpr int DIR_BUFF_LEN = 25; } // namespace ModuleFileIO } // namespace DistributedFS } // namespace OHOS diff --git a/interfaces/kits/js/src/mod_fileio/properties/watcher.cpp b/interfaces/kits/js/src/mod_fileio/properties/watcher.cpp index b822f9a3c6461034cb62979578c32354e451d672..b7e2f536ef965c44665cc62fd3593df62551c573 100644 --- a/interfaces/kits/js/src/mod_fileio/properties/watcher.cpp +++ b/interfaces/kits/js/src/mod_fileio/properties/watcher.cpp @@ -49,6 +49,7 @@ void Watcher::RunCommand(uv_fs_event_t *handle, const char *filename, int events napi_get_global(information->env, &global); napi_value tmp = nullptr; napi_call_function(information->env, global, callback, argv.size(), argv.data(), &tmp); + napi_close_handle_scope(information->env, scope); } }