diff --git a/bundle.json b/bundle.json index edb76103b405c627e59f9878847fd59359ea2630..32a20417dfdd506f5e14ee4c9a607fdead18c80b 100644 --- a/bundle.json +++ b/bundle.json @@ -36,8 +36,7 @@ "//foundation/filemanagement/user_file_service/services:fms", "//foundation/filemanagement/user_file_service/services/sa_profile:filemanager_service_sa_profile", "//foundation/filemanagement/user_file_service/interfaces/kits/js:filemanager", - "//foundation/filemanagement/user_file_service/frameworks/innerkits:frameworks_innerkits", - "//foundation/filemanagement/user_file_service/interfaces/kits/napi/file_access_ext_ability:fileaccessextensionability_napi" + "//foundation/filemanagement/user_file_service/frameworks/innerkits:frameworks_innerkits" ], "test": [ "//foundation/filemanagement/user_file_service/services/test:user_file_manager_test" diff --git a/interfaces/kits/napi/common/file_extension_info_napi.cpp b/interfaces/kits/napi/common/file_extension_info_napi.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8888e0ffb3b1f1b9c1244b908a2edf620574b6c1 --- /dev/null +++ b/interfaces/kits/napi/common/file_extension_info_napi.cpp @@ -0,0 +1,131 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "file_extension_info_napi.h" + +#include +#include "file_access_extension_info.h" +#include "hilog_wrapper.h" + +namespace OHOS { +namespace FileAccessFwk { +napi_value CreateStringUtf8(napi_env env, const std::string &str) +{ + napi_value value = nullptr; + if (napi_create_string_utf8(env, str.c_str(), str.length(), &value) != napi_ok) { + HILOG_ERROR("%{public}s, value is not napi_ok", __func__); + return nullptr; + } + return value; +} + +napi_value CreateUint32(napi_env env, uint32_t val) +{ + napi_value value = nullptr; + if (napi_create_uint32(env, val, &value) != napi_ok) { + HILOG_ERROR("%{public}s, value is not napi_ok", __func__); + return nullptr; + } + return value; +} + +napi_value FileInfoConstructor(napi_env env, napi_callback_info info) +{ + size_t argc = 0; + napi_value args[1] = {0}; + napi_value res = nullptr; + void *data = nullptr; + + napi_status status = napi_get_cb_info(env, info, &argc, args, &res, &data); + if (status != napi_ok) { + HILOG_ERROR("%{public}s, status is not napi_ok", __func__); + return nullptr; + } + + return res; +} + +napi_value DeviceInfoConstructor(napi_env env, napi_callback_info info) +{ + size_t argc = 0; + napi_value args[1] = {0}; + napi_value res = nullptr; + void *data = nullptr; + + napi_status status = napi_get_cb_info(env, info, &argc, args, &res, &data); + if (status != napi_ok) { + HILOG_ERROR("%{public}s, status is not napi_ok", __func__);s + return nullptr; + } + + return res; +} + +void InitFlag(napi_env env, napi_value exports) +{ + char propertyName[] = "FLAG"; + napi_property_descriptor desc[] = { + DECLARE_NAPI_STATIC_PROPERTY("SUPPORTS_THUMBNAIL", + CreateUint32(env, FLAG_SUPPORTS_THUMBNAIL)), + DECLARE_NAPI_STATIC_PROPERTY("SUPPORTS_WRITE", + CreateUint32(env, FLAG_SUPPORTS_WRITE)), + DECLARE_NAPI_STATIC_PROPERTY("SUPPORTS_READ", + CreateUint32(env, FLAG_SUPPORTS_READ)), + DECLARE_NAPI_STATIC_PROPERTY("SUPPORTS_DELETE", + CreateUint32(env, FLAG_SUPPORTS_DELETE)), + DECLARE_NAPI_STATIC_PROPERTY("SUPPORTS_RENAME", + CreateUint32(env, FLAG_SUPPORTS_RENAME)), + DECLARE_NAPI_STATIC_PROPERTY("SUPPORTS_MOVE", + CreateUint32(env, FLAG_SUPPORTS_MOVE)) + }; + napi_value obj = nullptr; + napi_create_object(env, &obj); + napi_define_properties(env, obj, sizeof(desc) / sizeof(desc[0]), desc); + napi_set_named_property(env, exports, propertyName, obj); +} + +void InitFileInfo(napi_env env, napi_value exports) +{ + char className[] = "FileInfo"; + napi_property_descriptor desc[] = { + { "uri", nullptr, nullptr, nullptr, nullptr, CreateStringUtf8(env, "uri"), napi_writable, nullptr }, + { "fileName", nullptr, nullptr, nullptr, nullptr, CreateStringUtf8(env, "fileName"), napi_writable, nullptr }, + { "mode", nullptr, nullptr, nullptr, nullptr, CreateStringUtf8(env, "mode"), napi_writable, nullptr }, + { "size", nullptr, nullptr, nullptr, nullptr, CreateStringUtf8(env, "size"), napi_writable, nullptr }, + { "mtime", nullptr, nullptr, nullptr, nullptr, CreateStringUtf8(env, "mtime"), napi_writable, nullptr }, + { "mimiType", nullptr, nullptr, nullptr, nullptr, CreateStringUtf8(env, "mimiType"), napi_writable, nullptr } + }; + napi_value obj = nullptr; + napi_define_class(env, className, NAPI_AUTO_LENGTH, FileInfoConstructor, nullptr, + sizeof(desc) / sizeof(*desc), desc, &obj); + napi_set_named_property(env, exports, className, obj); +} + +void InitDeviceInfo(napi_env env, napi_value exports) +{ + char className[] = "DeviceInfo"; + napi_property_descriptor desc[] = { + { "uri", nullptr, nullptr, nullptr, nullptr, CreateStringUtf8(env, "uri"), napi_writable, nullptr }, + { "displayName", nullptr, nullptr, nullptr, nullptr, + CreateStringUtf8(env, "displayName"), napi_writable, nullptr }, + { "deviceId", nullptr, nullptr, nullptr, nullptr, CreateStringUtf8(env, "deviceId"), napi_writable, nullptr }, + { "flags", nullptr, nullptr, nullptr, nullptr, CreateStringUtf8(env, "flags"), napi_writable, nullptr } + }; + napi_value obj = nullptr; + napi_define_class(env, className, NAPI_AUTO_LENGTH, DeviceInfoConstructor, nullptr, + sizeof(desc) / sizeof(*desc), desc, &obj); + napi_set_named_property(env, exports, className, obj); +} +} // namespace FileAccessFwk +} // namespace OHOS \ No newline at end of file diff --git a/interfaces/kits/napi/common/file_extension_info_napi.h b/interfaces/kits/napi/common/file_extension_info_napi.h new file mode 100644 index 0000000000000000000000000000000000000000..dab3c05960f8e5563dae6088f8d3fb1dc9b067e0 --- /dev/null +++ b/interfaces/kits/napi/common/file_extension_info_napi.h @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FILE_EXTENSION_INFO_NAPI_H +#define FILE_EXTENSION_INFO_NAPI_H + +#include "napi/native_api.h" +#include "napi/native_node_api.h" +namespace OHOS { +namespace FileAccessFwk { +void InitFlag(napi_env env, napi_value exports); +void InitFileInfo(napi_env env, napi_value exports); +void InitDeviceInfo(napi_env env, napi_value exports); +} // namespace FileAccessFwk +} // namespace OHOS +#endif // FILE_EXTENSION_INFO_NAPI_H \ No newline at end of file diff --git a/interfaces/kits/napi/file_access_ext_ability/file_access_ext_ability.js b/interfaces/kits/napi/file_access_ext_ability/file_access_ext_ability.js index 3c564a63bea2c07beeb2de5a85cfff5f2da7e888..97f0eb6ab4dd5d2504a8fe46af5aa4af6232638f 100644 --- a/interfaces/kits/napi/file_access_ext_ability/file_access_ext_ability.js +++ b/interfaces/kits/napi/file_access_ext_ability/file_access_ext_ability.js @@ -16,6 +16,40 @@ class FileAccessExtensionAbility { onCreate(want) { } + + openFile(uri, mode) { + return 0; + } + + createFile(parentUri, displayName) { + return ""; + } + + mkdir(parentUri, displayName) { + return ""; + } + + delete(sourceFileUri) { + return 0; + } + + move(sourceFileUri, targetParentUri) { + return ""; + } + + rename(sourceFileUri, displayName) { + return ""; + } + + listFile(sourceFileUri) { + let infos = []; + return infos; + } + + getRoots() { + let roots = []; + return roots; + } } export default FileAccessExtensionAbility \ No newline at end of file diff --git a/interfaces/kits/napi/file_access_module/BUILD.gn b/interfaces/kits/napi/file_access_module/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..c3317d50c0a86fe20c8d473380feb0533312f9a9 --- /dev/null +++ b/interfaces/kits/napi/file_access_module/BUILD.gn @@ -0,0 +1,53 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/ohos.gni") +BASE_DIR = "//foundation/filemanagement/user_file_service" + +ohos_shared_library("fileaccess") { + subsystem_name = "filemanagement" + part_name = "user_file_service" + + relative_install_dir = "module/data" + + include_dirs = [ + "./", + "${BASE_DIR}/utils", + "${BASE_DIR}/interfaces/kits/napi/common", + "//foundation/distributeddatamgr/distributedfile/interfaces/kits/js/src/common/napi", + "//foundation/distributeddatamgr/distributedfile/interfaces/kits/js/src/common", + ] + + sources = [ + "${BASE_DIR}/interfaces/kits/napi/common/file_extension_info_napi.cpp", + "napi_fileaccess_helper.cpp", + "native_fileaccess_module.cpp", + ] + + deps = [ + "${BASE_DIR}/frameworks/innerkits/file_access:file_access_extension_ability_kit", + "//foundation/ability/ability_runtime/frameworks/js/napi/aafwk/inner/napi_common:napi_common", + "//foundation/distributeddatamgr/distributedfile/interfaces/kits/js:fileio", + ] + + external_deps = [ + "ability_base:base", + "ability_base:want", + "ability_base:zuri", + "ability_runtime:abilitykit_native", + "ability_runtime:napi_base_context", + "hiviewdfx_hilog_native:libhilog", + "napi:ace_napi", + "utils_base:utils", + ] +} diff --git a/interfaces/kits/napi/file_access_module/file_access_common.h b/interfaces/kits/napi/file_access_module/file_access_common.h new file mode 100644 index 0000000000000000000000000000000000000000..4bc188b4923b44ef2c7ddf3223cb6245511be5a3 --- /dev/null +++ b/interfaces/kits/napi/file_access_module/file_access_common.h @@ -0,0 +1,112 @@ +/* + * Copyright (C) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef FILE_ACCESS_COMMON_H +#define FILE_ACCESS_COMMON_H + +#include "ability.h" +#include "file_access_helper.h" +#include "napi/native_api.h" +#include "napi/native_common.h" +#include "napi/native_node_api.h" +#include "napi_common.h" +#include "napi_common_util.h" + +namespace OHOS { +namespace FileAccessFwk { +struct CBBase { + AppExecFwk::CallbackInfo cbInfo; + napi_async_work asyncWork; + napi_deferred deferred; + Ability *ability = nullptr; + AppExecFwk::AbilityType abilityType = AppExecFwk::AbilityType::UNKNOWN; + int errCode = ERR_OK; +}; + +struct FileAccessHelperCB { + CBBase cbBase; + napi_ref uri = nullptr; + napi_value result = nullptr; +}; + +struct FileAccessHelperOpenFileCB { + CBBase cbBase; + FileAccessHelper *fileAccessHelper = nullptr; + std::string uri; + int flags; + int result = ERR_OK; + int execResult; +}; + +struct FileAccessHelperCreateFileCB { + CBBase cbBase; + FileAccessHelper *fileAccessHelper = nullptr; + std::string parentUri; + std::string name; + std::string result; + int execResult; +}; + +struct FileAccessHelperMkdirCB { + CBBase cbBase; + FileAccessHelper *fileAccessHelper = nullptr; + std::string parentUri; + std::string name; + std::string result; + int execResult; +}; + +struct FileAccessHelperDeleteCB { + CBBase cbBase; + FileAccessHelper *fileAccessHelper = nullptr; + std::string selectFileUri; + int result = ERR_OK; + int execResult; +}; + +struct FileAccessHelperMoveCB { + CBBase cbBase; + FileAccessHelper *fileAccessHelper = nullptr; + std::string sourceFileUri; + std::string targetParentUri; + std::string result; + int execResult; +}; + +struct FileAccessHelperRenameCB { + CBBase cbBase; + FileAccessHelper *fileAccessHelper = nullptr; + std::string sourceFileUri; + std::string displayName; + std::string result; + int execResult; +}; + +struct FileAccessHelperListFileCB { + CBBase cbBase; + FileAccessHelper *fileAccessHelper = nullptr; + std::string sourceFileUri; + std::vector result; + int execResult; +}; + +struct FileAccessHelperGetRootsCB { + CBBase cbBase; + FileAccessHelper *fileAccessHelper = nullptr; + std::vector result; + int execResult; +}; +} +} +#endif \ No newline at end of file diff --git a/interfaces/kits/napi/file_access_module/napi_fileaccess_helper.h b/interfaces/kits/napi/file_access_module/napi_fileaccess_helper.h new file mode 100644 index 0000000000000000000000000000000000000000..0f4fb297a43a3810d577db169ed8674d12607294 --- /dev/null +++ b/interfaces/kits/napi/file_access_module/napi_fileaccess_helper.h @@ -0,0 +1,114 @@ +/* + * Copyright (C) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef NAPI_FILEACCESS_HELPER_H +#define NAPI_FILEACCESS_HELPER_H + +#include "file_access_common.h" + +namespace OHOS { +namespace FileAccessFwk { + napi_value FileAccessHelperInit(napi_env env, napi_value exports); + napi_value FileAccessHelperConstructor(napi_env env, napi_callback_info info); + napi_value NAPI_OpenFile(napi_env env, napi_callback_info info); + napi_value OpenFileWrap(napi_env env, napi_callback_info info, FileAccessHelperOpenFileCB *openFileCB); + napi_value OpenFileAsync(napi_env env, + napi_value *args, + const size_t argCallback, + FileAccessHelperOpenFileCB *openFileCB); + napi_value OpenFilePromise(napi_env env, FileAccessHelperOpenFileCB *openFileCB); + void OpenFileExecuteCB(napi_env env, void *data); + void OpenFileAsyncCompleteCB(napi_env env, napi_status status, void *data); + void OpenFilePromiseCompleteCB(napi_env env, napi_status status, void *data); + + napi_value NAPI_CreateFile(napi_env env, napi_callback_info info); + napi_value CreateFileWrap(napi_env env, napi_callback_info info, FileAccessHelperCreateFileCB *createFileCB); + napi_value CreateFileAsync(napi_env env, + napi_value *args, + const size_t argCallback, + FileAccessHelperCreateFileCB *createFileCB); + napi_value CreateFilePromise(napi_env env, FileAccessHelperCreateFileCB *createFileCB); + void CreateFileExecuteCB(napi_env env, void *data); + void CreateFileAsyncCompleteCB(napi_env env, napi_status status, void *data); + void CreateFilePromiseCompleteCB(napi_env env, napi_status status, void *data); + + napi_value NAPI_Mkdir(napi_env env, napi_callback_info info); + napi_value MkdirWrap(napi_env env, napi_callback_info info, FileAccessHelperMkdirCB *mkdirCB); + napi_value MkdirAsync(napi_env env, + napi_value *args, + const size_t argCallback, + FileAccessHelperMkdirCB *mkdirCB); + napi_value MkdirPromise(napi_env env, FileAccessHelperMkdirCB *mkdirCB); + void MkdirExecuteCB(napi_env env, void *data); + void MkdirAsyncCompleteCB(napi_env env, napi_status status, void *data); + void MkdirPromiseCompleteCB(napi_env env, napi_status status, void *data); + + napi_value NAPI_Delete(napi_env env, napi_callback_info info); + napi_value DeleteWrap(napi_env env, napi_callback_info info, FileAccessHelperDeleteCB *deleteCB); + napi_value DeleteAsync(napi_env env, + napi_value *args, + const size_t argCallback, + FileAccessHelperDeleteCB *deleteCB); + napi_value DeletePromise(napi_env env, FileAccessHelperDeleteCB *deleteCB); + void DeleteExecuteCB(napi_env env, void *data); + void DeleteAsyncCompleteCB(napi_env env, napi_status status, void *data); + void DeletePromiseCompleteCB(napi_env env, napi_status status, void *data); + + napi_value NAPI_Move(napi_env env, napi_callback_info info); + napi_value MoveWrap(napi_env env, napi_callback_info info, FileAccessHelperMoveCB *moveCB); + napi_value MoveAsync(napi_env env, + napi_value *args, + const size_t argCallback, + FileAccessHelperMoveCB *moveCB); + napi_value MovePromise(napi_env env, FileAccessHelperMoveCB *moveCB); + void MoveExecuteCB(napi_env env, void *data); + void MoveAsyncCompleteCB(napi_env env, napi_status status, void *data); + void MovePromiseCompleteCB(napi_env env, napi_status status, void *data); + + napi_value NAPI_Rename(napi_env env, napi_callback_info info); + napi_value RenameWrap(napi_env env, napi_callback_info info, FileAccessHelperRenameCB *renameCB); + napi_value RenameAsync(napi_env env, + napi_value *args, + const size_t argCallback, + FileAccessHelperRenameCB *renameCB); + napi_value RenamePromise(napi_env env, FileAccessHelperRenameCB *renameCB); + void RenameExecuteCB(napi_env env, void *data); + void RenameAsyncCompleteCB(napi_env env, napi_status status, void *data); + void RenamePromiseCompleteCB(napi_env env, napi_status status, void *data); + + napi_value NAPI_ListFile(napi_env env, napi_callback_info info); + napi_value ListFileWrap(napi_env env, napi_callback_info info, FileAccessHelperListFileCB *listFileCB); + napi_value ListFileAsync(napi_env env, + napi_value *args, + const size_t argCallback, + FileAccessHelperListFileCB *listFileCB); + napi_value ListFilePromise(napi_env env, FileAccessHelperListFileCB *listFileCB); + void ListFileExecuteCB(napi_env env, void *data); + void ListFileAsyncCompleteCB(napi_env env, napi_status status, void *data); + void ListFilePromiseCompleteCB(napi_env env, napi_status status, void *data); + + napi_value NAPI_GetRoots(napi_env env, napi_callback_info info); + napi_value GetRootsWrap(napi_env env, napi_callback_info info, FileAccessHelperGetRootsCB *getRootsCB); + napi_value GetRootsAsync(napi_env env, + napi_value *args, + const size_t argCallback, + FileAccessHelperGetRootsCB *getRootsCB); + napi_value GetRootsPromise(napi_env env, FileAccessHelperGetRootsCB *getRootsCB); + void GetRootsExecuteCB(napi_env env, void *data); + void GetRootsAsyncCompleteCB(napi_env env, napi_status status, void *data); + void GetRootsPromiseCompleteCB(napi_env env, napi_status status, void *data); +} +} // namespace FileAccessFwk +#endif // FILE_ACCESS_NAPI_H \ No newline at end of file diff --git a/interfaces/kits/napi/file_access_module/native_fileaccess_module.cpp b/interfaces/kits/napi/file_access_module/native_fileaccess_module.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5154db21047a64d9c8ee4c08fd3e7e3ed0f4b6f3 --- /dev/null +++ b/interfaces/kits/napi/file_access_module/native_fileaccess_module.cpp @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +#include "file_extension_info_napi.h" +#include "hilog_wrapper.h" +#include "napi_fileaccess_helper.h" +#include "napi/native_api.h" +#include "napi/native_node_api.h" +using namespace std; + +namespace OHOS { +namespace FileAccessFwk { +EXTERN_C_START +/* + * The module initialization. + */ +static napi_value Init(napi_env env, napi_value exports) +{ + FileAccessHelperInit(env, exports); + InitFlag(env, exports); + InitFileInfo(env, exports); + InitDeviceInfo(env, exports); + return exports; +} +EXTERN_C_END + +/* + * The module definition. + */ +static napi_module _module = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "data.fileAccess", + .nm_priv = ((void *)0), + .reserved = {0} +}; + +/* + * The module registration. + */ +extern "C" __attribute__((constructor)) void RegisterModule(void) +{ + napi_module_register(&_module); +} +} // namespace FileAccessFwk +} // namespace OHOS \ No newline at end of file diff --git a/interfaces/kits/napi/file_extension_info_module/BUILD.gn b/interfaces/kits/napi/file_extension_info_module/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..b1893f20e79fe90f91374e53a539910c4b5a0b04 --- /dev/null +++ b/interfaces/kits/napi/file_extension_info_module/BUILD.gn @@ -0,0 +1,42 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/ohos.gni") + +UFS_BASE_PATH = "//foundation/filemanagement/user_file_service" +FRAMEWORK_PATH = "${UFS_BASE_PATH}/frameworks" + +ohos_shared_library("fileextensioninfo") { + subsystem_name = "filemanagement" + part_name = "user_file_service" + relative_install_dir = "module" + + include_dirs = [ + ".", + "${UFS_BASE_PATH}/interfaces/kits/napi/common", + "${FRAMEWORK_PATH}/innerkits/file_access/include", + ] + + sources = [ + "${UFS_BASE_PATH}/interfaces/kits/napi/common/file_extension_info_napi.cpp", + "module_export_napi.cpp", + ] + + deps = [ "//foundation/arkui/napi:ace_napi" ] + + external_deps = [ + "ability_base:zuri", + "hiviewdfx_hilog_native:libhilog", + "utils_base:utils", + ] +} diff --git a/interfaces/kits/napi/file_extension_info_module/module_export_napi.cpp b/interfaces/kits/napi/file_extension_info_module/module_export_napi.cpp new file mode 100644 index 0000000000000000000000000000000000000000..950e3900333eb9fd4b50863fc3dec1da73b6314e --- /dev/null +++ b/interfaces/kits/napi/file_extension_info_module/module_export_napi.cpp @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "module_export_napi.h" + +#include +#include "file_extension_info_napi.h" +#include "napi/native_api.h" +#include "napi/native_node_api.h" + +namespace OHOS { +namespace FileAccessFwk { +napi_value FileExtensionInfoExport(napi_env env, napi_value exports) +{ + InitFlag(env, exports); + InitFileInfo(env, exports); + InitDeviceInfo(env, exports); + + return exports; +} + +NAPI_MODULE(fileExtensionInfo, FileExtensionInfoExport) +} // namespace FileAccessFwk +} // namespace OHOS \ No newline at end of file diff --git a/interfaces/kits/napi/file_extension_info_module/module_export_napi.h b/interfaces/kits/napi/file_extension_info_module/module_export_napi.h new file mode 100644 index 0000000000000000000000000000000000000000..c49f3b0ae3779596e47069ecc2b2524041f4ae53 --- /dev/null +++ b/interfaces/kits/napi/file_extension_info_module/module_export_napi.h @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef MODULE_EXPORT_NAPI_H +#define MODULE_EXPORT_NAPI_H +namespace OHOS { +namespace FileAccessFwk { +} // namespace FileAccessFwk +} // namespace OHOS +#endif // MODULE_EXPORT_NAPI_H \ No newline at end of file