diff --git a/interfaces/kits/js/src/common/ani_helper/type_converter.cpp b/interfaces/kits/js/src/common/ani_helper/type_converter.cpp index ba640a84cfca4ee72916e4dccc110a8ded4256dc..89a692ca02807fc9735bdb3eb83a8ce5253206d7 100644 --- a/interfaces/kits/js/src/common/ani_helper/type_converter.cpp +++ b/interfaces/kits/js/src/common/ani_helper/type_converter.cpp @@ -267,20 +267,15 @@ std::tuple TypeConverter::ToAniArrayBuffer(ani_env *env, return { true, static_cast(obj) }; } -std::tuple TypeConverter::ToAniStringList( +std::tuple TypeConverter::ToAniStringList( ani_env *env, const std::string strList[], const uint32_t length) { if (env == nullptr) { return { false, nullptr }; } - auto classDesc = BuiltInTypes::String::classDesc.c_str(); - ani_array_ref result = nullptr; - ani_class cls = nullptr; - if (env->FindClass(classDesc, &cls) != ANI_OK) { - return { false, result }; - } - if (env->Array_New_Ref(cls, length, nullptr, &result) != ANI_OK) { + ani_array result = nullptr; + if (env->Array_New(length, nullptr, &result) != ANI_OK) { return { false, result }; } for (uint32_t i = 0; i < length; i++) { @@ -289,11 +284,11 @@ std::tuple TypeConverter::ToAniStringList( return { false, nullptr }; } - if (env->Array_Set_Ref(result, i, item) != ANI_OK) { + if (env->Array_Set(result, i, item) != ANI_OK) { return { false, nullptr }; } } return { true, result }; } -} // namespace OHOS::FileManagement::ModuleFileIO::ANI \ No newline at end of file +} // namespace OHOS::FileManagement::ModuleFileIO::ANI diff --git a/interfaces/kits/js/src/common/ani_helper/type_converter.h b/interfaces/kits/js/src/common/ani_helper/type_converter.h index bac25493fda5311c32340a5ce0371dd981a9af1d..a0176dc196555be6850ceca270b970c1b6f1bf0b 100644 --- a/interfaces/kits/js/src/common/ani_helper/type_converter.h +++ b/interfaces/kits/js/src/common/ani_helper/type_converter.h @@ -39,10 +39,10 @@ public: static std::tuple> EnumToInt32(ani_env *env, const ani_enum_item &enumOp); static std::tuple ToFileInfo(ani_env *env, const ani_object &pathOrFd); static std::tuple ToArrayBuffer(ani_env *env, ani_arraybuffer &buffer); - static std::tuple ToAniStringList( + static std::tuple ToAniStringList( ani_env *env, const std::string strList[], const uint32_t length); }; } // namespace OHOS::FileManagement::ModuleFileIO::ANI -#endif // FILEMANAGEMENT_ANI_TYPE_CONVERTER_H \ No newline at end of file +#endif // FILEMANAGEMENT_ANI_TYPE_CONVERTER_H diff --git a/interfaces/kits/js/src/mod_fs/properties/ani/listfile_ani.cpp b/interfaces/kits/js/src/mod_fs/properties/ani/listfile_ani.cpp index 44b8faf6e3ac8aece21d13579e52bbd4f2a37655..337eacf4d3c8696927bc1609211034061dff28b2 100644 --- a/interfaces/kits/js/src/mod_fs/properties/ani/listfile_ani.cpp +++ b/interfaces/kits/js/src/mod_fs/properties/ani/listfile_ani.cpp @@ -206,7 +206,7 @@ tuple> ParseArgs(ani_env *env, ani_object obj) return { true, make_optional(result) }; } -ani_array_ref ListFileAni::ListFileSync(ani_env *env, [[maybe_unused]] ani_class clazz, ani_string path, ani_object obj) +ani_array ListFileAni::ListFileSync(ani_env *env, [[maybe_unused]] ani_class clazz, ani_string path, ani_object obj) { auto [succPath, srcPath] = TypeConverter::ToUTF8String(env, path); if (!succPath) { @@ -244,4 +244,4 @@ ani_array_ref ListFileAni::ListFileSync(ani_env *env, [[maybe_unused]] ani_class } // namespace ANI } // namespace ModuleFileIO } // namespace FileManagement -} // namespace OHOS \ No newline at end of file +} // namespace OHOS diff --git a/interfaces/kits/js/src/mod_fs/properties/ani/listfile_ani.h b/interfaces/kits/js/src/mod_fs/properties/ani/listfile_ani.h index 63ff7731db00fd48fae52f975b7af4f6aa99f99d..2045ec1cb00afb648eb68c95a1052bdc8ef7c901 100644 --- a/interfaces/kits/js/src/mod_fs/properties/ani/listfile_ani.h +++ b/interfaces/kits/js/src/mod_fs/properties/ani/listfile_ani.h @@ -25,7 +25,7 @@ namespace ANI { class ListFileAni final { public: - static ani_array_ref ListFileSync(ani_env *env, [[maybe_unused]] ani_class clazz, ani_string path, ani_object obj); + static ani_array ListFileSync(ani_env *env, [[maybe_unused]] ani_class clazz, ani_string path, ani_object obj); }; } // namespace ANI @@ -33,4 +33,4 @@ public: } // namespace FileManagement } // namespace OHOS -#endif // INTERFACES_KITS_JS_SRC_MOD_FS_PROPERTIES_FILELIST_ANI_H \ No newline at end of file +#endif // INTERFACES_KITS_JS_SRC_MOD_FS_PROPERTIES_FILELIST_ANI_H