diff --git a/interfaces/kits/js/src/mod_fileio/properties/chmod.cpp b/interfaces/kits/js/src/mod_fileio/properties/chmod.cpp index bfef7ca25ad2eaa12d3f06f6f8fdbad08f391018..3a75eb8bd21098f72cb2115914263503988ecae2 100644 --- a/interfaces/kits/js/src/mod_fileio/properties/chmod.cpp +++ b/interfaces/kits/js/src/mod_fileio/properties/chmod.cpp @@ -36,7 +36,23 @@ napi_value Chmod::Sync(napi_env env, napi_callback_info info) napi_value Chmod::Async(napi_env env, napi_callback_info info) { - return NVal::CreateUndefined(env).val_; + NFuncArg funcArg(env, info); + auto cbExec = [](napi_env env) -> UniError { + return UniError(ERRNO_NOERR); + }; + + auto cbComplete = [](napi_env env, UniError err) -> NVal { + return { NVal::CreateUndefined(env) }; + }; + + NVal thisVar(env, funcArg.GetThisVar()); + const string procedureName = "FileIOChmod"; + if (funcArg.GetArgc() == NARG_CNT::TWO) { + return NAsyncWorkPromise(env, thisVar).Schedule(procedureName, cbExec, cbComplete).val_; + } else { + NVal cb(env, funcArg[NARG_POS::THIRD]); + return NAsyncWorkCallback(env, thisVar, cb).Schedule(procedureName, cbExec, cbComplete).val_; + } } } // namespace ModuleFileIO } // namespace DistributedFS diff --git a/interfaces/kits/js/src/mod_fileio/properties/chown.cpp b/interfaces/kits/js/src/mod_fileio/properties/chown.cpp index 8cac52c70fe63b6d21620fc4d070d0ae168085df..cf2887d1e000b928ea0bfbc50a5c334682ab2dad 100644 --- a/interfaces/kits/js/src/mod_fileio/properties/chown.cpp +++ b/interfaces/kits/js/src/mod_fileio/properties/chown.cpp @@ -35,7 +35,24 @@ napi_value Chown::Sync(napi_env env, napi_callback_info info) napi_value Chown::Async(napi_env env, napi_callback_info info) { - return NVal::CreateUndefined(env).val_; + NFuncArg funcArg(env, info); + auto cbExec = [](napi_env env) -> UniError { + return UniError(ERRNO_NOERR); + }; + + auto cbCompl = [](napi_env env, UniError err) -> NVal { + return { NVal::CreateUndefined(env) }; + }; + + const string procedureName = "FileIOChown"; + NVal thisVar(env, funcArg.GetThisVar()); + if (funcArg.GetArgc() == NARG_CNT::THREE) { + return NAsyncWorkPromise(env, thisVar).Schedule(procedureName, cbExec, cbCompl).val_; + } else { + int cbIdx = NARG_POS::FOURTH; + NVal cb(env, funcArg[cbIdx]); + return NAsyncWorkCallback(env, thisVar, cb).Schedule(procedureName, cbExec, cbCompl).val_; + } } } // namespace ModuleFileIO } // namespace DistributedFS diff --git a/interfaces/kits/js/src/mod_fileio/properties/fchmod.cpp b/interfaces/kits/js/src/mod_fileio/properties/fchmod.cpp index 159ef1b409e4508a3a5a371adbfadc7a0ee16269..837fac637504a3daf345e5608cc2e40be9befcd3 100644 --- a/interfaces/kits/js/src/mod_fileio/properties/fchmod.cpp +++ b/interfaces/kits/js/src/mod_fileio/properties/fchmod.cpp @@ -33,10 +33,25 @@ napi_value Fchmod::Sync(napi_env env, napi_callback_info info) return NVal::CreateUndefined(env).val_; } - napi_value Fchmod::Async(napi_env env, napi_callback_info info) { - return NVal::CreateUndefined(env).val_; + NFuncArg funcArg(env, info); + auto cbExec = [](napi_env env) -> UniError { + return UniError(ERRNO_NOERR); + }; + + auto cbComplCallback = [](napi_env env, UniError err) -> NVal { + return { NVal::CreateUndefined(env) }; + }; + + const string procedureName = "FileIOFchmod"; + NVal thisVar(env, funcArg.GetThisVar()); + if (funcArg.GetArgc() == NARG_CNT::TWO) { + return NAsyncWorkPromise(env, thisVar).Schedule(procedureName, cbExec, cbComplCallback).val_; + } else { + NVal cb(env, funcArg[NARG_POS::THIRD]); + return NAsyncWorkCallback(env, thisVar, cb).Schedule(procedureName, cbExec, cbComplCallback).val_; + } } } // namespace ModuleFileIO } // namespace DistributedFS diff --git a/interfaces/kits/js/src/mod_fileio/properties/fchown.cpp b/interfaces/kits/js/src/mod_fileio/properties/fchown.cpp index a3295b092176a149fb0f04525fa3b3e2a66cbc9b..0ced6307328e09c8e2f96f6420461afb3eeb6fd3 100644 --- a/interfaces/kits/js/src/mod_fileio/properties/fchown.cpp +++ b/interfaces/kits/js/src/mod_fileio/properties/fchown.cpp @@ -34,7 +34,23 @@ napi_value Fchown::Sync(napi_env env, napi_callback_info info) napi_value Fchown::Async(napi_env env, napi_callback_info info) { - return NVal::CreateUndefined(env).val_; + NFuncArg funcArg(env, info); + auto cbExec = [](napi_env env) -> UniError { + return UniError(ERRNO_NOERR); + }; + + auto cbComplCallback = [](napi_env env, UniError err) -> NVal { + return { NVal::CreateUndefined(env) }; + }; + + const string procedureName = "FileIOFchown"; + NVal thisVar(env, funcArg.GetThisVar()); + if (funcArg.GetArgc() == NARG_CNT::THREE) { + return NAsyncWorkPromise(env, thisVar).Schedule(procedureName, cbExec, cbComplCallback).val_; + } else { + NVal cb(env, funcArg[NARG_POS::FOURTH]); + return NAsyncWorkCallback(env, thisVar, cb).Schedule(procedureName, cbExec, cbComplCallback).val_; + } } } // namespace ModuleFileIO } // namespace DistributedFS diff --git a/interfaces/kits/js/src/mod_fileio/properties/lchown.cpp b/interfaces/kits/js/src/mod_fileio/properties/lchown.cpp index 2113bdfc277fcde56da3ffa7f7bc3e2304539d57..459c6a50d18e74b9ff3d12c5a34f50354579167b 100644 --- a/interfaces/kits/js/src/mod_fileio/properties/lchown.cpp +++ b/interfaces/kits/js/src/mod_fileio/properties/lchown.cpp @@ -34,7 +34,23 @@ napi_value Lchown::Sync(napi_env env, napi_callback_info info) napi_value Lchown::Async(napi_env env, napi_callback_info info) { - return NVal::CreateUndefined(env).val_; + NFuncArg funcArg(env, info); + auto cbExec = [](napi_env env) -> UniError { + return UniError(ERRNO_NOERR); + }; + + auto cbCompl = [](napi_env env, UniError err) -> NVal { + return { NVal::CreateUndefined(env) }; + }; + + const string procedureName = "FileIOLchown"; + NVal thisVar(env, funcArg.GetThisVar()); + if (funcArg.GetArgc() == NARG_CNT::THREE) { + return NAsyncWorkPromise(env, thisVar).Schedule(procedureName, cbExec, cbCompl).val_; + } else { + NVal cb(env, funcArg[NARG_POS::FOURTH]); + return NAsyncWorkCallback(env, thisVar, cb).Schedule(procedureName, cbExec, cbCompl).val_; + } } } // namespace ModuleFileIO } // namespace DistributedFS