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 4ed5f43e12c222245466778d6839339076044f7d..5d2fc15ec48877be3fb0c163f55e0a54b21d9bdf 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 6bde0f86d9b08d28782ab605eab7376d4fdce31a..375b0e4cce3132c79e795d5f1ea214affdb7bf88 100755 --- 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 65f0701f857f4a892026d3175496fa01aab3a2bb..1bb4350f09d5ac9bfcd64b472d75e69cea21e20c 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_ = "";