diff --git a/interfaces/kits/js/src/mod_fs/common_func.cpp b/interfaces/kits/js/src/mod_fs/common_func.cpp index 6193013a3afc892ae12f1afa3babee85bd964689..46e0cf65305ec9d29ceae31af6eab067bb7b5480 100644 --- a/interfaces/kits/js/src/mod_fs/common_func.cpp +++ b/interfaces/kits/js/src/mod_fs/common_func.cpp @@ -78,6 +78,55 @@ void InitAccessModeType(napi_env env, napi_value exports) } } +void InitAccessFlagType(napi_env env, napi_value exports) +{ + char propertyName[] = "AccessFlagType"; + napi_property_descriptor desc[] = { + DECLARE_NAPI_STATIC_PROPERTY("LOCAL", NVal::CreateInt32(env, MODE_LOCAL).val_), + }; + napi_value obj = nullptr; + napi_status status = napi_create_object(env, &obj); + if (status != napi_ok) { + HILOGE("Failed to create object at initializing AccessFlagType"); + return; + } + status = napi_define_properties(env, obj, sizeof(desc) / sizeof(desc[0]), desc); + if (status != napi_ok) { + HILOGE("Failed to set properties of character at initializing AccessFlagType"); + return; + } + status = napi_set_named_property(env, exports, propertyName, obj); + if (status != napi_ok) { + HILOGE("Failed to set direction property at initializing AccessFlagType"); + return; + } +} + +void InitLocationType(napi_env env, napi_value exports) +{ + char propertyName[] = "LocationType"; + napi_property_descriptor desc[] = { + DECLARE_NAPI_STATIC_PROPERTY("LOCAl", NVal::CreateInt32(env, MODE_LOCATION_LOCAL).val_), + DECLARE_NAPI_STATIC_PROPERTY("CLOUD", NVal::CreateInt32(env, MODE_LOCATION_CLOUD).val_), + }; + napi_value obj = nullptr; + napi_status status = napi_create_object(env, &obj); + if (status != napi_ok) { + HILOGE("Failed to create object at initializing LocationType"); + return; + } + status = napi_define_properties(env, obj, sizeof(desc) / sizeof(desc[0]), desc); + if (status != napi_ok) { + HILOGE("Failed to set properties of character at initializing LocationType"); + return; + } + status = napi_set_named_property(env, exports, propertyName, obj); + if (status != napi_ok) { + HILOGE("Failed to set direction property at initializing LocationType"); + return; + } +} + void InitOpenMode(napi_env env, napi_value exports) { char propertyName[] = "OpenMode"; diff --git a/interfaces/kits/js/src/mod_fs/common_func.h b/interfaces/kits/js/src/mod_fs/common_func.h index 567cf26b4b167d3da00d1a439b8bfc469babbefa..7b6a2052b1e4609c855e8e40e8b9840519b2b821 100644 --- a/interfaces/kits/js/src/mod_fs/common_func.h +++ b/interfaces/kits/js/src/mod_fs/common_func.h @@ -44,6 +44,10 @@ constexpr unsigned int MODE_WRITE = 02; constexpr unsigned int MODE_READ = 04; constexpr unsigned int MODE_READ_WRITE = 06; +constexpr unsigned int MODE_LOCAL = 00; +constexpr unsigned int MODE_LOCATION_LOCAL = 01; +constexpr unsigned int MODE_LOCATION_CLOUD = 02; + constexpr unsigned int USR_READ_ONLY = 00; constexpr unsigned int USR_WRITE_ONLY = 01; constexpr unsigned int USR_RDWR = 02; @@ -75,6 +79,8 @@ public: #endif void InitAccessModeType(napi_env env, napi_value exports); +void InitAccessFlagType(napi_env env, napi_value exports); +void InitLocationType(napi_env env, napi_value exports); void InitOpenMode(napi_env env, napi_value exports); void InitWhenceType(napi_env env, napi_value exports); diff --git a/interfaces/kits/js/src/mod_fs/module.cpp b/interfaces/kits/js/src/mod_fs/module.cpp index 8944c27a6c2d0b4b08a0ef60459c607e182d13ac..cdbc61f85d1979a590f671887061240364399c5a 100644 --- a/interfaces/kits/js/src/mod_fs/module.cpp +++ b/interfaces/kits/js/src/mod_fs/module.cpp @@ -39,6 +39,8 @@ namespace ModuleFileIO { static napi_value Export(napi_env env, napi_value exports) { InitAccessModeType(env, exports); + InitAccessFlagType(env, exports); + InitLocationType(env, exports); InitOpenMode(env, exports); InitWhenceType(env, exports); std::vector> products;