From 7aca8d08ceaee7ebb1645060a20a8f69b13a0e0a Mon Sep 17 00:00:00 2001 From: zhuhongtao66 Date: Mon, 20 Mar 2023 17:11:59 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E5=9B=9E=E5=90=88release=E3=80=91?= =?UTF-8?q?=E5=91=8A=E8=AD=A6=E6=B8=85=E9=9B=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhuhongtao66 --- .../js/src/mod_fs/class_stream/stream_n_exporter.cpp | 4 ++-- .../kits/js/src/mod_fs/properties/listfile.cpp | 12 +++++------- interfaces/kits/js/src/mod_fs/properties/open.cpp | 2 +- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/interfaces/kits/js/src/mod_fs/class_stream/stream_n_exporter.cpp b/interfaces/kits/js/src/mod_fs/class_stream/stream_n_exporter.cpp index 4ed5f43e1..5d2fc15ec 100644 --- a/interfaces/kits/js/src/mod_fs/class_stream/stream_n_exporter.cpp +++ b/interfaces/kits/js/src/mod_fs/class_stream/stream_n_exporter.cpp @@ -130,7 +130,7 @@ napi_value StreamNExporter::WriteSync(napi_env env, napi_callback_info cbInfo) } size_t writeLen = fwrite(buf, 1, len, filp); - if (writeLen == 0 && writeLen != len) { + if (writeLen == 0 && writeLen != static_cast(len)) { HILOGE("Failed to fwrite stream"); NError(EIO).ThrowErr(env); return nullptr; @@ -187,7 +187,7 @@ napi_value StreamNExporter::Write(napi_env env, napi_callback_info cbInfo) return NError(errno); } arg->actLen = fwrite(buf, 1, len, filp); - if (arg->actLen == 0 && arg->actLen != len) { + if (arg->actLen == 0 && arg->actLen != static_cast(len)) { HILOGE("Failed to fwrite stream"); return NError(EIO); } diff --git a/interfaces/kits/js/src/mod_fs/properties/listfile.cpp b/interfaces/kits/js/src/mod_fs/properties/listfile.cpp index 01fe6bb15..567199a8d 100644 --- a/interfaces/kits/js/src/mod_fs/properties/listfile.cpp +++ b/interfaces/kits/js/src/mod_fs/properties/listfile.cpp @@ -151,11 +151,9 @@ static bool GetOptionArg(napi_env env, const NFuncArg &funcArg, OptionArgs &opti static bool FilterSuffix(const vector& suffixs, const struct dirent& filename) { - for (auto iter = suffixs.begin(); iter != suffixs.end(); iter++) { - string_view sv1(*iter); - string_view sv2((string(filename.d_name)).substr((string(filename.d_name)).find('.'), - (string(filename.d_name)).length() - 1)); - if (sv1 != sv2) { + for (const auto &iter : suffixs) { + string suffixStr = string(filename.d_name).substr((string(filename.d_name)).rfind('.')); + if (iter != suffixStr) { return true; } } @@ -164,8 +162,8 @@ static bool FilterSuffix(const vector& suffixs, const struct dirent& fil static bool FilterDisplayname(const vector& displaynames, const struct dirent& filename) { - for (auto iter = displaynames.begin(); iter != displaynames.end(); iter++) { - int ret = fnmatch((*iter).c_str(), filename.d_name, FNM_PATHNAME | FNM_PERIOD); + for (const auto &iter : displaynames) { + int ret = fnmatch(iter.c_str(), filename.d_name, FNM_PATHNAME | FNM_PERIOD); if (ret == 0) { return true; } diff --git a/interfaces/kits/js/src/mod_fs/properties/open.cpp b/interfaces/kits/js/src/mod_fs/properties/open.cpp index 65f0701f8..1bb4350f0 100644 --- a/interfaces/kits/js/src/mod_fs/properties/open.cpp +++ b/interfaces/kits/js/src/mod_fs/properties/open.cpp @@ -72,7 +72,7 @@ static NVal InstantiateFile(napi_env env, int fd, string pathOrUri, bool isUri) NError(EIO).ThrowErr(env); return NVal(); } - auto fdg = make_unique(fd, false); + auto fdg = make_unique(fd, true); fileEntity->fd_.swap(fdg); if (isUri) { fileEntity->path_ = ""; -- Gitee