diff --git a/interfaces/kits/js/src/mod_environment/environment_napi.cpp b/interfaces/kits/js/src/mod_environment/environment_napi.cpp index 3a5c007bbe286787ffd2ceb93b33b607f376e191..51b95212fe958c3596ccffa5ea6c9af5bfa43325 100644 --- a/interfaces/kits/js/src/mod_environment/environment_napi.cpp +++ b/interfaces/kits/js/src/mod_environment/environment_napi.cpp @@ -31,7 +31,20 @@ napi_value EnvironmentExport(napi_env env, napi_value exports) return exports; } -NAPI_MODULE(environment, EnvironmentExport) +static napi_module _module = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = EnvironmentExport, + .nm_modname = "file.environment", + .nm_priv = ((void *)0), + .reserved = {0} +}; + +extern "C" __attribute__((constructor)) void RegisterModule(void) +{ + napi_module_register(&_module); +} } // namespace ModuleEnvironment } // namespace FileManagement } // namespace OHOS \ No newline at end of file diff --git a/interfaces/kits/js/src/mod_fileio/properties/open.cpp b/interfaces/kits/js/src/mod_fileio/properties/open.cpp index a024642b246d9c6bdeee872c8cc55bd34e289188..cc84fd971bff0dad671ac646d0e4dda7bf8e898f 100644 --- a/interfaces/kits/js/src/mod_fileio/properties/open.cpp +++ b/interfaces/kits/js/src/mod_fileio/properties/open.cpp @@ -90,15 +90,15 @@ napi_value Open::Sync(napi_env env, napi_callback_info info) } size_t argc = funcArg.GetArgc(); + int32_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP; if (argc != NARG_CNT::THREE) { size_t flagsFirst { flags }; if ((flagsFirst & O_CREAT) || (flagsFirst & O_TMPFILE)) { UniError(EINVAL).ThrowErr(env, "called with O_CREAT/O_TMPFILE but no mode"); return nullptr; } - fd = open(path.get(), flags); + fd = open(path.get(), flags, mode); } else { - int mode; tie(succ, mode) = NVal(env, funcArg.GetArg(NARG_POS::THIRD)).ToInt32(); if (!succ) { UniError(EINVAL).ThrowErr(env, "Invalid mode"); @@ -119,7 +119,7 @@ napi_value Open::Sync(napi_env env, napi_callback_info info) return NVal::CreateInt64(env, fd).val_; } -static UniError DoOpenExec(const std::string& path, const int flags, const int mode, shared_ptr arg) +static UniError DoOpenExec(const std::string& path, const int flags, const int32_t mode, shared_ptr arg) { int fd = -1; if (!ModuleRemoteUri::RemoteUri::IsRemoteUri(path, fd, flags)) { @@ -157,7 +157,7 @@ napi_value Open::Async(napi_env env, napi_callback_info info) (void)AdaptToAbi(flags); } - int mode = 0; + int32_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP; size_t argc = funcArg.GetArgc(); if (argc == NARG_CNT::FOUR || (argc == NARG_CNT::THREE && NVal(env, funcArg[NARG_POS::THIRD]).TypeIs(napi_number))) {