From 285daea5956ee9440ee870f481eb3fad14c8cbbe Mon Sep 17 00:00:00 2001 From: futurezhou Date: Sun, 29 Jan 2023 14:29:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9open=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: futurezhou --- .../kits/js/src/mod_fs/properties/copy_file.cpp | 2 +- .../kits/js/src/mod_fs/properties/fdatasync.cpp | 5 ++--- interfaces/kits/js/src/mod_fs/properties/fdatasync.h | 1 + interfaces/kits/js/src/mod_fs/properties/fsync.cpp | 5 ++--- interfaces/kits/js/src/mod_fs/properties/fsync.h | 1 + interfaces/kits/js/src/mod_fs/properties/lstat.cpp | 7 +++---- interfaces/kits/js/src/mod_fs/properties/lstat.h | 1 + interfaces/kits/js/src/mod_fs/properties/mkdtemp.cpp | 11 +++++------ interfaces/kits/js/src/mod_fs/properties/mkdtemp.h | 1 + interfaces/kits/js/src/mod_fs/properties/open.cpp | 4 ++-- .../kits/js/src/mod_fs/properties/read_text.cpp | 4 ++-- interfaces/kits/js/src/mod_fs/properties/truncate.cpp | 6 +++--- 12 files changed, 24 insertions(+), 24 deletions(-) diff --git a/interfaces/kits/js/src/mod_fs/properties/copy_file.cpp b/interfaces/kits/js/src/mod_fs/properties/copy_file.cpp index 029d1472b..ae3fec84c 100755 --- a/interfaces/kits/js/src/mod_fs/properties/copy_file.cpp +++ b/interfaces/kits/js/src/mod_fs/properties/copy_file.cpp @@ -59,7 +59,7 @@ static NError SendFileCore(FileInfo& srcFile, FileInfo& destFile) return NError(ERRNO_NOERR); } int ret = uv_fs_open(nullptr, open_req.get(), srcFile.path.get(), O_RDONLY, - S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH, nullptr); + S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP, nullptr); if (ret < 0) { HILOGE("Failed to open srcFile with ret: %{public}d", ret); return NError(errno); diff --git a/interfaces/kits/js/src/mod_fs/properties/fdatasync.cpp b/interfaces/kits/js/src/mod_fs/properties/fdatasync.cpp index f5dbc0f4f..54dae67b9 100644 --- a/interfaces/kits/js/src/mod_fs/properties/fdatasync.cpp +++ b/interfaces/kits/js/src/mod_fs/properties/fdatasync.cpp @@ -100,13 +100,12 @@ napi_value Fdatasync::Async(napi_env env, napi_callback_info info) return {NVal::CreateUndefined(env)}; }; - const string procedureName = "FileIOFdatasync"; NVal thisVar(env, funcArg.GetThisVar()); if (funcArg.GetArgc() == NARG_CNT::ONE) { - return NAsyncWorkPromise(env, thisVar).Schedule(procedureName, cbExec, cbComplCallback).val_; + return NAsyncWorkPromise(env, thisVar).Schedule(PROCEDURE_FDATASYNC_NAME, cbExec, cbComplCallback).val_; } else { NVal cb(env, funcArg[NARG_POS::SECOND]); - return NAsyncWorkCallback(env, thisVar, cb).Schedule(procedureName, cbExec, cbComplCallback).val_; + return NAsyncWorkCallback(env, thisVar, cb).Schedule(PROCEDURE_FDATASYNC_NAME, cbExec, cbComplCallback).val_; } } } // OHOS::FileManagement::ModuleFileIO \ No newline at end of file diff --git a/interfaces/kits/js/src/mod_fs/properties/fdatasync.h b/interfaces/kits/js/src/mod_fs/properties/fdatasync.h index f4c3ba0e5..6c109c642 100644 --- a/interfaces/kits/js/src/mod_fs/properties/fdatasync.h +++ b/interfaces/kits/js/src/mod_fs/properties/fdatasync.h @@ -24,5 +24,6 @@ public: static napi_value Sync(napi_env env, napi_callback_info info); static napi_value Async(napi_env env, napi_callback_info info); }; +const std::string PROCEDURE_FDATASYNC_NAME = "FileIOFdatasync"; } // namespace OHOS::FileManagement::ModuleFileIO #endif // INTERFACES_KITS_JS_SRC_MOD_FS_PROPERTIES_FDATASYNC_H \ No newline at end of file diff --git a/interfaces/kits/js/src/mod_fs/properties/fsync.cpp b/interfaces/kits/js/src/mod_fs/properties/fsync.cpp index 422389c64..6fcb230fd 100644 --- a/interfaces/kits/js/src/mod_fs/properties/fsync.cpp +++ b/interfaces/kits/js/src/mod_fs/properties/fsync.cpp @@ -98,14 +98,13 @@ napi_value Fsync::Async(napi_env env, napi_callback_info info) } }; - const string procedureName = "FileIOFsync"; size_t argc = funcArg.GetArgc(); NVal thisVar(env, funcArg.GetThisVar()); if (argc == NARG_CNT::ONE) { - return NAsyncWorkPromise(env, thisVar).Schedule(procedureName, cbExec, cbComplete).val_; + return NAsyncWorkPromise(env, thisVar).Schedule(PROCEDURE_FSYNC_NAME, cbExec, cbComplete).val_; } else { NVal cb(env, funcArg[NARG_POS::SECOND]); - return NAsyncWorkCallback(env, thisVar, cb).Schedule(procedureName, cbExec, cbComplete).val_; + return NAsyncWorkCallback(env, thisVar, cb).Schedule(PROCEDURE_FSYNC_NAME, cbExec, cbComplete).val_; } } } // namespace OHOS::FileManagement::ModuleFileIO \ No newline at end of file diff --git a/interfaces/kits/js/src/mod_fs/properties/fsync.h b/interfaces/kits/js/src/mod_fs/properties/fsync.h index e03390978..f52573afe 100644 --- a/interfaces/kits/js/src/mod_fs/properties/fsync.h +++ b/interfaces/kits/js/src/mod_fs/properties/fsync.h @@ -24,5 +24,6 @@ public: static napi_value Sync(napi_env env, napi_callback_info info); static napi_value Async(napi_env env, napi_callback_info info); }; +const std::string PROCEDURE_FSYNC_NAME = "FileIOFsync"; } // namespace OHOS::FileManagement::ModuleFileIO #endif // INTERFACES_KITS_JS_SRC_MOD_FS_PROPERTIES_FSYNC_H \ No newline at end of file diff --git a/interfaces/kits/js/src/mod_fs/properties/lstat.cpp b/interfaces/kits/js/src/mod_fs/properties/lstat.cpp index 06ecdf639..cc5b9defd 100644 --- a/interfaces/kits/js/src/mod_fs/properties/lstat.cpp +++ b/interfaces/kits/js/src/mod_fs/properties/lstat.cpp @@ -17,7 +17,7 @@ #include #include -#include "../common_func.h" +#include "common_func.h" #include "class_stat/stat_entity.h" #include "class_stat/stat_n_exporter.h" #include "filemgmt_libhilog.h" @@ -115,12 +115,11 @@ napi_value Lstat::Async(napi_env env, napi_callback_info info) }; NVal thisVar(env, funcArg.GetThisVar()); - const string procedureName = "FileIOLstat"; if (funcArg.GetArgc() == NARG_CNT::ONE) { - return NAsyncWorkPromise(env, thisVar).Schedule(procedureName, cbExec, cbCompl).val_; + return NAsyncWorkPromise(env, thisVar).Schedule(PROCEDURE_LSTAT_NAME, cbExec, cbCompl).val_; } else { NVal cb(env, funcArg[NARG_POS::SECOND]); - return NAsyncWorkCallback(env, thisVar, cb).Schedule(procedureName, cbExec, cbCompl).val_; + return NAsyncWorkCallback(env, thisVar, cb).Schedule(PROCEDURE_LSTAT_NAME, cbExec, cbCompl).val_; } } } // namespace OHOS::FileManagement::ModuleFileIO \ No newline at end of file diff --git a/interfaces/kits/js/src/mod_fs/properties/lstat.h b/interfaces/kits/js/src/mod_fs/properties/lstat.h index 00adc4627..6d28f82a2 100644 --- a/interfaces/kits/js/src/mod_fs/properties/lstat.h +++ b/interfaces/kits/js/src/mod_fs/properties/lstat.h @@ -24,5 +24,6 @@ public: static napi_value Async(napi_env env, napi_callback_info info); static napi_value Sync(napi_env env, napi_callback_info info); }; +const std::string PROCEDURE_LSTAT_NAME = "FileIOLstat"; } // namespace OHOS::FileManagement::ModuleFileIO #endif // INTERFACES_KITS_JS_SRC_MOD_FS_PROPERTIES_LSTAT_H \ No newline at end of file diff --git a/interfaces/kits/js/src/mod_fs/properties/mkdtemp.cpp b/interfaces/kits/js/src/mod_fs/properties/mkdtemp.cpp index 43ab54a2b..2db654792 100755 --- a/interfaces/kits/js/src/mod_fs/properties/mkdtemp.cpp +++ b/interfaces/kits/js/src/mod_fs/properties/mkdtemp.cpp @@ -75,16 +75,16 @@ napi_value Mkdtemp::Async(napi_env env, napi_callback_info info) } auto arg = make_shared(); - auto cbExec = [path = tmp.get(), arg]() -> NError { + auto cbExec = [path = string(tmp.get()), arg]() -> NError { std::unique_ptr mkdtemp_req = { new uv_fs_t, CommonFunc::fs_req_cleanup }; if (!mkdtemp_req) { HILOGE("Failed to request heap memory."); return NError(ERRNO_NOERR); } - int ret = uv_fs_mkdtemp(nullptr, mkdtemp_req.get(), const_cast(path), nullptr); + int ret = uv_fs_mkdtemp(nullptr, mkdtemp_req.get(), path.c_str(), nullptr); if (ret < 0) { - HILOGE("Failed to create a temporary directory with path: %{public}s", path); + HILOGE("Failed to create a temporary directory with path: %{public}s", path.c_str()); return NError(errno); } else { *arg = mkdtemp_req->path; @@ -100,14 +100,13 @@ napi_value Mkdtemp::Async(napi_env env, napi_callback_info info) } }; - const string procedureName = "FileIOmkdtemp"; size_t argc = funcArg.GetArgc(); NVal thisVar(env, funcArg.GetThisVar()); if (argc == NARG_CNT::ONE) { - return NAsyncWorkPromise(env, thisVar).Schedule(procedureName, cbExec, cbComplete).val_; + return NAsyncWorkPromise(env, thisVar).Schedule(PROCEDURE_MKDTEMP_NAME, cbExec, cbComplete).val_; } else { NVal cb(env, funcArg[NARG_POS::SECOND]); - return NAsyncWorkCallback(env, thisVar, cb).Schedule(procedureName, cbExec, cbComplete).val_; + return NAsyncWorkCallback(env, thisVar, cb).Schedule(PROCEDURE_MKDTEMP_NAME, cbExec, cbComplete).val_; } } } // namespace ModuleFileIO diff --git a/interfaces/kits/js/src/mod_fs/properties/mkdtemp.h b/interfaces/kits/js/src/mod_fs/properties/mkdtemp.h index ac968c32e..1c08723d8 100755 --- a/interfaces/kits/js/src/mod_fs/properties/mkdtemp.h +++ b/interfaces/kits/js/src/mod_fs/properties/mkdtemp.h @@ -28,6 +28,7 @@ public: static napi_value Sync(napi_env env, napi_callback_info info); static napi_value Async(napi_env env, napi_callback_info info); }; +const std::string PROCEDURE_MKDTEMP_NAME = "FileIOmkdtemp"; } // namespace ModuleFileIO } // namespace FileManagement } // namespace OHOS diff --git a/interfaces/kits/js/src/mod_fs/properties/open.cpp b/interfaces/kits/js/src/mod_fs/properties/open.cpp index bcd429fc8..eca18b290 100644 --- a/interfaces/kits/js/src/mod_fs/properties/open.cpp +++ b/interfaces/kits/js/src/mod_fs/properties/open.cpp @@ -129,7 +129,7 @@ napi_value Open::Sync(napi_env env, napi_callback_info info) return nullptr; } int ret = uv_fs_open(nullptr, open_req.get(), path.get(), mode, S_IRUSR | - S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH, nullptr); + S_IWUSR | S_IRGRP | S_IWGRP, nullptr); if (ret < 0) { HILOGE("Failed to open file for libuv error %{public}d", ret); NError(errno).ThrowErr(env); @@ -185,7 +185,7 @@ napi_value Open::Async(napi_env env, napi_callback_info info) return NError(ERRNO_NOERR); } int ret = uv_fs_open(nullptr, open_req.get(), path.c_str(), mode, S_IRUSR | - S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH, nullptr); + S_IWUSR | S_IRGRP | S_IWGRP, nullptr); if (ret < 0) { HILOGE("Failed to open file for libuv error %{public}d", ret); return NError(errno); diff --git a/interfaces/kits/js/src/mod_fs/properties/read_text.cpp b/interfaces/kits/js/src/mod_fs/properties/read_text.cpp index 5ff8590e2..d3d664634 100755 --- a/interfaces/kits/js/src/mod_fs/properties/read_text.cpp +++ b/interfaces/kits/js/src/mod_fs/properties/read_text.cpp @@ -86,7 +86,7 @@ static NError ReadTextAsync(const std::string path, std::shared_ptrpath.get(), O_RDWR, - S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH, nullptr); + S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP, nullptr); if (ret < 0) { return NError(errno); } @@ -186,5 +186,5 @@ napi_value Truncate::Async(napi_env env, napi_callback_info info) return NAsyncWorkCallback(env, thisVar, cb).Schedule(PROCEDURE_TRUNCATE_NAME, cbExec, cbCompl).val_; } } -} +} } // namespace OHOS::FileManagement::ModuleFileIO \ No newline at end of file -- Gitee