diff --git a/bundle.json b/bundle.json index 95dbc537d0a3d2fcb80f4ae861bdfb655108e715..5fab9ad88f16791ec3cfad58ef6cbd1031e540e6 100644 --- a/bundle.json +++ b/bundle.json @@ -35,7 +35,10 @@ "sub_component": [ "//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/interfaces/kits/js:filemanager", + "//foundation/filemanagement/user_file_service/frameworks/innerkits:frameworks_innerkits", + "//foundation/filemanagement/user_file_service/interfaces/kits/napi/file_access_module:fileaccess", + "//foundation/filemanagement/user_file_service/interfaces/kits/napi/file_ext_ability:fileextensionability_napi" ], "test": [ "//foundation/filemanagement/user_file_service/services/test:user_file_manager_test" diff --git a/frameworks/innerkits/BUILD.gn b/frameworks/innerkits/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..0c10968c00cac66b3a780ff5da09d7cc472ae45f --- /dev/null +++ b/frameworks/innerkits/BUILD.gn @@ -0,0 +1,58 @@ +# 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") + +group("frameworks_innerkits") { + deps = [ + ":file_extension_hap", + "file_extension:file_extension_ability_kit", + "file_extension:file_extension_ability_module", + ] +} + +#### file extension hap +ohos_hap("file_extension_hap") { + hap_profile = "file_extension_hap/entry/src/main/module.json" + deps = [ + ":file_extension_js_assets", + ":file_extension_resources", + ] + certificate_profile = "signature/fileextension.p7b" + hap_name = "file_extension" + subsystem_name = "filemanagement" + part_name = "user_file_service" + module_install_dir = "app/com.ohos.FileExtension" +} + +ohos_js_assets("file_extension_js_assets") { + hap_profile = "file_extension_hap/entry/src/main/module.json" + ets2abc = true + source_dir = "file_extension_hap/entry/src/main/ets" +} + +ohos_app_scope("file_extension_app_profile") { + app_profile = "file_extension_hap/AppScope/app.json" + sources = [ "file_extension_hap/AppScope/resources" ] +} + +ohos_resources("file_extension_resources") { + sources = [ + "file_extension_hap/entry/src/main/resources", + ] + deps = [ + ":file_extension_app_profile", + ] + hap_profile = "file_extension_hap/entry/src/main/module.json" +} +#### file extension hap \ No newline at end of file diff --git a/frameworks/innerkits/file_extension/BUILD.gn b/frameworks/innerkits/file_extension/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..aba44d064430e840ce2289a01998b00d4cae28cf --- /dev/null +++ b/frameworks/innerkits/file_extension/BUILD.gn @@ -0,0 +1,116 @@ +# 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" + +config("ability_config") { + visibility = [ ":*" ] + include_dirs = [ + "include", + "${BASE_DIR}/utils", + "//foundation/aafwk/standard/frameworks/kits/appkit/native/app/include", + "//foundation/aafwk/standard/services/common/include", + "//foundation/aafwk/standard/frameworks/kits/ability/native/include/continuation/distributed", + "//foundation/aafwk/standard/frameworks/kits/ability/native/include/continuation/kits", + "//foundation/aafwk/standard/interfaces/kits/napi/aafwk/inner/napi_common", + "//foundation/appexecfwk/standard/interfaces/innerkits/appexecfwk_base/include", + ] + + cflags = [] + if (target_cpu == "arm") { + cflags += [ "-DBINDER_IPC_32BIT" ] + } +} + +config("ability_public_config") { + visibility = [ ":*" ] + include_dirs = [ + "include", + "${BASE_DIR}/utils", + "//foundation/aafwk/standard/frameworks/kits/appkit/native/ability_runtime/app", + "//foundation/aafwk/standard/frameworks/kits/appkit/native/app/include", + "//foundation/aafwk/standard/frameworks/kits/appkit/native/ability_runtime/context", + ] +} + +ohos_shared_library("file_extension_ability_kit") { + include_dirs = [] + + sources = [ + "${BASE_DIR}/frameworks/innerkits/file_extension/src/file_access_helper.cpp", + "${BASE_DIR}/frameworks/innerkits/file_extension/src/file_ext_ability.cpp", + "${BASE_DIR}/frameworks/innerkits/file_extension/src/file_ext_connection.cpp", + "${BASE_DIR}/frameworks/innerkits/file_extension/src/file_ext_proxy.cpp", + "${BASE_DIR}/frameworks/innerkits/file_extension/src/file_ext_stub_impl.cpp", + "${BASE_DIR}/frameworks/innerkits/file_extension/src/file_ext_stub.cpp", + "${BASE_DIR}/frameworks/innerkits/file_extension/src/js_file_ext_ability.cpp", + ] + configs = [ ":ability_config" ] + public_configs = [ + ":ability_public_config", + "//foundation/aafwk/standard/frameworks/kits/ability/ability_runtime:ability_context_public_config", + ] + + deps = [ + "//foundation/aafwk/standard/frameworks/kits/ability/native:abilitykit_native", + "//foundation/aafwk/standard/frameworks/kits/appkit:app_context", + ] + + external_deps = [ + "ability_base:want", + "ability_base:zuri", + "ability_runtime:ability_context_native", + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "ability_runtime:runtime", + "ability_runtime:wantagent_innerkits", + "access_token:libaccesstoken_sdk", + "bytrace_standard:bytrace_core", + "ipc:ipc_core", + "ipc_js:rpc", + "permission_standard:libpermissionsdk_standard", + "utils_base:utils", + ] + + public_deps = [ + "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + "//foundation/arkui/napi:ace_napi", + ] + + subsystem_name = "filemanagement" + part_name = "user_file_service" +} + +ohos_shared_library("file_extension_ability_module") { + sources = [ "${BASE_DIR}/frameworks/innerkits/file_extension/src/file_ext_ability_module_loader.cpp" ] + + configs = [ ":ability_config" ] + public_configs = [ ":ability_public_config" ] + + deps = [ + ":file_extension_ability_kit", + "//foundation/aafwk/standard/frameworks/kits/ability/native:abilitykit_native", + ] + + external_deps = [ + "ability_base:want", + "ability_runtime:runtime", + "hiviewdfx_hilog_native:libhilog", + "utils_base:utils", + ] + + subsystem_name = "filemanagement" + part_name = "user_file_service" +} diff --git a/frameworks/innerkits/file_extension/include/file_access_helper.h b/frameworks/innerkits/file_extension/include/file_access_helper.h new file mode 100644 index 0000000000000000000000000000000000000000..a3f7e3cac3a904cebdfe39bf43b019813e20798e --- /dev/null +++ b/frameworks/innerkits/file_extension/include/file_access_helper.h @@ -0,0 +1,79 @@ +/* + * 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 FOUNDATION_APPEXECFWK_OHOS_FILEACCESS_HELPER_H +#define FOUNDATION_APPEXECFWK_OHOS_FILEACCESS_HELPER_H + +#include +#include +#include + +#include "file_ext_connection.h" +#include "foundation/aafwk/standard/frameworks/kits/appkit/native/ability_runtime/context/context.h" +#include "ifile_ext_base.h" +#include "uri.h" +#include "want.h" + +using Uri = OHOS::Uri; + +namespace OHOS { +namespace AppExecFwk { +using string = std::string; +class FileAccessHelper final : public std::enable_shared_from_this { +public: + ~FileAccessHelper() = default; + + static std::shared_ptr Creator(const std::shared_ptr &context, + const AAFwk::Want &want); + + bool Release(); + + int OpenFile(Uri &uri, const std::string &mode); + int CreateFile(Uri &parentUri, const std::string &displayName, Uri &newFileUri); + int Mkdir(Uri &parentUri, const std::string &displayName, Uri &newDirUri); + int Delete(Uri &selectFileUri); + int Move(Uri &sourceFileUri, Uri &targetParentUri, Uri &newFileUri); + int Rename(Uri &sourceFileUri, const std::string &displayName, Uri &newFileUri); + int CloseFile(int fd, const std::string &uri); +private: + FileAccessHelper(const std::shared_ptr &context, const AAFwk::Want &want, + const sptr &fileExtProxy); + void AddFileAccessDeathRecipient(const sptr &token); + void OnSchedulerDied(const wptr &remote); + + sptr token_ = {}; + AAFwk::Want want_ = {}; + sptr fileExtProxy_ = nullptr; + bool isSystemCaller_ = false; + sptr callerDeathRecipient_ = nullptr; + sptr fileExtConnection_ = nullptr; +}; + +class FileAccessDeathRecipient : public IRemoteObject::DeathRecipient { +public: + using RemoteDiedHandler = std::function &)>; + + explicit FileAccessDeathRecipient(RemoteDiedHandler handler); + + virtual ~FileAccessDeathRecipient(); + + virtual void OnRemoteDied(const wptr &remote); + +private: + RemoteDiedHandler handler_; +}; +} // namespace AppExecFwk +} // namespace OHOS +#endif // FOUNDATION_APPEXECFWK_OHOS_FILEACCESS_HELPER_H diff --git a/frameworks/innerkits/file_extension/include/file_ext_ability.h b/frameworks/innerkits/file_extension/include/file_ext_ability.h new file mode 100644 index 0000000000000000000000000000000000000000..c98a352abdc09d3c199035c4c489e079bae59584 --- /dev/null +++ b/frameworks/innerkits/file_extension/include/file_ext_ability.h @@ -0,0 +1,46 @@ +/* + * 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 FOUNDATION_ABILITYRUNTIME_OHOS_FILE_EXT_ABILITY_H +#define FOUNDATION_ABILITYRUNTIME_OHOS_FILE_EXT_ABILITY_H + +#include "extension_base.h" + +namespace OHOS { +namespace AbilityRuntime { +class Runtime; +class FileExtAbility : public ExtensionBase<> { +public: + FileExtAbility() = default; + virtual ~FileExtAbility() = default; + + virtual void Init(const std::shared_ptr &record, + const std::shared_ptr &application, + std::shared_ptr &handler, + const sptr &token) override; + + static FileExtAbility* Create(const std::unique_ptr& runtime); + + virtual int OpenFile(const Uri &uri, const std::string &mode); + virtual int CloseFile(int fd, const std::string &uri); + virtual int CreateFile(const Uri &parentUri, const std::string &displayName, Uri &newFileUri); + virtual int Mkdir(const Uri &parentUri, const std::string &displayName, Uri &newFileUri); + virtual int Delete(const Uri &sourceFileUri); + virtual int Move(const Uri &sourceFileUri, const Uri &targetParentUri, Uri &newFileUri); + virtual int Rename(const Uri &sourceFileUri, const std::string &displayName, Uri &newFileUri); +}; +} // namespace AbilityRuntime +} // namespace OHOS +#endif // FOUNDATION_ABILITYRUNTIME_OHOS_FILE_EXT_ABILITY_H \ No newline at end of file diff --git a/frameworks/innerkits/file_extension/include/file_ext_ability_module_loader.h b/frameworks/innerkits/file_extension/include/file_ext_ability_module_loader.h new file mode 100644 index 0000000000000000000000000000000000000000..81cd27ac4f48e148d482ffcca56e3022f05b31f6 --- /dev/null +++ b/frameworks/innerkits/file_extension/include/file_ext_ability_module_loader.h @@ -0,0 +1,36 @@ +/* + * 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 FOUNDATION_ABILITYRUTIME_FILE_EXT_ABILITY_MODULE_LOADER_H +#define FOUNDATION_ABILITYRUTIME_FILE_EXT_ABILITY_MODULE_LOADER_H + +#include "extension_module_loader.h" + +namespace OHOS::AbilityRuntime { +class FileExtAbilityModuleLoader : public ExtensionModuleLoader, + public Singleton { + DECLARE_SINGLETON(FileExtAbilityModuleLoader); + +public: + /** + * @brief Create Extension. + * + * @param runtime The runtime. + * @return The Extension instance. + */ + virtual Extension *Create(const std::unique_ptr& runtime) const override; +}; +} +#endif // FOUNDATION_ABILITYRUTIME_FILE_EXT_ABILITY_MODULE_LOADER_H \ No newline at end of file diff --git a/frameworks/innerkits/file_extension/include/file_ext_connection.h b/frameworks/innerkits/file_extension/include/file_ext_connection.h new file mode 100644 index 0000000000000000000000000000000000000000..292a913037ec124a9728725bc6c6301847868d88 --- /dev/null +++ b/frameworks/innerkits/file_extension/include/file_ext_connection.h @@ -0,0 +1,61 @@ +/* + * 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 FOUNDATION_APPEXECFWK_OHOS_FILEEXT_CONNECTION_H +#define FOUNDATION_APPEXECFWK_OHOS_FILEEXT_CONNECTION_H + +#include + +#include "ability_connect_callback_stub.h" +#include "event_handler.h" +#include "ifile_ext_base.h" +#include "want.h" + +namespace OHOS { +namespace AppExecFwk { +class FileExtConnection : public AAFwk::AbilityConnectionStub { +public: + FileExtConnection() = default; + virtual ~FileExtConnection() = default; + + + static sptr GetInstance(); + + void OnAbilityConnectDone( + const AppExecFwk::ElementName &element, const sptr &remoteObject, int resultCode) override; + + void OnAbilityDisconnectDone(const AppExecFwk::ElementName &element, int resultCode) override; + + + void ConnectFileExtAbility(const AAFwk::Want &want, const sptr &token); + + + void DisconnectFileExtAbility(); + + + bool IsExtAbilityConnected(); + + + sptr GetFileExtProxy(); + +private: + static sptr instance_; + static std::mutex mutex_; + std::atomic isConnected_ = {false}; + sptr fileExtProxy_; +}; +} // namespace AppExecFwk +} // namespace OHOS +#endif // FOUNDATION_APPEXECFWK_OHOS_DATASHARE_CONNECTION_H diff --git a/frameworks/innerkits/file_extension/include/file_ext_proxy.h b/frameworks/innerkits/file_extension/include/file_ext_proxy.h new file mode 100644 index 0000000000000000000000000000000000000000..1a3d2126d05d641d300f5e5298f7c6cb7d451390 --- /dev/null +++ b/frameworks/innerkits/file_extension/include/file_ext_proxy.h @@ -0,0 +1,43 @@ +/* + * 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 OHOS_APPEXECFWK_FILEEXT_PROXY_H +#define OHOS_APPEXECFWK_FILEEXT_PROXY_H + +#include +#include "ifile_ext_base.h" + +namespace OHOS { +namespace AppExecFwk { +class FileExtProxy : public IRemoteProxy { +public: + explicit FileExtProxy(const sptr& remote) : IRemoteProxy(remote) {} + + virtual ~FileExtProxy() {} + + virtual int OpenFile(const Uri &uri, const std::string &mode) override; + virtual int CloseFile(int fd, const std::string &uri) override; + virtual int CreateFile(const Uri &parentUri, const std::string &displayName, Uri &newFileUri) override; + virtual int Mkdir(const Uri &parentUri, const std::string &displayName, Uri &newFileUri) override; + virtual int Delete(const Uri &sourceFileUri) override; + virtual int Move(const Uri &sourceFileUri, const Uri &targetParentUri, Uri &newFileUri) override; + virtual int Rename(const Uri &sourceFileUri, const std::string &displayName, Uri &newFileUri) override; +private: + static inline BrokerDelegator delegator_; +}; +} // namespace AppExecFwk +} // namespace OHOS +#endif // OHOS_APPEXECFWK_DATASHARE_PROXY_H + diff --git a/frameworks/innerkits/file_extension/include/file_ext_stub.h b/frameworks/innerkits/file_extension/include/file_ext_stub.h new file mode 100644 index 0000000000000000000000000000000000000000..356e4cff8b702458f45d193f74db3c42df04fbd9 --- /dev/null +++ b/frameworks/innerkits/file_extension/include/file_ext_stub.h @@ -0,0 +1,45 @@ +/* + * 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 OHOS_APPEXECFWK_FILEEXT_STUB_H +#define OHOS_APPEXECFWK_FILEEXT_STUB_H + +#include +#include + +#include "ifile_ext_base.h" + +namespace OHOS { +namespace AppExecFwk { +class FileExtStub : public IRemoteStub { +public: + FileExtStub(); + ~FileExtStub(); + int OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) override; +private: + ErrCode CmdOpenFile(MessageParcel &data, MessageParcel &reply); + ErrCode CmdCloseFile(MessageParcel &data, MessageParcel &reply); + ErrCode CmdCreateFile(MessageParcel &data, MessageParcel &reply); + ErrCode CmdMkdir(MessageParcel &data, MessageParcel &reply); + ErrCode CmdDelete(MessageParcel &data, MessageParcel &reply); + ErrCode CmdMove(MessageParcel &data, MessageParcel &reply); + ErrCode CmdRename(MessageParcel &data, MessageParcel &reply); + using RequestFuncType = int (FileExtStub::*)(MessageParcel &data, MessageParcel &reply); + std::map stubFuncMap_; +}; +} // namespace AppExecFwk +} // namespace OHOS +#endif // OHOS_APPEXECFWK_FILEEXT_STUB_H + diff --git a/frameworks/innerkits/file_extension/include/file_ext_stub_impl.h b/frameworks/innerkits/file_extension/include/file_ext_stub_impl.h new file mode 100644 index 0000000000000000000000000000000000000000..9f964953dd0fbff0b3c4cc4d50bb38fccd7ef609 --- /dev/null +++ b/frameworks/innerkits/file_extension/include/file_ext_stub_impl.h @@ -0,0 +1,50 @@ +/* + * 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 OHOS_APPEXECFWK_FILEEXT_STUB_IMPL_H +#define OHOS_APPEXECFWK_FILEEXT_STUB_IMPL_H + +#include +#include "file_ext_stub.h" +#include "js_file_ext_ability.h" +#include "native_engine/native_value.h" + +namespace OHOS { +namespace AppExecFwk { +using AbilityRuntime::JsFileExtAbility; +class FileExtStubImpl : public FileExtStub { +public: + explicit FileExtStubImpl(const std::shared_ptr& extension, napi_env env) + : extension_(extension) {} + + virtual ~FileExtStubImpl() {} + + int OpenFile(const Uri &uri, const std::string &mode) override; + int CreateFile(const Uri &parentUri, const std::string &displayName, Uri &newFileUri) override; + int CloseFile(int fd, const std::string &uri) override; + int Mkdir(const Uri &parentUri, const std::string &displayName, Uri &newFileUri) override; + int Delete(const Uri &sourceFileUri) override; + int Move(const Uri &sourceFileUri, const Uri &targetParentUri, Uri &newFileUri) override; + int Rename(const Uri &sourceFileUri, const std::string &displayName, Uri &newFileUri) override; +private: + std::shared_ptr GetOwner(); + +private: + std::shared_ptr extension_; +}; +} // namespace AppExecFwk +} // namespace OHOS +#endif // OHOS_APPEXECFWK_FILEEXT_STUB_IMPL_H + diff --git a/frameworks/innerkits/file_extension/include/ifile_ext_base.h b/frameworks/innerkits/file_extension/include/ifile_ext_base.h new file mode 100644 index 0000000000000000000000000000000000000000..ad7399cf34d738d906162275e77f920a72b9a921 --- /dev/null +++ b/frameworks/innerkits/file_extension/include/ifile_ext_base.h @@ -0,0 +1,85 @@ +/* + * 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 OHOS_APPEXECFWK_I_FILEEXTBASE_H +#define OHOS_APPEXECFWK_I_FILEEXTBASE_H + +#include +#include +#include +#include "uri.h" + +namespace OHOS { +namespace AppExecFwk { +struct FileInfo +{ + Uri uri; + std::string fileName; + std::string mode; + size_t size; + int64_t mtime; + std::string mimiType; + std::bitset<32> flags; +}; + +struct DeviceInfo +{ + Uri uri; + std::string displayname; + std::string deviceId; + std::bitset<32> flags; +}; + +const std::string ATTRIBUTE_COLUMN_SUMMARY = "summary"; +const std::string ATTRIBUTE_COLUMN_LAST_MODIFIED = "last_modified"; +const std::string ATTRIBUTE_COLUMN_ICON = "icon"; +const std::string ATTRIBUTE_COLUMN_FLAGS = "flags"; +const std::string ATTRIBUTE_COLUMN_SIZE = "size"; + +const std::bitset<32> FLAG_SUPPORTS_THUMBNAIL = 1; +const std::bitset<32> FLAG_SUPPORTS_WRITE = 1 << 1; +const std::bitset<32> FLAG_SUPPORTS_DELETE = 1 << 2; +const std::bitset<32> FLAG_DIR_SUPPORTS_CREATE = 1 << 3; +const std::bitset<32> FLAG_DIR_PREFERS_LAST_MODIFIED = 1 << 4; +const std::bitset<32> FLAG_SUPPORTS_RENAME = 1 << 5; +const std::bitset<32> FLAG_SUPPORTS_COPY = 1 << 6; +const std::bitset<32> FLAG_SUPPORTS_MOVE = 1 << 7; +const std::bitset<32> FLAG_SUPPORTS_REMOVE = 1 << 8; + +class IFileExtBase : public IRemoteBroker { +public: + DECLARE_INTERFACE_DESCRIPTOR(u"OHOS.AppExecFwk.IFileExtBase"); + + enum { + CMD_OPEN_FILE = 1, + CMD_CLOSE_FILE = 2, + CMD_CREATE_FILE = 3, + CMD_MKDIR = 4, + CMD_DELETE = 5, + CMD_MOVE = 6, + CMD_RENAME = 7 + }; + + virtual int OpenFile(const Uri &uri, const std::string &mode) = 0; + virtual int CloseFile(int fd, const std::string &uri) = 0; + virtual int CreateFile(const Uri &parentUri, const std::string &displayName, Uri &newFileUri) = 0; + virtual int Mkdir(const Uri &parentUri, const std::string &displayName, Uri &newFileUri) = 0; + virtual int Delete(const Uri &sourceFileUri) = 0; + virtual int Move(const Uri &sourceFileUri, const Uri &targetParentUri, Uri &newFileUri) = 0; + virtual int Rename(const Uri &sourceFileUri, const std::string &displayName, Uri &newFileUri) = 0; +}; +} // namespace AppExecFwk +} // namespace OHOS +#endif // OHOS_APPEXECFWK_I_FILEEXTBASE_H diff --git a/frameworks/innerkits/file_extension/include/js_file_ext_ability.h b/frameworks/innerkits/file_extension/include/js_file_ext_ability.h new file mode 100644 index 0000000000000000000000000000000000000000..ae17d3e46f25357d16588324f190bd997e4d98c6 --- /dev/null +++ b/frameworks/innerkits/file_extension/include/js_file_ext_ability.h @@ -0,0 +1,62 @@ +/* + * 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 FOUNDATION_ABILITYRUNTIME_OHOS_JS_FILE_EXT_ABILITY_H +#define FOUNDATION_ABILITYRUNTIME_OHOS_JS_FILE_EXT_ABILITY_H + +#include "file_ext_ability.h" + +#include "js_runtime.h" +#include "native_engine/native_reference.h" +#include "native_engine/native_value.h" + +namespace OHOS { +namespace AbilityRuntime { + +class JsFileExtAbility : public FileExtAbility { +public: + JsFileExtAbility(JsRuntime& jsRuntime); + virtual ~JsFileExtAbility() override; + + static JsFileExtAbility* Create(const std::unique_ptr& runtime); + + void Init(const std::shared_ptr &record, + const std::shared_ptr &application, + std::shared_ptr &handler, + const sptr &token) override; + + + void OnStart(const AAFwk::Want &want) override; + + sptr OnConnect(const AAFwk::Want &want) override; + + int OpenFile(const Uri &uri, const std::string &mode) override; + int CloseFile(int fd, const std::string &uri) override; + int CreateFile(const Uri &parentUri, const std::string &displayName, Uri &newFileUri) override; + int Mkdir(const Uri &parentUri, const std::string &displayName, Uri &newFileUri) override; + int Delete(const Uri &sourceFileUri) override; + int Move(const Uri &sourceFileUri, const Uri &targetParentUri, Uri &newFileUri) override; + int Rename(const Uri &sourceFileUri, const std::string &displayName, Uri &newFileUri) override; + +private: + NativeValue* CallObjectMethod(const char* name, NativeValue* const* argv = nullptr, size_t argc = 0); + void GetSrcPath(std::string &srcPath); + + JsRuntime& jsRuntime_; + std::unique_ptr jsObj_; +}; +} // namespace AbilityRuntime +} // namespace OHOS +#endif // FOUNDATION_ABILITYRUNTIME_OHOS_JS_DATASHARE_EXT_ABILITY_H \ No newline at end of file diff --git a/frameworks/innerkits/file_extension/src/file_access_helper.cpp b/frameworks/innerkits/file_extension/src/file_access_helper.cpp new file mode 100644 index 0000000000000000000000000000000000000000..6a62e048edb8bdd955cc13fa4cca487d62ec9ead --- /dev/null +++ b/frameworks/innerkits/file_extension/src/file_access_helper.cpp @@ -0,0 +1,317 @@ +/* + * 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 "file_access_helper.h" + +#include "hilog_wrapper.h" +#include "ifile_ext_base.h" + +namespace OHOS { +namespace AppExecFwk { +namespace { +constexpr int INVALID_VALUE = -1; +} // namespace + + +FileAccessHelper::FileAccessHelper(const std::shared_ptr &context, + const AAFwk::Want &want, const sptr &fileExtProxy) +{ + HILOG_INFO("tag dsa FileAccessHelper::FileAccessHelper start"); + token_ = context->GetToken(); + want_ = want; + fileExtProxy_ = fileExtProxy; + fileExtConnection_ = FileExtConnection::GetInstance(); + HILOG_INFO("tag dsa FileAccessHelper::FileAccessHelper end"); +} + +void FileAccessHelper::AddFileAccessDeathRecipient(const sptr &token) +{ + HILOG_INFO("tag dsa %{public}s called begin", __func__); + if (token != nullptr && callerDeathRecipient_ != nullptr) { + HILOG_INFO("tag dsa token RemoveDeathRecipient."); + token->RemoveDeathRecipient(callerDeathRecipient_); + } + if (callerDeathRecipient_ == nullptr) { + callerDeathRecipient_ = + new FileAccessDeathRecipient(std::bind(&FileAccessHelper::OnSchedulerDied, this, std::placeholders::_1)); + } + if (token != nullptr) { + HILOG_INFO("tag dsa token AddDeathRecipient."); + token->AddDeathRecipient(callerDeathRecipient_); + } + HILOG_INFO("tag dsa %{public}s called end", __func__); +} + +void FileAccessHelper::OnSchedulerDied(const wptr &remote) +{ + HILOG_INFO("tag dsa %{public}s called begin", __func__); + auto object = remote.promote(); + object = nullptr; + fileExtProxy_ = nullptr; + HILOG_INFO("tag dsa %{public}s called end", __func__); +} + +std::shared_ptr FileAccessHelper::Creator( + const std::shared_ptr &context, const AAFwk::Want &want) +{ + HILOG_INFO("tag dsa FileAccessHelper::Creator with runtime context, want and uri called start."); + if (context == nullptr) { + HILOG_ERROR("tag dsa ileAccessHelper::Creator failed, context == nullptr"); + return nullptr; + } + + HILOG_INFO("tag dsa FileAccessHelper::Creator before ConnectFileExtAbility."); + sptr fileExtProxy = nullptr; + + sptr fileExtConnection = FileExtConnection::GetInstance(); + if (!fileExtConnection->IsExtAbilityConnected()) { + fileExtConnection->ConnectFileExtAbility(want, context->GetToken()); + } + fileExtProxy = fileExtConnection->GetFileExtProxy(); + if (fileExtProxy == nullptr) { + HILOG_WARN("tag dsa FileAccessHelper::Creator get invalid fileExtProxy"); + } + HILOG_INFO("tag dsa FileAccessHelper::Creator after ConnectFileExtAbility."); + + FileAccessHelper *ptrDataShareHelper = new (std::nothrow) FileAccessHelper(context, want, fileExtProxy); + if (ptrDataShareHelper == nullptr) { + HILOG_ERROR("tag dsa FileAccessHelper::Creator failed, create FileAccessHelper failed"); + return nullptr; + } + + HILOG_INFO("tag dsa FileAccessHelper::Creator with runtime context, want and uri called end."); + return std::shared_ptr(ptrDataShareHelper); +} + +bool FileAccessHelper::Release() +{ + HILOG_INFO("tag dsa %{public}s called begin", __func__); + + HILOG_INFO("tag dsa FileAccessHelper::Release before DisconnectFileExtAbility."); + if (fileExtConnection_->IsExtAbilityConnected()) { + fileExtConnection_->DisconnectFileExtAbility(); + } + HILOG_INFO("tag dsa FileAccessHelper::Release after DisconnectFileExtAbility."); + fileExtProxy_ = nullptr; + HILOG_INFO("tag dsa %{public}s called end", __func__); + return true; +} + +int FileAccessHelper::OpenFile(Uri &uri, const std::string &mode) +{ + HILOG_INFO("tag dsa %{public}s begin.", __func__); + int fd = INVALID_VALUE; + + HILOG_INFO("tag dsa FileAccessHelper::OpenFile before ConnectFileExtAbility."); + if (!fileExtConnection_->IsExtAbilityConnected()) { + fileExtConnection_->ConnectFileExtAbility(want_, token_); + } + fileExtProxy_ = fileExtConnection_->GetFileExtProxy(); + HILOG_INFO("tag dsa FileAccessHelper::OpenFile after ConnectFileExtAbility."); + if (isSystemCaller_ && fileExtProxy_) { + AddFileAccessDeathRecipient(fileExtProxy_->AsObject()); + } + + if (fileExtProxy_ == nullptr) { + HILOG_ERROR("tag dsa %{public}s failed with invalid fileExtProxy_", __func__); + return fd; + } + + HILOG_INFO("tag dsa FileAccessHelper::OpenFile before fileExtProxy_->OpenFile."); + fd = fileExtProxy_->OpenFile(uri, mode); + HILOG_INFO("tag dsa %{public}s begin.", __func__); + return fd; +} + +int FileAccessHelper::CreateFile(Uri &parentUri, const std::string &displayName, Uri &newFileUri) +{ + HILOG_INFO("tag dsa FileAccessHelper::CreateFile start."); + int index = INVALID_VALUE; + + HILOG_INFO("tag dsa FileAccessHelper::CreateFile before ConnectDataShareExtAbility."); + if (!fileExtConnection_->IsExtAbilityConnected()) { + fileExtConnection_->ConnectFileExtAbility(want_, token_); + } + fileExtProxy_ = fileExtConnection_->GetFileExtProxy(); + HILOG_INFO("tag dsa FileAccessHelper::CreateFile after ConnectDataShareExtAbility."); + if (isSystemCaller_ && fileExtProxy_) { + AddFileAccessDeathRecipient(fileExtProxy_->AsObject()); + } + + if (fileExtProxy_ == nullptr) { + HILOG_ERROR("tag dsa %{public}s failed with invalid fileExtProxy_", __func__); + return index; + } + + HILOG_INFO("tag dsa FileAccessHelper::CreateFile before fileExtProxy_->CreateFile."); + index = fileExtProxy_->CreateFile(parentUri, displayName, newFileUri); + HILOG_INFO("tag dsa FileAccessHelper::CreateFile end. index = %{public}d", index); + HILOG_INFO("tag dsa FileAccessHelper::CreateFile end. newDirUri = %{public}s", newFileUri.ToString().c_str()); + return index; +} + +int FileAccessHelper::Mkdir(Uri &parentUri, const std::string &displayName, Uri &newDirUri) +{ + HILOG_INFO("tag dsa FileAccessHelper::Mkdir start."); + int index = INVALID_VALUE; + + HILOG_INFO("tag dsa FileAccessHelper::Mkdir before ConnectDataShareExtAbility."); + if (!fileExtConnection_->IsExtAbilityConnected()) { + fileExtConnection_->ConnectFileExtAbility(want_, token_); + } + fileExtProxy_ = fileExtConnection_->GetFileExtProxy(); + HILOG_INFO("tag dsa FileAccessHelper::Mkdir after ConnectDataShareExtAbility."); + if (isSystemCaller_ && fileExtProxy_) { + AddFileAccessDeathRecipient(fileExtProxy_->AsObject()); + } + + if (fileExtProxy_ == nullptr) { + HILOG_ERROR("tag dsa %{public}s failed with invalid fileExtProxy_", __func__); + return index; + } + + HILOG_INFO("tag dsa FileAccessHelper::Mkdir before fileExtProxy_->Mkdir."); + index = fileExtProxy_->Mkdir(parentUri, displayName, newDirUri); + HILOG_INFO("tag dsa FileAccessHelper::Mkdir end. index = %{public}d", index); + HILOG_INFO("tag dsa FileAccessHelper::Mkdir end. newDirUri = %{public}s", newDirUri.ToString().c_str()); + return index; +} + +int FileAccessHelper::Delete(Uri &selectFileUri) +{ + HILOG_INFO("tag dsa %{public}s begin.", __func__); + int index = INVALID_VALUE; + + HILOG_INFO("tag dsa FileAccessHelper::Delete before ConnectFileExtAbility."); + if (!fileExtConnection_->IsExtAbilityConnected()) { + fileExtConnection_->ConnectFileExtAbility(want_, token_); + } + fileExtProxy_ = fileExtConnection_->GetFileExtProxy(); + HILOG_INFO("tag dsa FileAccessHelper::Delete after ConnectFileExtAbility."); + if (isSystemCaller_ && fileExtProxy_) { + AddFileAccessDeathRecipient(fileExtProxy_->AsObject()); + } + + if (fileExtProxy_ == nullptr) { + HILOG_ERROR("tag dsa %{public}s failed with invalid fileExtProxy_", __func__); + return index; + } + + HILOG_INFO("tag dsa FileAccessHelper::Delete before fileExtProxy_->Delete."); + index = fileExtProxy_->Delete(selectFileUri); + HILOG_INFO("tag dsa %{public}s begin.", __func__); + return index; +} + +int FileAccessHelper::Move(Uri &sourceFileUri, Uri &targetParentUri, Uri &newFileUri) +{ + HILOG_INFO("tag dsa FileAccessHelper::Move start."); + int index = INVALID_VALUE; + + HILOG_INFO("tag dsa FileAccessHelper::Move before ConnectDataShareExtAbility."); + if (!fileExtConnection_->IsExtAbilityConnected()) { + fileExtConnection_->ConnectFileExtAbility(want_, token_); + } + fileExtProxy_ = fileExtConnection_->GetFileExtProxy(); + HILOG_INFO("tag dsa FileAccessHelper::Move after ConnectDataShareExtAbility."); + if (isSystemCaller_ && fileExtProxy_) { + AddFileAccessDeathRecipient(fileExtProxy_->AsObject()); + } + + if (fileExtProxy_ == nullptr) { + HILOG_ERROR("tag dsa %{public}s failed with invalid fileExtProxy_", __func__); + return index; + } + + HILOG_INFO("tag dsa FileAccessHelper::Move before fileExtProxy_->Move."); + index = fileExtProxy_->Move(sourceFileUri, targetParentUri, newFileUri); + HILOG_INFO("tag dsa FileAccessHelper::Move end. index = %{public}d", index); + HILOG_INFO("tag dsa FileAccessHelper::Move end. newFileUri = %{public}s", newFileUri.ToString().c_str()); + return index; +} + +int FileAccessHelper::Rename(Uri &sourceFileUri, const std::string &displayName, Uri &newFileUri) +{ + HILOG_INFO("tag dsa FileAccessHelper::Rename start."); + int index = INVALID_VALUE; + + HILOG_INFO("tag dsa FileAccessHelper::Rename before ConnectDataShareExtAbility."); + if (!fileExtConnection_->IsExtAbilityConnected()) { + fileExtConnection_->ConnectFileExtAbility(want_, token_); + } + fileExtProxy_ = fileExtConnection_->GetFileExtProxy(); + HILOG_INFO("tag dsa FileAccessHelper::Rename after ConnectDataShareExtAbility."); + if (isSystemCaller_ && fileExtProxy_) { + AddFileAccessDeathRecipient(fileExtProxy_->AsObject()); + } + + if (fileExtProxy_ == nullptr) { + HILOG_ERROR("tag dsa %{public}s failed with invalid fileExtProxy_", __func__); + return index; + } + + HILOG_INFO("tag dsa FileAccessHelper::Rename before fileExtProxy_->Rename."); + index = fileExtProxy_->Rename(sourceFileUri, displayName, newFileUri); + HILOG_INFO("tag dsa FileAccessHelper::Rename end. index = %{public}d", index); + HILOG_INFO("tag dsa FileAccessHelper::Rename end. newFileUri = %{public}s", newFileUri.ToString().c_str()); + return index; +} + +int FileAccessHelper::CloseFile(int fd, const std::string &uri) +{ + HILOG_INFO("tag dsa %{public}s begin.", __func__); + int index = INVALID_VALUE; + + HILOG_INFO("tag dsa FileAccessHelper::CloseFile before ConnectFileExtAbility."); + if (!fileExtConnection_->IsExtAbilityConnected()) { + fileExtConnection_->ConnectFileExtAbility(want_, token_); + } + fileExtProxy_ = fileExtConnection_->GetFileExtProxy(); + HILOG_INFO("tag dsa FileAccessHelper::CloseFile after ConnectFileExtAbility."); + if (isSystemCaller_ && fileExtProxy_) { + AddFileAccessDeathRecipient(fileExtProxy_->AsObject()); + } + + if (fileExtProxy_ == nullptr) { + HILOG_ERROR("tag dsa %{public}s failed with invalid fileExtProxy_", __func__); + return index; + } + + HILOG_INFO("tag dsa FileAccessHelper::CloseFile before fileExtProxy_->CloseFile."); + index = fileExtProxy_->CloseFile(fd, uri); + HILOG_INFO("tag dsa %{public}s begin.", __func__); + return index; +} + +void FileAccessDeathRecipient::OnRemoteDied(const wptr &remote) +{ + HILOG_INFO("tag dsa %{public}s begin.", __func__); + if (handler_) { + handler_(remote); + } + HILOG_INFO("tag dsa %{public}s begin.", __func__); +} + +FileAccessDeathRecipient::FileAccessDeathRecipient(RemoteDiedHandler handler) : handler_(handler) +{ + HILOG_INFO("tag dsa %{public}s begin.", __func__); +} + +FileAccessDeathRecipient::~FileAccessDeathRecipient() +{ + HILOG_INFO("tag dsa %{public}s begin.", __func__); +} +} // namespace AppExecFwk +} // namespace OHOS \ No newline at end of file diff --git a/frameworks/innerkits/file_extension/src/file_ext_ability.cpp b/frameworks/innerkits/file_extension/src/file_ext_ability.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e137a15f4b775f8fcfc26c9c4ebe8e6b99ac7e6f --- /dev/null +++ b/frameworks/innerkits/file_extension/src/file_ext_ability.cpp @@ -0,0 +1,106 @@ +/* + * 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 "file_ext_ability.h" + +#include "ability_loader.h" +#include "connection_manager.h" +#include "extension_context.h" +#include "hilog_wrapper.h" +#include "js_file_ext_ability.h" +#include "runtime.h" + +namespace OHOS { +namespace AbilityRuntime { +using namespace OHOS::AppExecFwk; +FileExtAbility* FileExtAbility::Create(const std::unique_ptr& runtime) +{ + HILOG_INFO("tag dsa %{public}s begin.", __func__); + if (!runtime) { + return new FileExtAbility(); + } + HILOG_INFO("tag dsa FileExtAbility::Create runtime"); + switch (runtime->GetLanguage()) { + case Runtime::Language::JS: + HILOG_INFO("tag dsa Runtime::Language::JS --> JsFileExtAbility"); + return JsFileExtAbility::Create(runtime); + + default: + HILOG_INFO("tag dsa default --> FileExtAbility"); + return new FileExtAbility(); + } + HILOG_INFO("tag dsa %{public}s begin.", __func__); +} + +void FileExtAbility::Init(const std::shared_ptr &record, + const std::shared_ptr &application, + std::shared_ptr &handler, + const sptr &token) +{ + HILOG_INFO("tag dsa %{public}s begin.", __func__); + ExtensionBase<>::Init(record, application, handler, token); + HILOG_INFO("tag dsa %{public}s end.", __func__); +} + +int FileExtAbility::OpenFile(const Uri &uri, const std::string &mode) +{ + HILOG_INFO("tag dsa %{public}s begin.", __func__); + HILOG_INFO("tag dsa %{public}s end.", __func__); + return 0; +} + +int FileExtAbility::CloseFile(int fd, const std::string &uri) +{ + HILOG_INFO("tag dsa %{public}s begin.", __func__); + HILOG_INFO("tag dsa %{public}s end.", __func__); + return 0; +} + +int FileExtAbility::CreateFile(const Uri &parentUri, const std::string &displayName, Uri &newFileUri) +{ + HILOG_INFO("tag dsa %{public}s begin.", __func__); + HILOG_INFO("tag dsa %{public}s end.", __func__); + return 0; +} + +int FileExtAbility::Mkdir(const Uri &parentUri, const std::string &displayName, Uri &newFileUri) +{ + HILOG_INFO("tag dsa %{public}s begin.", __func__); + HILOG_INFO("tag dsa %{public}s end.", __func__); + return 0; +} + +int FileExtAbility::Delete(const Uri &sourceFileUri) +{ + HILOG_INFO("tag dsa %{public}s begin.", __func__); + HILOG_INFO("tag dsa %{public}s end.", __func__); + return 0; +} + +int FileExtAbility::Move(const Uri &sourceFileUri, const Uri &targetParentUri, Uri &newFileUri) +{ + HILOG_INFO("tag dsa %{public}s begin.", __func__); + HILOG_INFO("tag dsa %{public}s end.", __func__); + return 0; +} + +int FileExtAbility::Rename(const Uri &sourceFileUri, const std::string &displayName, Uri &newFileUri) +{ + HILOG_INFO("tag dsa %{public}s begin.", __func__); + HILOG_INFO("tag dsa %{public}s end.", __func__); + return 0; +} +} // namespace AbilityRuntime +} // namespace OHOS \ No newline at end of file diff --git a/frameworks/innerkits/file_extension/src/file_ext_ability_module_loader.cpp b/frameworks/innerkits/file_extension/src/file_ext_ability_module_loader.cpp new file mode 100644 index 0000000000000000000000000000000000000000..96ae5c4a8818b3b9fa1c9a3fc94345d7fb193441 --- /dev/null +++ b/frameworks/innerkits/file_extension/src/file_ext_ability_module_loader.cpp @@ -0,0 +1,34 @@ +/* + * 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 "file_ext_ability_module_loader.h" +#include "file_ext_ability.h" + +namespace OHOS::AbilityRuntime { +FileExtAbilityModuleLoader::FileExtAbilityModuleLoader() = default; +FileExtAbilityModuleLoader::~FileExtAbilityModuleLoader() = default; + +Extension *FileExtAbilityModuleLoader::Create(const std::unique_ptr& runtime) const +{ + HILOG_INFO("tag dsa %{public}s begin.", __func__); + return FileExtAbility::Create(runtime); +} + +extern "C" __attribute__((visibility("default"))) void* OHOS_EXTENSION_GetExtensionModule() +{ + HILOG_INFO("tag dsa %{public}s begin.", __func__); + return &FileExtAbilityModuleLoader::GetInstance(); +} +} // namespace OHOS::AbilityRuntime \ No newline at end of file diff --git a/frameworks/innerkits/file_extension/src/file_ext_connection.cpp b/frameworks/innerkits/file_extension/src/file_ext_connection.cpp new file mode 100644 index 0000000000000000000000000000000000000000..088932339a54aa73329b04489f35c60eba8438d9 --- /dev/null +++ b/frameworks/innerkits/file_extension/src/file_ext_connection.cpp @@ -0,0 +1,96 @@ +/* + * 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 "file_ext_connection.h" + +#include "ability_manager_client.h" +#include "bytrace.h" +#include "file_ext_proxy.h" +#include "hilog_wrapper.h" + +namespace OHOS { +namespace AppExecFwk { +sptr FileExtConnection::instance_ = nullptr; +std::mutex FileExtConnection::mutex_; + +sptr FileExtConnection::GetInstance() +{ + HILOG_INFO("tag dsa %{public}s begin.", __func__); + if (instance_ == nullptr) { + std::lock_guard lock(mutex_); + if (instance_ == nullptr) { + instance_ = sptr(new (std::nothrow) FileExtConnection()); + } + } + HILOG_INFO("tag dsa %{public}s end.", __func__); + return instance_; +} + +void FileExtConnection::OnAbilityConnectDone( + const AppExecFwk::ElementName &element, const sptr &remoteObject, int resultCode) +{ + HILOG_INFO("tag dsa %{public}s called begin", __func__); + BYTRACE_NAME(BYTRACE_TAG_DISTRIBUTEDDATA, __PRETTY_FUNCTION__); + if (remoteObject == nullptr) { + HILOG_ERROR("tag dsa FileExtConnection::OnAbilityConnectDone failed, remote is nullptr"); + return; + } + fileExtProxy_ = iface_cast(remoteObject); + if (fileExtProxy_ == nullptr) { + HILOG_ERROR("tag dsa FileExtConnection::OnAbilityConnectDone failed, fileExtProxy_ is nullptr"); + return; + } + isConnected_.store(true); + HILOG_INFO("tag dsa %{public}s end.", __func__); +} + +void FileExtConnection::OnAbilityDisconnectDone(const AppExecFwk::ElementName &element, int resultCode) +{ + HILOG_INFO("tag dsa %{public}s called begin", __func__); + BYTRACE_NAME(BYTRACE_TAG_DISTRIBUTEDDATA, __PRETTY_FUNCTION__); + fileExtProxy_ = nullptr; + isConnected_.store(false); + HILOG_INFO("tag dsa %{public}s called end", __func__); +} + +void FileExtConnection::ConnectFileExtAbility(const AAFwk::Want &want, const sptr &token) +{ + HILOG_INFO("tag dsa %{public}s called begin", __func__); + ErrCode ret = AAFwk::AbilityManagerClient::GetInstance()->ConnectAbility(want, this, token); + HILOG_INFO("tag dsa %{public}s called end, ret=%{public}d", __func__, ret); +} + +void FileExtConnection::DisconnectFileExtAbility() +{ + HILOG_INFO("tag dsa %{public}s called begin", __func__); + fileExtProxy_ = nullptr; + isConnected_.store(false); + ErrCode ret = AAFwk::AbilityManagerClient::GetInstance()->DisconnectAbility(this); + HILOG_INFO("tag dsa %{public}s called end, ret=%{public}d", __func__, ret); +} + +bool FileExtConnection::IsExtAbilityConnected() +{ + HILOG_INFO("tag dsa %{public}s called begin", __func__); + return isConnected_.load(); +} + +sptr FileExtConnection::GetFileExtProxy() +{ + HILOG_INFO("tag dsa %{public}s called begin", __func__); + return fileExtProxy_; +} +} // namespace AppExecFwk +} // namespace OHOS \ No newline at end of file diff --git a/frameworks/innerkits/file_extension/src/file_ext_proxy.cpp b/frameworks/innerkits/file_extension/src/file_ext_proxy.cpp new file mode 100644 index 0000000000000000000000000000000000000000..085c7b41e8d73b0c990d0ba7baa06a52727d0bb6 --- /dev/null +++ b/frameworks/innerkits/file_extension/src/file_ext_proxy.cpp @@ -0,0 +1,343 @@ +/* + * 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 "file_ext_proxy.h" + +#include "hilog_wrapper.h" + +namespace OHOS { +namespace AppExecFwk { +int FileExtProxy::OpenFile(const Uri &uri, const std::string &mode) +{ + HILOG_INFO("tag dsa %{public}s begin.", __func__); + int fd = -1; + MessageParcel data; + if (!data.WriteInterfaceToken(FileExtProxy::GetDescriptor())) { + HILOG_ERROR("tag dsa %{public}s WriteInterfaceToken failed", __func__); + return fd; + } + + if (!data.WriteParcelable(&uri)) { + HILOG_ERROR("tag dsa fail to WriteParcelable uri"); + return fd; + } + + if (!data.WriteString(mode)) { + HILOG_ERROR("tag dsa fail to WriteString mode"); + return fd; + } + + MessageParcel reply; + MessageOption option; + int32_t err = Remote()->SendRequest(CMD_OPEN_FILE, data, reply, option); + if (err != NO_ERROR) { + HILOG_ERROR("tag dsa OpenFile fail to SendRequest. err: %d", err); + return fd; + } + + fd = reply.ReadFileDescriptor(); + if (fd == -1) { + HILOG_ERROR("tag dsa fail to ReadFileDescriptor fd"); + return fd; + } + + HILOG_INFO("tag dsa %{public}s end successfully, return fd=%{public}d", __func__, fd); + return fd; +} + +int FileExtProxy::CloseFile(int fd, const std::string &uri) +{ + HILOG_INFO("tag dsa %{public}s begin.", __func__); + int ret = -1; + MessageParcel data; + if (!data.WriteInterfaceToken(FileExtProxy::GetDescriptor())) { + HILOG_ERROR("tag dsa %{public}s WriteInterfaceToken failed", __func__); + return ret; + } + + if (!data.WriteFileDescriptor(fd)) { + HILOG_ERROR("tag dsa fail to WriteFileDescriptor fd"); + return ret; + } + + if (!data.WriteString(uri)) { + HILOG_ERROR("tag dsa fail to WriteString uri"); + return ret; + } + + MessageParcel reply; + MessageOption option; + int32_t err = Remote()->SendRequest(CMD_CLOSE_FILE, data, reply, option); + if (err != NO_ERROR) { + HILOG_ERROR("tag dsa CloseFile fail to SendRequest. err: %d", err); + return ret; + } + + ret = reply.ReadInt32(); + if (ret < 0) { + HILOG_ERROR("tag dsa fail to ReadInt32 ret"); + return ret; + } + + HILOG_INFO("tag dsa %{public}s end successfully, return ret=%{public}d", __func__, ret); + return ret; +} + +int FileExtProxy::CreateFile(const Uri &parentUri, const std::string &displayName, Uri &newFileUri) +{ + HILOG_INFO("tag dsa %{public}s begin.", __func__); + int ret = -1; + MessageParcel data; + if (!data.WriteInterfaceToken(FileExtProxy::GetDescriptor())) { + HILOG_ERROR("tag dsa %{public}s WriteInterfaceToken failed", __func__); + return ret; + } + + if (!data.WriteParcelable(&parentUri)) { + HILOG_ERROR("tag dsa fail to WriteParcelable parentUri"); + return ret; + } + + if (!data.WriteString(displayName)) { + HILOG_ERROR("tag dsa fail to WriteString mode"); + return ret; + } + + if (!data.WriteParcelable(&newFileUri)) { + HILOG_ERROR("tag dsa fail to WriteParcelable newFileUri"); + return ret; + } + + MessageParcel reply; + MessageOption option; + int32_t err = Remote()->SendRequest(CMD_CREATE_FILE, data, reply, option); + if (err != NO_ERROR) { + HILOG_ERROR("tag dsa OpenFile fail to SendRequest. err: %d", err); + return ret; + } + + ret = reply.ReadInt32(); + if (ret < 0) { + HILOG_ERROR("tag dsa fail to ReadInt32 ret"); + return ret; + } + + std::unique_ptr tempUri(reply.ReadParcelable()); + if (!tempUri) { + HILOG_ERROR("ReadParcelable value is nullptr."); + ret = -1; + return ret; + } + + HILOG_INFO("tag dsa %{public}s end successfully, return ret=%{public}d, newFileUri=%{public}s", __func__, ret, newFileUri.ToString().c_str()); + newFileUri = Uri(*tempUri); + HILOG_INFO("tag dsa %{public}s end successfully, return ret=%{public}d, newFileUri=%{public}s", __func__, ret, newFileUri.ToString().c_str()); + HILOG_INFO("tag dsa %{public}s end successfully, tempUri=%{public}s", __func__, tempUri->ToString().c_str()); + return ret; +} + +int FileExtProxy::Mkdir(const Uri &parentUri, const std::string &displayName, Uri &newFileUri) +{ + HILOG_INFO("tag dsa %{public}s begin.", __func__); + int ret = -1; + MessageParcel data; + if (!data.WriteInterfaceToken(FileExtProxy::GetDescriptor())) { + HILOG_ERROR("tag dsa %{public}s WriteInterfaceToken failed", __func__); + return ret; + } + + if (!data.WriteParcelable(&parentUri)) { + HILOG_ERROR("tag dsa fail to WriteParcelable parentUri"); + return ret; + } + + if (!data.WriteString(displayName)) { + HILOG_ERROR("tag dsa fail to WriteString displayName"); + return ret; + } + + if (!data.WriteParcelable(&newFileUri)) { + HILOG_ERROR("tag dsa fail to WriteParcelable newFileUri"); + return ret; + } + + MessageParcel reply; + MessageOption option; + int32_t err = Remote()->SendRequest(CMD_MKDIR, data, reply, option); + if (err != NO_ERROR) { + HILOG_ERROR("tag dsa OpenFile fail to SendRequest. err: %d", err); + return ret; + } + + ret = reply.ReadInt32(); + if (ret < 0) { + HILOG_ERROR("tag dsa fail to ReadInt32 ret"); + return ret; + } + + std::unique_ptr tempUri(reply.ReadParcelable()); + if (!tempUri) { + HILOG_ERROR("ReadParcelable value is nullptr."); + ret = -1; + return ret; + } + + HILOG_INFO("tag dsa %{public}s end successfully, return ret=%{public}d, newFileUri=%{public}s", __func__, ret, newFileUri.ToString().c_str()); + newFileUri = Uri(*tempUri); + HILOG_INFO("tag dsa %{public}s end successfully, return ret=%{public}d, newFileUri=%{public}s", __func__, ret, newFileUri.ToString().c_str()); + HILOG_INFO("tag dsa %{public}s end successfully, tempUri=%{public}s", __func__, tempUri->ToString().c_str()); + return ret; +} + +int FileExtProxy::Delete(const Uri &sourceFileUri) +{ + HILOG_INFO("tag dsa %{public}s begin.", __func__); + int ret = -1; + MessageParcel data; + if (!data.WriteInterfaceToken(FileExtProxy::GetDescriptor())) { + HILOG_ERROR("tag dsa %{public}s WriteInterfaceToken failed", __func__); + return ret; + } + + if (!data.WriteParcelable(&sourceFileUri)) { + HILOG_ERROR("tag dsa fail to WriteParcelable sourceFileUri"); + return ret; + } + + MessageParcel reply; + MessageOption option; + int32_t err = Remote()->SendRequest(CMD_DELETE, data, reply, option); + if (err != NO_ERROR) { + HILOG_ERROR("tag dsa OpenFile fail to SendRequest. err: %d", err); + return ret; + } + + ret = reply.ReadInt32(); + if (ret < 0) { + HILOG_ERROR("tag dsa fail to ReadInt32 ret"); + return ret; + } + + HILOG_INFO("tag dsa %{public}s end successfully, return ret=%{public}d", __func__, ret); + return ret; +} + +int FileExtProxy::Move(const Uri &sourceFileUri, const Uri &targetParentUri, Uri &newFileUri) +{ + HILOG_INFO("tag dsa %{public}s begin.", __func__); + int ret = -1; + MessageParcel data; + if (!data.WriteInterfaceToken(FileExtProxy::GetDescriptor())) { + HILOG_ERROR("tag dsa %{public}s WriteInterfaceToken failed", __func__); + return ret; + } + + if (!data.WriteParcelable(&sourceFileUri)) { + HILOG_ERROR("tag dsa fail to WriteParcelable sourceFileUri"); + return ret; + } + + if (!data.WriteParcelable(&targetParentUri)) { + HILOG_ERROR("tag dsa fail to WriteParcelable targetParentUri"); + return ret; + } + + if (!data.WriteParcelable(&newFileUri)) { + HILOG_ERROR("tag dsa fail to WriteParcelable newFileUri"); + return ret; + } + + MessageParcel reply; + MessageOption option; + int32_t err = Remote()->SendRequest(CMD_MOVE, data, reply, option); + if (err != NO_ERROR) { + HILOG_ERROR("tag dsa OpenFile fail to SendRequest. err: %d", err); + return ret; + } + + ret = reply.ReadInt32(); + if (ret < 0) { + HILOG_ERROR("tag dsa fail to ReadInt32 ret"); + return ret; + } + + std::unique_ptr tempUri(reply.ReadParcelable()); + if (!tempUri) { + HILOG_ERROR("ReadParcelable value is nullptr."); + ret = -1; + return ret; + } + + HILOG_INFO("tag dsa %{public}s end successfully, return ret=%{public}d, newFileUri=%{public}s", __func__, ret, newFileUri.ToString().c_str()); + newFileUri = Uri(*tempUri); + HILOG_INFO("tag dsa %{public}s end successfully, return ret=%{public}d, newFileUri=%{public}s", __func__, ret, newFileUri.ToString().c_str()); + HILOG_INFO("tag dsa %{public}s end successfully, tempUri=%{public}s", __func__, tempUri->ToString().c_str()); + return ret; +} + +int FileExtProxy::Rename(const Uri &sourceFileUri, const std::string &displayName, Uri &newFileUri) +{ + HILOG_INFO("tag dsa %{public}s begin.", __func__); + int ret = -1; + MessageParcel data; + if (!data.WriteInterfaceToken(FileExtProxy::GetDescriptor())) { + HILOG_ERROR("tag dsa %{public}s WriteInterfaceToken failed", __func__); + return ret; + } + + if (!data.WriteParcelable(&sourceFileUri)) { + HILOG_ERROR("tag dsa fail to WriteParcelable sourceFileUri"); + return ret; + } + + if (!data.WriteString(displayName)) { + HILOG_ERROR("tag dsa fail to WriteString displayName"); + return ret; + } + + if (!data.WriteParcelable(&newFileUri)) { + HILOG_ERROR("tag dsa fail to WriteParcelable newFileUri"); + return ret; + } + + MessageParcel reply; + MessageOption option; + int32_t err = Remote()->SendRequest(CMD_RENAME, data, reply, option); + if (err != NO_ERROR) { + HILOG_ERROR("tag dsa OpenFile fail to SendRequest. err: %d", err); + return ret; + } + + ret = reply.ReadInt32(); + if (ret < 0) { + HILOG_ERROR("tag dsa fail to ReadInt32 ret"); + return ret; + } + + std::unique_ptr tempUri(reply.ReadParcelable()); + if (!tempUri) { + HILOG_ERROR("ReadParcelable value is nullptr."); + ret = -1; + return ret; + } + + HILOG_INFO("tag dsa %{public}s end successfully, return ret=%{public}d, newFileUri=%{public}s", __func__, ret, newFileUri.ToString().c_str()); + newFileUri = Uri(*tempUri); + HILOG_INFO("tag dsa %{public}s end successfully, return ret=%{public}d, newFileUri=%{public}s", __func__, ret, newFileUri.ToString().c_str()); + HILOG_INFO("tag dsa %{public}s end successfully, tempUri=%{public}s", __func__, tempUri->ToString().c_str()); + return ret; +} +} // namespace AAFwk +} // namespace OHOS diff --git a/frameworks/innerkits/file_extension/src/file_ext_stub.cpp b/frameworks/innerkits/file_extension/src/file_ext_stub.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e81ddb29a2a375fb261968e794b0f991d63bd9b8 --- /dev/null +++ b/frameworks/innerkits/file_extension/src/file_ext_stub.cpp @@ -0,0 +1,298 @@ +/* + * 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 "file_ext_stub.h" + +#include "hilog_wrapper.h" + +namespace OHOS { +namespace AppExecFwk { +FileExtStub::FileExtStub() +{ + HILOG_INFO("tag dsa %{public}s begin.", __func__); + stubFuncMap_[CMD_OPEN_FILE] = &FileExtStub::CmdOpenFile; + stubFuncMap_[CMD_CLOSE_FILE] = &FileExtStub::CmdCloseFile; + stubFuncMap_[CMD_CREATE_FILE] = &FileExtStub::CmdCreateFile; + stubFuncMap_[CMD_MKDIR] = &FileExtStub::CmdMkdir; + stubFuncMap_[CMD_DELETE] = &FileExtStub::CmdDelete; + stubFuncMap_[CMD_MOVE] = &FileExtStub::CmdMove; + stubFuncMap_[CMD_RENAME] = &FileExtStub::CmdRename; +} + +FileExtStub::~FileExtStub() +{ + HILOG_INFO("tag dsa %{public}s begin.", __func__); + stubFuncMap_.clear(); +} + +int FileExtStub::OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, + MessageOption& option) +{ + HILOG_INFO("tag dsa %{public}s Received stub message: %{public}d", __func__, code); + std::u16string descriptor = FileExtStub::GetDescriptor(); + std::u16string remoteDescriptor = data.ReadInterfaceToken(); + if (descriptor != remoteDescriptor) { + HILOG_INFO("tag dsa local descriptor is not equal to remote"); + return ERR_INVALID_STATE; + } + + const auto &itFunc = stubFuncMap_.find(code); + if (itFunc != stubFuncMap_.end()) { + return (this->*(itFunc->second))(data, reply); + } + + HILOG_INFO("tag dsa %{public}s remote request unhandled: %{public}d", __func__, code); + return IPCObjectStub::OnRemoteRequest(code, data, reply, option); +} + +ErrCode FileExtStub::CmdOpenFile(MessageParcel &data, MessageParcel &reply) +{ + HILOG_INFO("tag dsa %{public}s begin.", __func__); + std::shared_ptr uri(data.ReadParcelable()); + if (uri == nullptr) { + HILOG_ERROR("tag dsa FileExtStub uri is nullptr"); + return ERR_INVALID_VALUE; + } + std::string mode = data.ReadString(); + if (mode.empty()) { + HILOG_ERROR("tag dsa FileExtStub mode is nullptr"); + return ERR_INVALID_VALUE; + } + int fd = OpenFile(*uri, mode); + if (fd < 0) { + HILOG_ERROR("tag dsa OpenFile fail, fd is %{pubilc}d", fd); + return ERR_INVALID_VALUE; + } + HILOG_INFO("tag dsa %{public}s retutn fd: %{public}d.", __func__, fd); + + if (!reply.WriteFileDescriptor(fd)) { + HILOG_ERROR("tag dsa fail to WriteFileDescriptor fd"); + return ERR_INVALID_VALUE; + } + HILOG_INFO("tag dsa %{public}s end.", __func__); + return NO_ERROR; +} + +ErrCode FileExtStub::CmdCloseFile(MessageParcel &data, MessageParcel &reply) +{ + HILOG_INFO("tag dsa %{public}s begin.", __func__); + int fd = data.ReadFileDescriptor(); + if (fd < 0) { + HILOG_ERROR("tag dsa FileExtStub fd is invalid"); + return ERR_INVALID_VALUE; + } + std::string uri = data.ReadString(); + if (uri.empty()) { + HILOG_ERROR("tag dsa FileExtStub uri is nullptr"); + return ERR_INVALID_VALUE; + } + + int ret = CloseFile(fd, uri); + if (ret < 0) { + HILOG_ERROR("tag dsa CloseFile fail, ret is %{pubilc}d", ret); + return ERR_INVALID_VALUE; + } + + if (!reply.WriteInt32(ret)) { + HILOG_ERROR("tag dsa fail to WriteInt32 ret"); + return ERR_INVALID_VALUE; + } + HILOG_INFO("tag dsa %{public}s end.", __func__); + return NO_ERROR; +} + +ErrCode FileExtStub::CmdCreateFile(MessageParcel &data, MessageParcel &reply) +{ + HILOG_INFO("tag dsa %{public}s begin.", __func__); + std::shared_ptr parentUri(data.ReadParcelable()); + if (parentUri == nullptr) { + HILOG_ERROR("tag dsa FileExtStub parentUri is nullptr"); + return ERR_INVALID_VALUE; + } + std::string displayName = data.ReadString(); + if (displayName.empty()) { + HILOG_ERROR("tag dsa FileExtStub mode is nullptr"); + return ERR_INVALID_VALUE; + } + std::shared_ptr newFileUri(data.ReadParcelable()); + if (newFileUri == nullptr) { + HILOG_ERROR("tag dsa FileExtStub newFileUri is nullptr"); + return ERR_INVALID_VALUE; + } + + int ret = CreateFile(*parentUri, displayName, *newFileUri); + if (ret < 0) { + HILOG_ERROR("tag dsa CreateFile fail, ret is %{pubilc}d", ret); + return ERR_INVALID_VALUE; + } + + if (!reply.WriteInt32(ret)) { + HILOG_ERROR("tag dsa fail to WriteInt32 ret"); + return ERR_INVALID_VALUE; + } + + if (!reply.WriteParcelable(&(*newFileUri))) { + HILOG_ERROR("fail to WriteParcelable type"); + return ERR_INVALID_VALUE; + } + HILOG_INFO("tag dsa %{public}s end. ret:%d, newFileUri = %{public}s", __func__, ret, newFileUri->ToString().c_str()); + HILOG_INFO("tag dsa %{public}s end. newFileUri = %{public}s", __func__, newFileUri->ToString().c_str()); + return NO_ERROR; +} + +ErrCode FileExtStub::CmdMkdir(MessageParcel &data, MessageParcel &reply) +{ + HILOG_INFO("tag dsa %{public}s begin.", __func__); + std::shared_ptr parentUri(data.ReadParcelable()); + if (parentUri == nullptr) { + HILOG_ERROR("tag dsa FileExtStub parentUri is nullptr"); + return ERR_INVALID_VALUE; + } + std::string displayName = data.ReadString(); + if (displayName.empty()) { + HILOG_ERROR("tag dsa FileExtStub mode is nullptr"); + return ERR_INVALID_VALUE; + } + std::shared_ptr newFileUri(data.ReadParcelable()); + if (newFileUri == nullptr) { + HILOG_ERROR("tag dsa FileExtStub newFileUri is nullptr"); + return ERR_INVALID_VALUE; + } + + int ret = Mkdir(*parentUri, displayName, *newFileUri); + if (ret < 0) { + HILOG_ERROR("tag dsa Mkdir fail, ret is %{pubilc}d", ret); + return ERR_INVALID_VALUE; + } + + if (!reply.WriteInt32(ret)) { + HILOG_ERROR("tag dsa fail to WriteInt32 ret"); + return ERR_INVALID_VALUE; + } + + if (!reply.WriteParcelable(&(*newFileUri))) { + HILOG_ERROR("fail to WriteParcelable type"); + return ERR_INVALID_VALUE; + } + + HILOG_INFO("tag dsa %{public}s end. ret:%d, newFileUri = %{public}s", __func__, ret, newFileUri->ToString().c_str()); + HILOG_INFO("tag dsa %{public}s end. newFileUri = %{public}s", __func__, newFileUri->ToString().c_str()); + return NO_ERROR; +} + +ErrCode FileExtStub::CmdDelete(MessageParcel &data, MessageParcel &reply) +{ + HILOG_INFO("tag dsa %{public}s begin.", __func__); + std::shared_ptr uri(data.ReadParcelable()); + if (uri == nullptr) { + HILOG_ERROR("tag dsa FileExtStub uri is nullptr"); + return ERR_INVALID_VALUE; + } + + int ret = Delete(*uri); + if (ret < 0) { + HILOG_ERROR("tag dsa Delete fail, ret is %{pubilc}d", ret); + return ERR_INVALID_VALUE; + } + + if (!reply.WriteInt32(ret)) { + HILOG_ERROR("tag dsa fail to WriteFileDescriptor ret"); + return ERR_INVALID_VALUE; + } + HILOG_INFO("tag dsa %{public}s end.", __func__); + return NO_ERROR; +} + +ErrCode FileExtStub::CmdMove(MessageParcel &data, MessageParcel &reply) +{ + HILOG_INFO("tag dsa %{public}s begin.", __func__); + std::shared_ptr sourceFileUri(data.ReadParcelable()); + if (sourceFileUri == nullptr) { + HILOG_ERROR("tag dsa FileExtStub sourceFileUri is nullptr"); + return ERR_INVALID_VALUE; + } + std::shared_ptr targetParentUri(data.ReadParcelable()); + if (targetParentUri == nullptr) { + HILOG_ERROR("tag dsa FileExtStub targetParentUri is nullptr"); + return ERR_INVALID_VALUE; + } + std::shared_ptr newFileUri(data.ReadParcelable()); + if (newFileUri == nullptr) { + HILOG_ERROR("tag dsa FileExtStub newFileUri is nullptr"); + return ERR_INVALID_VALUE; + } + + int ret = Move(*sourceFileUri, *targetParentUri, *newFileUri); + if (ret < 0) { + HILOG_ERROR("tag dsa Move fail, ret is %{pubilc}d", ret); + return ERR_INVALID_VALUE; + } + + if (!reply.WriteInt32(ret)) { + HILOG_ERROR("tag dsa fail to WriteInt32 ret"); + return ERR_INVALID_VALUE; + } + + if (!reply.WriteParcelable(&(*newFileUri))) { + HILOG_ERROR("fail to WriteParcelable type"); + return ERR_INVALID_VALUE; + } + + HILOG_INFO("tag dsa %{public}s end. ret:%d, newFileUri = %{public}s", __func__, ret, newFileUri->ToString().c_str()); + HILOG_INFO("tag dsa %{public}s end. newFileUri = %{public}s", __func__, newFileUri->ToString().c_str()); + return NO_ERROR; +} + +ErrCode FileExtStub::CmdRename(MessageParcel &data, MessageParcel &reply) +{ + HILOG_INFO("tag dsa %{public}s begin.", __func__); + std::shared_ptr sourceFileUri(data.ReadParcelable()); + if (sourceFileUri == nullptr) { + HILOG_ERROR("tag dsa FileExtStub sourceFileUri is nullptr"); + return ERR_INVALID_VALUE; + } + std::string displayName = data.ReadString(); + if (displayName.empty()) { + HILOG_ERROR("tag dsa FileExtStub mode is nullptr"); + return ERR_INVALID_VALUE; + } + std::shared_ptr newFileUri(data.ReadParcelable()); + if (newFileUri == nullptr) { + HILOG_ERROR("tag dsa FileExtStub newFileUri is nullptr"); + return ERR_INVALID_VALUE; + } + + int ret = Rename(*sourceFileUri, displayName, *newFileUri); + if (ret < 0) { + HILOG_ERROR("tag dsa Rename fail, ret is %{pubilc}d", ret); + return ERR_INVALID_VALUE; + } + + if (!reply.WriteInt32(ret)) { + HILOG_ERROR("tag dsa fail to WriteInt32 ret"); + return ERR_INVALID_VALUE; + } + + if (!reply.WriteParcelable(&(*newFileUri))) { + HILOG_ERROR("fail to WriteParcelable type"); + return ERR_INVALID_VALUE; + } + + HILOG_INFO("tag dsa %{public}s end. ret:%d, newFileUri = %{public}s", __func__, ret, newFileUri->ToString().c_str()); + HILOG_INFO("tag dsa %{public}s end. newFileUri = %{public}s", __func__, newFileUri->ToString().c_str()); + return NO_ERROR; +} +} // namespace AAFwk +} // namespace OHOS diff --git a/frameworks/innerkits/file_extension/src/file_ext_stub_impl.cpp b/frameworks/innerkits/file_extension/src/file_ext_stub_impl.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ced9fe2123848002bb0acd9de3fc5f5666dc59e3 --- /dev/null +++ b/frameworks/innerkits/file_extension/src/file_ext_stub_impl.cpp @@ -0,0 +1,124 @@ +/* + * 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 "file_ext_stub_impl.h" + +#include "hilog_wrapper.h" + +namespace OHOS { +namespace AppExecFwk { +std::shared_ptr FileExtStubImpl::GetOwner() +{ + HILOG_INFO("tag dsa %{public}s begin.", __func__); + return extension_; +} + +int FileExtStubImpl::OpenFile(const Uri &uri, const std::string &mode) +{ + HILOG_INFO("tag dsa %{public}s begin.", __func__); + int ret = -1; + auto extension = GetOwner(); + if (extension == nullptr) { + HILOG_ERROR("tag dsa %{public}s end failed.", __func__); + return ret; + } + ret = extension->OpenFile(uri, mode); + HILOG_INFO("tag dsa %{public}s end successfully, return fd:%{public}d", __func__, ret); + return ret; +} + +int FileExtStubImpl::CloseFile(int fd, const std::string &uri) +{ + HILOG_INFO("tag dsa %{public}s begin.", __func__); + int ret = -1; + auto extension = GetOwner(); + if (extension == nullptr) { + HILOG_ERROR("tag dsa %{public}s end failed.", __func__); + return ret; + } + ret = extension->CloseFile(fd, uri); + HILOG_INFO("tag dsa %{public}s end successfully, return fd:%{public}d", __func__, ret); + return ret; +} + +int FileExtStubImpl::CreateFile(const Uri &parentUri, const std::string &displayName, Uri &newFileUri) +{ + HILOG_INFO("tag dsa %{public}s begin.", __func__); + int ret = -1; + auto extension = GetOwner(); + if (extension == nullptr) { + HILOG_ERROR("tag dsa %{public}s end failed.", __func__); + return ret; + } + ret = extension->CreateFile(parentUri, displayName, newFileUri); + HILOG_INFO("tag dsa %{public}s end successfully, return ret:%{public}d, %{public}s", __func__, ret,newFileUri.ToString().c_str()); + return ret; +} + +int FileExtStubImpl::Mkdir(const Uri &parentUri, const std::string &displayName, Uri &newFileUri) +{ + HILOG_INFO("tag dsa %{public}s begin.", __func__); + int ret = -1; + auto extension = GetOwner(); + if (extension == nullptr) { + HILOG_ERROR("tag dsa %{public}s end failed.", __func__); + return ret; + } + ret = extension->Mkdir(parentUri, displayName, newFileUri); + HILOG_INFO("tag dsa %{public}s end successfully, return ret:%{public}d, %{public}s", __func__, ret,newFileUri.ToString().c_str()); + return ret; +} + +int FileExtStubImpl::Delete(const Uri &sourceFileUri) +{ + HILOG_INFO("tag dsa %{public}s begin.", __func__); + int ret = -1; + auto extension = GetOwner(); + if (extension == nullptr) { + HILOG_ERROR("tag dsa %{public}s end failed.", __func__); + return ret; + } + ret = extension->Delete(sourceFileUri); + HILOG_INFO("tag dsa %{public}s end successfully, return fd:%{public}d", __func__, ret); + return ret; +} +int FileExtStubImpl::Move(const Uri &sourceFileUri, const Uri &targetParentUri, Uri &newFileUri) +{ + HILOG_INFO("tag dsa %{public}s begin.", __func__); + int ret = -1; + auto extension = GetOwner(); + if (extension == nullptr) { + HILOG_ERROR("tag dsa %{public}s end failed.", __func__); + return ret; + } + ret = extension->Move(sourceFileUri, targetParentUri, newFileUri); + HILOG_INFO("tag dsa %{public}s end successfully, return ret:%{public}d, %{public}s", __func__, ret,newFileUri.ToString().c_str()); + return ret; +} +int FileExtStubImpl::Rename(const Uri &sourceFileUri, const std::string &displayName, Uri &newFileUri) +{ + HILOG_INFO("tag dsa %{public}s begin.", __func__); + int ret = -1; + auto extension = GetOwner(); + if (extension == nullptr) { + HILOG_ERROR("tag dsa %{public}s end failed.", __func__); + return ret; + } + ret = extension->Rename(sourceFileUri, displayName, newFileUri); + HILOG_INFO("tag dsa %{public}s end successfully, return ret:%{public}d, %{public}s", __func__, ret,newFileUri.ToString().c_str()); + return ret; +} +} // namespace AppExecFwk +} // namespace OHOS diff --git a/frameworks/innerkits/file_extension/src/js_file_ext_ability.cpp b/frameworks/innerkits/file_extension/src/js_file_ext_ability.cpp new file mode 100644 index 0000000000000000000000000000000000000000..cc6509748d42685c1ee9fc31ba442e420eca6018 --- /dev/null +++ b/frameworks/innerkits/file_extension/src/js_file_ext_ability.cpp @@ -0,0 +1,365 @@ +/* + * 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 "js_file_ext_ability.h" + +#include "extension_context.h" +#include "ability_info.h" +#include "accesstoken_kit.h" +#include "bytrace.h" +#include "file_ext_stub_impl.h" +#include "hilog_wrapper.h" +#include "ipc_skeleton.h" +#include "js_runtime.h" +#include "js_runtime_utils.h" +#include "napi/native_api.h" +#include "napi/native_node_api.h" +#include "napi_common_util.h" +#include "napi_common_want.h" +#include "napi_remote_object.h" + +namespace OHOS { +namespace AbilityRuntime { +namespace { +constexpr size_t ARGC_ONE = 1; +constexpr size_t ARGC_TWO = 2; +} + +using namespace OHOS::AppExecFwk; +using OHOS::Security::AccessToken::AccessTokenKit; + +JsFileExtAbility* JsFileExtAbility::Create(const std::unique_ptr& runtime) +{ + HILOG_INFO("tag dsa %{public}s begin.", __func__); + return new JsFileExtAbility(static_cast(*runtime)); +} + +JsFileExtAbility::JsFileExtAbility(JsRuntime& jsRuntime) : jsRuntime_(jsRuntime) {} +JsFileExtAbility::~JsFileExtAbility() = default; + +void JsFileExtAbility::Init(const std::shared_ptr &record, + const std::shared_ptr &application, std::shared_ptr &handler, + const sptr &token) +{ + HILOG_INFO("tag dsa %{public}s begin.", __func__); + FileExtAbility::Init(record, application, handler, token); + std::string srcPath = ""; + GetSrcPath(srcPath); + if (srcPath.empty()) { + HILOG_ERROR("tag dsa Failed to get srcPath"); + return; + } + + std::string moduleName(Extension::abilityInfo_->moduleName); + moduleName.append("::").append(abilityInfo_->name); + HILOG_INFO("tag dsa %{public}s module:%{public}s, srcPath:%{public}s.", __func__, moduleName.c_str(), srcPath.c_str()); + HandleScope handleScope(jsRuntime_); + + jsObj_ = jsRuntime_.LoadModule(moduleName, srcPath); + if (jsObj_ == nullptr) { + HILOG_ERROR("tag dsa Failed to get jsObj_"); + return; + } + HILOG_INFO("tag dsa JsFileExtAbility::Init ConvertNativeValueTo."); + NativeObject* obj = ConvertNativeValueTo(jsObj_->Get()); + if (obj == nullptr) { + HILOG_ERROR("tag dsa Failed to get JsFileExtAbility object"); + return; + } + HILOG_INFO("tag dsa JsFileExtAbility::Init end."); +} + +void JsFileExtAbility::OnStart(const AAFwk::Want &want) +{ + HILOG_INFO("tag dsa %{public}s begin.", __func__); + Extension::OnStart(want); + HandleScope handleScope(jsRuntime_); + napi_env env = reinterpret_cast(&jsRuntime_.GetNativeEngine()); + napi_value napiWant = OHOS::AppExecFwk::WrapWant(env, want); + NativeValue* nativeWant = reinterpret_cast(napiWant); + NativeValue* argv[] = {nativeWant}; + CallObjectMethod("onCreate", argv, ARGC_ONE); + HILOG_INFO("tag dsa %{public}s end.", __func__); +} + +sptr JsFileExtAbility::OnConnect(const AAFwk::Want &want) +{ + BYTRACE_NAME(BYTRACE_TAG_DISTRIBUTEDDATA, __PRETTY_FUNCTION__); + HILOG_INFO("tag dsa %{public}s begin.", __func__); + Extension::OnConnect(want); + sptr remoteObject = new (std::nothrow) FileExtStubImpl( + std::static_pointer_cast(shared_from_this()), + reinterpret_cast(&jsRuntime_.GetNativeEngine())); + if (remoteObject == nullptr) { + HILOG_ERROR("tag dsa %{public}s No memory allocated for FileExtStubImpl", __func__); + return nullptr; + } + HILOG_INFO("tag dsa %{public}s end. ", __func__); + return remoteObject->AsObject(); +} + +NativeValue* JsFileExtAbility::CallObjectMethod(const char* name, NativeValue* const* argv, size_t argc) +{ + HILOG_INFO("tag dsa JsFileExtAbility::CallObjectMethod(%{public}s), begin", name); + + if (!jsObj_) { + HILOG_WARN("Not found FileExtAbility.js"); + return nullptr; + } + + HandleScope handleScope(jsRuntime_); + auto& nativeEngine = jsRuntime_.GetNativeEngine(); + + NativeValue* value = jsObj_->Get(); + NativeObject* obj = ConvertNativeValueTo(value); + if (obj == nullptr) { + HILOG_ERROR("tag dsa Failed to get FileExtAbility object"); + return nullptr; + } + + NativeValue* method = obj->GetProperty(name); + if (method == nullptr) { + HILOG_ERROR("tag dsa Failed to get '%{public}s' from FileExtAbility object", name); + return nullptr; + } + HILOG_INFO("tag dsa JsFileExtAbility::CallFunction(%{public}s), success", name); + return handleScope.Escape(nativeEngine.CallFunction(value, method, argv, argc)); +} + +void JsFileExtAbility::GetSrcPath(std::string &srcPath) +{ + HILOG_INFO("tag dsa %{public}s begin.", __func__); + if (!Extension::abilityInfo_->isStageBasedModel) { + /* temporary compatibility api8 + config.json */ + srcPath.append(Extension::abilityInfo_->package); + srcPath.append("/assets/js/"); + if (!Extension::abilityInfo_->srcPath.empty()) { + srcPath.append(Extension::abilityInfo_->srcPath); + } + srcPath.append("/").append(Extension::abilityInfo_->name).append(".abc"); + HILOG_INFO("tag dsa %{public}s end1, srcPath:%{public}s", __func__, srcPath.c_str()); + return; + } + + if (!Extension::abilityInfo_->srcEntrance.empty()) { + srcPath.append(Extension::abilityInfo_->moduleName + "/"); + srcPath.append(Extension::abilityInfo_->srcEntrance); + srcPath.erase(srcPath.rfind('.')); + srcPath.append(".abc"); + } + HILOG_INFO("tag dsa %{public}s end2, srcPath:%{public}s", __func__, srcPath.c_str()); +} + +int JsFileExtAbility::OpenFile(const Uri &uri, const std::string &mode) +{ + HILOG_INFO("tag dsa %{public}s begin.", __func__); + HandleScope handleScope(jsRuntime_); + napi_env env = reinterpret_cast(&jsRuntime_.GetNativeEngine()); + + napi_value napiUri = nullptr; + napi_create_string_utf8(env, uri.ToString().c_str(), NAPI_AUTO_LENGTH, &napiUri); + napi_value napiMode = nullptr; + napi_create_string_utf8(env, mode.c_str(), NAPI_AUTO_LENGTH, &napiMode); + + NativeValue* nativeUri = reinterpret_cast(napiUri); + NativeValue* nativeMode = reinterpret_cast(napiMode); + NativeValue* argv[] = {nativeUri, nativeMode}; + NativeValue* nativeResult = CallObjectMethod("openFile", argv, ARGC_TWO); + int ret = -1; + if (nativeResult == nullptr) { + HILOG_ERROR("tag dsa %{public}s call openFile with return null.", __func__); + return ret; + } + ret = OHOS::AppExecFwk::UnwrapInt32FromJS(env, reinterpret_cast(nativeResult)); + HILOG_INFO("tag dsa %{public}s end. return fd:%{public}d", __func__, ret); + return ret; +} + +int JsFileExtAbility::CloseFile(int fd, const std::string &uri) +{ + HILOG_INFO("tag dsa %{public}s begin.", __func__); + HandleScope handleScope(jsRuntime_); + napi_env env = reinterpret_cast(&jsRuntime_.GetNativeEngine()); + + napi_value napiFd = nullptr; + napi_create_int32(env, fd, &napiFd); + napi_value napiUri = nullptr; + napi_create_string_utf8(env, uri.c_str(), NAPI_AUTO_LENGTH, &napiUri); + + NativeValue* nativeFd = reinterpret_cast(napiFd); + NativeValue* nativeUri = reinterpret_cast(napiUri); + NativeValue* argv[] = {nativeFd, nativeUri}; + NativeValue* nativeResult = CallObjectMethod("closeFile", argv, ARGC_TWO); + int ret = -1; + if (nativeResult == nullptr) { + HILOG_ERROR("tag dsa %{public}s call closeFile with return null.", __func__); + return ret; + } + ret = OHOS::AppExecFwk::UnwrapInt32FromJS(env, reinterpret_cast(nativeResult)); + HILOG_INFO("tag dsa %{public}s end. return fd:%{public}d", __func__, ret); + return ret; +} + +int JsFileExtAbility::CreateFile(const Uri &parentUri, const std::string &displayName, Uri &newFileUri) +{ + HILOG_INFO("tag dsa %{public}s begin.", __func__); + HandleScope handleScope(jsRuntime_); + napi_env env = reinterpret_cast(&jsRuntime_.GetNativeEngine()); + + napi_value napiParentUri = nullptr; + napi_create_string_utf8(env, parentUri.ToString().c_str(), NAPI_AUTO_LENGTH, &napiParentUri); + napi_value napiDisplayName = nullptr; + napi_create_string_utf8(env, displayName.c_str(), NAPI_AUTO_LENGTH, &napiDisplayName); + + NativeValue* nativeParentUri = reinterpret_cast(napiParentUri); + NativeValue* nativeDisplayName = reinterpret_cast(napiDisplayName); + NativeValue* argv[] = {nativeParentUri, nativeDisplayName}; + NativeValue* nativeResult = CallObjectMethod("createFile", argv, ARGC_TWO); + int ret = -1; + if (nativeResult == nullptr) { + HILOG_ERROR("tag dsa %{public}s call createFile with return null.", __func__); + return ret; + } + std::string uriStr = OHOS::AppExecFwk::UnwrapStringFromJS(env, reinterpret_cast(nativeResult)); + if (uriStr.empty()) { + HILOG_ERROR("tag dsa %{public}s call Mkdir with return empty.", __func__); + return ret; + } else { + ret = NO_ERROR; + } + newFileUri = Uri(uriStr); + HILOG_INFO("tag dsa %{public}s end. return fd:%{public}d, newFileUri = %{public}s", __func__, ret, uriStr.c_str()); + return ret; +} + +int JsFileExtAbility::Mkdir(const Uri &parentUri, const std::string &displayName, Uri &newFileUri) +{ + HILOG_INFO("tag dsa %{public}s begin.", __func__); + HandleScope handleScope(jsRuntime_); + napi_env env = reinterpret_cast(&jsRuntime_.GetNativeEngine()); + + napi_value napiParentUri = nullptr; + napi_create_string_utf8(env, parentUri.ToString().c_str(), NAPI_AUTO_LENGTH, &napiParentUri); + napi_value napiDisplayName = nullptr; + napi_create_string_utf8(env, displayName.c_str(), NAPI_AUTO_LENGTH, &napiDisplayName); + + NativeValue* nativeParentUri = reinterpret_cast(napiParentUri); + NativeValue* nativeDisplayName = reinterpret_cast(napiDisplayName); + NativeValue* argv[] = {nativeParentUri, nativeDisplayName}; + NativeValue* nativeResult = CallObjectMethod("mkdir", argv, ARGC_TWO); + int ret = -1; + if (nativeResult == nullptr) { + HILOG_ERROR("tag dsa %{public}s call Mkdir with return null.", __func__); + return ret; + } + std::string uriStr = OHOS::AppExecFwk::UnwrapStringFromJS(env, reinterpret_cast(nativeResult)); + if (uriStr.empty()) { + HILOG_ERROR("tag dsa %{public}s call Mkdir with return empty.", __func__); + return ret; + } else { + ret = NO_ERROR; + } + newFileUri = Uri(uriStr); + HILOG_INFO("tag dsa %{public}s end. return fd:%{public}d, newFileUri = %{public}s", __func__, ret, uriStr.c_str()); + return ret; +} + +int JsFileExtAbility::Delete(const Uri &sourceFileUri) +{ + HILOG_INFO("tag dsa %{public}s begin.", __func__); + HandleScope handleScope(jsRuntime_); + napi_env env = reinterpret_cast(&jsRuntime_.GetNativeEngine()); + + napi_value napiUri = nullptr; + napi_create_string_utf8(env, sourceFileUri.ToString().c_str(), NAPI_AUTO_LENGTH, &napiUri); + + NativeValue* nativeUri = reinterpret_cast(napiUri); + NativeValue* argv[] = {nativeUri}; + NativeValue* nativeResult = CallObjectMethod("delete", argv, ARGC_ONE); + int ret = -1; + if (nativeResult == nullptr) { + HILOG_ERROR("tag dsa %{public}s call delete with return null.", __func__); + return ret; + } + ret = OHOS::AppExecFwk::UnwrapInt32FromJS(env, reinterpret_cast(nativeResult)); + HILOG_INFO("tag dsa %{public}s end. return fd:%{public}d", __func__, ret); + return ret; +} + +int JsFileExtAbility::Move(const Uri &sourceFileUri, const Uri &targetParentUri, Uri &newFileUri) +{ + HILOG_INFO("tag dsa %{public}s begin.", __func__); + HandleScope handleScope(jsRuntime_); + napi_env env = reinterpret_cast(&jsRuntime_.GetNativeEngine()); + + napi_value napiSourceFileUri = nullptr; + napi_create_string_utf8(env, sourceFileUri.ToString().c_str(), NAPI_AUTO_LENGTH, &napiSourceFileUri); + napi_value napiTargetParentUri = nullptr; + napi_create_string_utf8(env, targetParentUri.ToString().c_str(), NAPI_AUTO_LENGTH, &napiTargetParentUri); + + NativeValue* nativeSourceFileUri = reinterpret_cast(napiSourceFileUri); + NativeValue* nativeTargetParentUri = reinterpret_cast(napiTargetParentUri); + NativeValue* argv[] = {nativeSourceFileUri, nativeTargetParentUri}; + NativeValue* nativeResult = CallObjectMethod("move", argv, ARGC_TWO); + int ret = -1; + if (nativeResult == nullptr) { + HILOG_ERROR("tag dsa %{public}s call move with return null.", __func__); + return ret; + } + std::string uriStr = OHOS::AppExecFwk::UnwrapStringFromJS(env, reinterpret_cast(nativeResult)); + if (uriStr.empty()) { + HILOG_ERROR("tag dsa %{public}s call move with return empty.", __func__); + return ret; + } else { + ret = NO_ERROR; + } + newFileUri = Uri(uriStr); + HILOG_INFO("tag dsa %{public}s end. return fd:%{public}d, newFileUri = %{public}s", __func__, ret, uriStr.c_str()); + return ret; +} + +int JsFileExtAbility::Rename(const Uri &sourceFileUri, const std::string &displayName, Uri &newFileUri) +{ + HILOG_INFO("tag dsa %{public}s begin.", __func__); + HandleScope handleScope(jsRuntime_); + napi_env env = reinterpret_cast(&jsRuntime_.GetNativeEngine()); + + napi_value napiSourceFileUri = nullptr; + napi_create_string_utf8(env, sourceFileUri.ToString().c_str(), NAPI_AUTO_LENGTH, &napiSourceFileUri); + napi_value napiDisplayName = nullptr; + napi_create_string_utf8(env, displayName.c_str(), NAPI_AUTO_LENGTH, &napiDisplayName); + + NativeValue* nativeSourceFileUri = reinterpret_cast(napiSourceFileUri); + NativeValue* nativeDisplayName = reinterpret_cast(napiDisplayName); + NativeValue* argv[] = {nativeSourceFileUri, nativeDisplayName}; + NativeValue* nativeResult = CallObjectMethod("rename", argv, ARGC_TWO); + int ret = -1; + if (nativeResult == nullptr) { + HILOG_ERROR("tag dsa %{public}s call rename with return null.", __func__); + return ret; + } + std::string uriStr = OHOS::AppExecFwk::UnwrapStringFromJS(env, reinterpret_cast(nativeResult)); + if (uriStr.empty()) { + HILOG_ERROR("tag dsa %{public}s call rename with return empty.", __func__); + return ret; + } else { + ret = NO_ERROR; + } + newFileUri = Uri(uriStr); + HILOG_INFO("tag dsa %{public}s end. return fd:%{public}d, newFileUri = %{public}s", __func__, ret, uriStr.c_str()); + return ret; +} +} // namespace AbilityRuntime +} // namespace OHOS \ No newline at end of file diff --git a/frameworks/innerkits/file_extension_hap/AppScope/app.json b/frameworks/innerkits/file_extension_hap/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..f86c4521221f0205e4f70ebd8021a1b16a9dcafb --- /dev/null +++ b/frameworks/innerkits/file_extension_hap/AppScope/app.json @@ -0,0 +1,13 @@ +{ + "app": { + "bundleName": "com.ohos.FileExtension.FileExtensionData", + "vendor": "FileExtension", + "versionCode": 1000000, + "versionName": "1.0.0", + "minAPIVersion": 9, + "targetAPIVersion": 9, + "icon": "$media:app_icon", + "label": "$string:app_name", + "distributedNotificationEnabled": true + } +} diff --git a/frameworks/innerkits/file_extension_hap/AppScope/resources/base/element/string.json b/frameworks/innerkits/file_extension_hap/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..7863972bd0ae5e0b33860b0912141dec95c82652 --- /dev/null +++ b/frameworks/innerkits/file_extension_hap/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "FileExtension" + } + ] +} diff --git a/frameworks/innerkits/file_extension_hap/AppScope/resources/base/media/app_icon.png b/frameworks/innerkits/file_extension_hap/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/frameworks/innerkits/file_extension_hap/AppScope/resources/base/media/app_icon.png differ diff --git a/frameworks/innerkits/file_extension_hap/build-profile.json5 b/frameworks/innerkits/file_extension_hap/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..fc53829be062f3a883f815802e6039c733ebb352 --- /dev/null +++ b/frameworks/innerkits/file_extension_hap/build-profile.json5 @@ -0,0 +1,26 @@ +{ + "app": { + "compileSdkVersion": 9, + "compatibleSdkVersion": 9, + "products": [ + { + "name": "default", + "signingConfig": "default", + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/frameworks/innerkits/file_extension_hap/entry/build-profile.json5 b/frameworks/innerkits/file_extension_hap/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..7dc37bb919dada5132609c409200db266559004f --- /dev/null +++ b/frameworks/innerkits/file_extension_hap/entry/build-profile.json5 @@ -0,0 +1,13 @@ +{ + "apiType": 'stageMode', + "buildOption": { + }, + "targets": [ + { + "name": "default", + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/frameworks/innerkits/file_extension_hap/entry/hvigorfile.js b/frameworks/innerkits/file_extension_hap/entry/hvigorfile.js new file mode 100644 index 0000000000000000000000000000000000000000..d7720ee6a7aad5c617d1fd2f6fc8c87067bfa32c --- /dev/null +++ b/frameworks/innerkits/file_extension_hap/entry/hvigorfile.js @@ -0,0 +1,2 @@ +// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. +module.exports = require('@ohos/hvigor-ohos-plugin').hapTasks diff --git a/frameworks/innerkits/file_extension_hap/entry/package-lock.json b/frameworks/innerkits/file_extension_hap/entry/package-lock.json new file mode 100644 index 0000000000000000000000000000000000000000..15bc7145be1490029883067847743ea7134cf545 --- /dev/null +++ b/frameworks/innerkits/file_extension_hap/entry/package-lock.json @@ -0,0 +1,5 @@ +{ + "name": "entry", + "version": "1.0.0", + "lockfileVersion": 1 +} diff --git a/frameworks/innerkits/file_extension_hap/entry/package.json b/frameworks/innerkits/file_extension_hap/entry/package.json new file mode 100644 index 0000000000000000000000000000000000000000..4693ae0c35e3dee3d45bc1c52885c088c11d476c --- /dev/null +++ b/frameworks/innerkits/file_extension_hap/entry/package.json @@ -0,0 +1,14 @@ +{ + "license":"ISC", + "devDependencies":{}, + "name":"entry", + "ohos":{ + "org":"huawei", + "directoryLevel":"module", + "buildTool":"hvigor" + }, + "description":"FileExtension", + "repository":{}, + "version":"1.0.0", + "dependencies":{} +} \ No newline at end of file diff --git a/frameworks/innerkits/file_extension_hap/entry/src/main/ets/Application/AbilityStage.ts b/frameworks/innerkits/file_extension_hap/entry/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..21eabd6ae36ea484ad7775078b8faed89aef4c8b --- /dev/null +++ b/frameworks/innerkits/file_extension_hap/entry/src/main/ets/Application/AbilityStage.ts @@ -0,0 +1,21 @@ +/* + * 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 AbilityStage from "@ohos.application.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("MyAbilityStage onCreate") + } +} \ No newline at end of file diff --git a/frameworks/innerkits/file_extension_hap/entry/src/main/ets/FileExtensionAbility/FileExtensionAbility.ts b/frameworks/innerkits/file_extension_hap/entry/src/main/ets/FileExtensionAbility/FileExtensionAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..ef8d617a6609d393473e797a38c032db857b37cd --- /dev/null +++ b/frameworks/innerkits/file_extension_hap/entry/src/main/ets/FileExtensionAbility/FileExtensionAbility.ts @@ -0,0 +1,57 @@ +/* + * 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 Extension from '@ohos.application.FileExtensionAbility' + +export default class FileExtAbility extends Extension { + onCreate(want) { + console.log('js server tag dsa FileExtAbility onCreate, want:' + want.abilityName); + console.log('js server tag dsa FileExtAbility this.context:' + this.context); + } + + openFile(uri, mode) { + console.log('js server tag dsa openFile, uri:' + uri + ',mode:' + mode); + return 2; + } + + closeFile(fd, uri) { + console.log('js server tag dsa delete, fd:' + fd + ",uri: " + uri); + return 0; + } + + createFile(parentUri, displayName) { + console.log('js server tag dsa CreateFile, parentUri:' + parentUri + ',displayName:' + displayName ); + return "filetest://fileext.share/temp/test/CreateFile001.txt"; + } + + mkdir(parentUri, displayName) { + console.log('js server tag dsa mkdir, parentUri:' + parentUri + ',displayName:' + displayName); + return "filetest://fileext.share/temp/test/Mkdir001"; + } + + delete(sourceFileUri) { + console.log('js server tag dsa delete, sourceFileUri:' + sourceFileUri); + return 0; + } + + move(sourceFileUri, targetParentUri) { + console.log('js server tag dsa move, sourceFileUri:' + sourceFileUri + ',targetParentUri:' + targetParentUri); + return "filetest://fileext.share/temp/test/move001.xl"; + } + + rename(sourceFileUri, displayName) { + console.log('js server tag dsa rename, sourceFileUri:' + sourceFileUri + ',displayName:' + displayName); + return "filetest://fileext.share/temp/test/rename001.ttt"; + } +}; \ No newline at end of file diff --git a/frameworks/innerkits/file_extension_hap/entry/src/main/ets/MainAbility/MainAbility.ts b/frameworks/innerkits/file_extension_hap/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..2f1022041fa5df0f291a0faf5243ecb592785d08 --- /dev/null +++ b/frameworks/innerkits/file_extension_hap/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,48 @@ +/* + * 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 Ability from '@ohos.application.Ability' + +export default class MainAbility extends Ability { + onCreate(want, launchParam) { + console.log("[tag dsa] MainAbility onCreate") + globalThis.abilityWant = want; + } + + onDestroy() { + console.log("[tag dsa] MainAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("[tag dsa] MainAbility onWindowStageCreate") + globalThis.context = this.context; + windowStage.setUIContent(this.context, "pages/index", null) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("[tag dsa] MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("[tag dsa] MainAbility onForeground") + } + + onBackground() { + // Ability has back to background + console.log("[tag dsa] MainAbility onBackground") + } +}; diff --git a/frameworks/innerkits/file_extension_hap/entry/src/main/ets/pages/index.ets b/frameworks/innerkits/file_extension_hap/entry/src/main/ets/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..a3361dc31925163a44aa2ed457be90de88aae2d5 --- /dev/null +++ b/frameworks/innerkits/file_extension_hap/entry/src/main/ets/pages/index.ets @@ -0,0 +1,31 @@ +/* + * 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. + */ +@Entry +@Component +struct Index { + @State message: string = 'Hello World' + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/frameworks/innerkits/file_extension_hap/entry/src/main/module.json b/frameworks/innerkits/file_extension_hap/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..9a88ff84a9614f50826c35f0fe0f751cb0c5a3e3 --- /dev/null +++ b/frameworks/innerkits/file_extension_hap/entry/src/main/module.json @@ -0,0 +1,37 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "srcEntrance": "./ets/Application/AbilityStage.ts", + "description": "$string:entry_desc", + "mainElement": "MainAbility", + "deviceTypes": [ + "phone", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "uiSyntax": "ets", + "abilities": [ + { + "name": "MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:MainAbility_desc", + "icon": "$media:icon", + "label": "$string:MainAbility_label", + "visible": false + } + ], + "extensionAbilities": [ + { + "srcEntrance": "./ets/FileExtensionAbility/FileExtensionAbility.ts", + "name": "FileExtensionAbility", + "icon": "$media:icon", + "description": "$string:description_serviceability", + "type": "file", + "visible": true + } + ] + } +} diff --git a/frameworks/innerkits/file_extension_hap/entry/src/main/resources/base/element/string.json b/frameworks/innerkits/file_extension_hap/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..db5e76342178fdffa784213058059bfa2c07590a --- /dev/null +++ b/frameworks/innerkits/file_extension_hap/entry/src/main/resources/base/element/string.json @@ -0,0 +1,20 @@ +{ + "string": [ + { + "name": "entry_desc", + "value": "description" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + }, + { + "name": "description_serviceability", + "value": "description_serviceability" + } + ] +} \ No newline at end of file diff --git a/frameworks/innerkits/file_extension_hap/entry/src/main/resources/base/media/icon.png b/frameworks/innerkits/file_extension_hap/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/frameworks/innerkits/file_extension_hap/entry/src/main/resources/base/media/icon.png differ diff --git a/frameworks/innerkits/file_extension_hap/entry/src/main/resources/base/profile/main_pages.json b/frameworks/innerkits/file_extension_hap/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..feec276e105eeb8d621c20aaf838f318b0a94150 --- /dev/null +++ b/frameworks/innerkits/file_extension_hap/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/index" + ] +} diff --git a/frameworks/innerkits/file_extension_hap/hvigorfile.js b/frameworks/innerkits/file_extension_hap/hvigorfile.js new file mode 100644 index 0000000000000000000000000000000000000000..5f2735e3deeaf655828407544bbed9365c258278 --- /dev/null +++ b/frameworks/innerkits/file_extension_hap/hvigorfile.js @@ -0,0 +1,2 @@ +// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. +module.exports = require('@ohos/hvigor-ohos-plugin').appTasks \ No newline at end of file diff --git a/frameworks/innerkits/file_extension_hap/package-lock.json b/frameworks/innerkits/file_extension_hap/package-lock.json new file mode 100644 index 0000000000000000000000000000000000000000..f88881ba3717724fbad26822b5615718d37a1f03 --- /dev/null +++ b/frameworks/innerkits/file_extension_hap/package-lock.json @@ -0,0 +1,1652 @@ +{ + "name": "FileExtension", + "version": "1.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@ohos/hvigor": { + "version": "1.0.6", + "resolved": "https://repo.harmonyos.com/npm/@ohos/hvigor/-/@ohos/hvigor-1.0.6.tgz", + "integrity": "sha512-jjp7vpvUOMW1Nf7TdyhOtonwWHoSyBJLUiZTQqIx/GJV4UJyIqsiURUOqFwncQ4L7PDdeHuWly4uEelknYeWhg==", + "requires": { + "@ohos/hvigor-base": "1.0.6", + "interpret": "1.4.0", + "liftoff": "4.0.0", + "mute-stdout": "1.0.0", + "pretty-hrtime": "1.0.0", + "v8flags": "3.2.0", + "yargs": "7.1.0" + } + }, + "@ohos/hvigor-base": { + "version": "1.0.6", + "resolved": "https://repo.harmonyos.com/npm/@ohos/hvigor-base/-/@ohos/hvigor-base-1.0.6.tgz", + "integrity": "sha512-cRDnWICTxmpNiFb9clIioqP5Oik1seLCICztXVhZqultrHuxwTheCRUZrHwlpyWdkSB2Al+FFBqmSwzIgZX4IQ==", + "requires": { + "json5": "2.2.0", + "log4js": "6.4.1", + "undertaker": "1.2.1" + } + }, + "@ohos/hvigor-ohos-plugin": { + "version": "1.0.6", + "resolved": "https://repo.harmonyos.com/npm/@ohos/hvigor-ohos-plugin/-/@ohos/hvigor-ohos-plugin-1.0.6.tgz", + "integrity": "sha512-MAAi8uJxMzODUoSSNfBr+fU4HQ20dfQtkje9I+X4asc7qY2kAplW/q9f5XS8IOvv8zhC8OcSgsAXOAJuLMstOQ==", + "requires": { + "@ohos/hvigor-base": "1.0.6", + "@ohos/sdkmanager-common": "1.1.3", + "ajv": "8.10.0", + "archiver": "5.3.0", + "execa": "5.1.1", + "fs-extra": "10.0.0", + "glob": "7.2.0", + "iconv-lite": "0.6.3", + "json5": "2.2.0", + "lodash": "4.17.21", + "pretty-hrtime": "1.0.3", + "resolve-package-path": "4.0.3" + }, + "dependencies": { + "fs-extra": { + "version": "10.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/fs-extra/-/fs-extra-10.0.0.tgz", + "integrity": "sha512-C5owb14u9eJwizKGdchcDUQeFtlSHHthBk8pbX9Vc1PFZrLombudjDnNns88aYslCyF6IY5SUw3Roz6xShcEIQ==", + "requires": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + } + }, + "pretty-hrtime": { + "version": "1.0.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/pretty-hrtime/-/pretty-hrtime-1.0.3.tgz", + "integrity": "sha1-t+PqQkNaTJsnWdmeDyAesZWALuE=" + } + } + }, + "@ohos/sdkmanager-common": { + "version": "1.1.3", + "resolved": "https://repo.harmonyos.com/npm/@ohos/sdkmanager-common/-/@ohos/sdkmanager-common-1.1.3.tgz", + "integrity": "sha512-d2uhVauDDJZIUvyyaWWoavG4N/jLyfF5IH5kEXKV6R8HNf3606H1zDQzA+UZtOfwwJFXhD9djRjnVFNB8xc7aw==" + }, + "ajv": { + "version": "8.10.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/ajv/-/ajv-8.10.0.tgz", + "integrity": "sha512-bzqAEZOjkrUMl2afH8dknrq5KEk2SrwdBROR+vH1EKVQTqaUbJVPdc/gEdggTMM0Se+s+Ja4ju4TlNcStKl2Hw==", + "requires": { + "fast-deep-equal": "^3.1.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2", + "uri-js": "^4.2.2" + } + }, + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=" + }, + "archiver": { + "version": "5.3.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/archiver/-/archiver-5.3.0.tgz", + "integrity": "sha512-iUw+oDwK0fgNpvveEsdQ0Ase6IIKztBJU2U0E9MzszMfmVVUyv1QJhS2ITW9ZCqx8dktAxVAjWWkKehuZE8OPg==", + "requires": { + "archiver-utils": "^2.1.0", + "async": "^3.2.0", + "buffer-crc32": "^0.2.1", + "readable-stream": "^3.6.0", + "readdir-glob": "^1.0.0", + "tar-stream": "^2.2.0", + "zip-stream": "^4.1.0" + } + }, + "archiver-utils": { + "version": "2.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/archiver-utils/-/archiver-utils-2.1.0.tgz", + "integrity": "sha512-bEL/yUb/fNNiNTuUz979Z0Yg5L+LzLxGJz8x79lYmR54fmTIb6ob/hNQgkQnIUDWIFjZVQwl9Xs356I6BAMHfw==", + "requires": { + "glob": "^7.1.4", + "graceful-fs": "^4.2.0", + "lazystream": "^1.0.0", + "lodash.defaults": "^4.2.0", + "lodash.difference": "^4.5.0", + "lodash.flatten": "^4.4.0", + "lodash.isplainobject": "^4.0.6", + "lodash.union": "^4.6.0", + "normalize-path": "^3.0.0", + "readable-stream": "^2.0.0" + }, + "dependencies": { + "readable-stream": { + "version": "2.3.7", + "resolved": "https://repo.huaweicloud.com/repository/npm/readable-stream/-/readable-stream-2.3.7.tgz", + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + } + } + }, + "arr-filter": { + "version": "1.1.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/arr-filter/-/arr-filter-1.1.2.tgz", + "integrity": "sha1-Q/3d0JHo7xGqTEXZzcGOLf8XEe4=", + "requires": { + "make-iterator": "^1.0.0" + } + }, + "arr-flatten": { + "version": "1.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/arr-flatten/-/arr-flatten-1.1.0.tgz", + "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==" + }, + "arr-map": { + "version": "2.0.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/arr-map/-/arr-map-2.0.2.tgz", + "integrity": "sha1-Onc0X/wc814qkYJWAfnljy4kysQ=", + "requires": { + "make-iterator": "^1.0.0" + } + }, + "array-each": { + "version": "1.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/array-each/-/array-each-1.0.1.tgz", + "integrity": "sha1-p5SvDAWrF1KEbudTofIRoFugxE8=" + }, + "array-initial": { + "version": "1.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/array-initial/-/array-initial-1.1.0.tgz", + "integrity": "sha1-L6dLJnOTccOUe9enrcc74zSz15U=", + "requires": { + "array-slice": "^1.0.0", + "is-number": "^4.0.0" + } + }, + "array-last": { + "version": "1.3.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/array-last/-/array-last-1.3.0.tgz", + "integrity": "sha512-eOCut5rXlI6aCOS7Z7kCplKRKyiFQ6dHFBem4PwlwKeNFk2/XxTrhRh5T9PyaEWGy/NHTZWbY+nsZlNFJu9rYg==", + "requires": { + "is-number": "^4.0.0" + } + }, + "array-slice": { + "version": "1.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/array-slice/-/array-slice-1.1.0.tgz", + "integrity": "sha512-B1qMD3RBP7O8o0H2KbrXDyB0IccejMF15+87Lvlor12ONPRHP6gTjXMNkt/d3ZuOGbAe66hFmaCfECI24Ufp6w==" + }, + "async": { + "version": "3.2.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/async/-/async-3.2.3.tgz", + "integrity": "sha512-spZRyzKL5l5BZQrr/6m/SqFdBN0q3OCI0f9rjfBzCMBIP4p75P620rR3gTmaksNOhmzgdxcaxdNfMy6anrbM0g==" + }, + "async-done": { + "version": "1.3.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/async-done/-/async-done-1.3.2.tgz", + "integrity": "sha512-uYkTP8dw2og1tu1nmza1n1CMW0qb8gWWlwqMmLb7MhBVs4BXrFziT6HXUd+/RlRA/i4H9AkofYloUbs1fwMqlw==", + "requires": { + "end-of-stream": "^1.1.0", + "once": "^1.3.2", + "process-nextick-args": "^2.0.0", + "stream-exhaust": "^1.0.1" + } + }, + "async-settle": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/async-settle/-/async-settle-1.0.0.tgz", + "integrity": "sha1-HQqRS7Aldb7IqPOnTlCA9yssDGs=", + "requires": { + "async-done": "^1.2.2" + } + }, + "bach": { + "version": "1.2.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/bach/-/bach-1.2.0.tgz", + "integrity": "sha1-Szzpa/JxNPeaG0FKUcFONMO9mIA=", + "requires": { + "arr-filter": "^1.1.1", + "arr-flatten": "^1.0.1", + "arr-map": "^2.0.0", + "array-each": "^1.0.0", + "array-initial": "^1.0.0", + "array-last": "^1.1.1", + "async-done": "^1.2.2", + "async-settle": "^1.0.0", + "now-and-later": "^2.0.0" + } + }, + "balanced-match": { + "version": "1.0.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" + }, + "base64-js": { + "version": "1.5.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==" + }, + "bl": { + "version": "4.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/bl/-/bl-4.1.0.tgz", + "integrity": "sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==", + "requires": { + "buffer": "^5.5.0", + "inherits": "^2.0.4", + "readable-stream": "^3.4.0" + } + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://repo.huaweicloud.com/repository/npm/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "braces": { + "version": "3.0.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "requires": { + "fill-range": "^7.0.1" + } + }, + "buffer": { + "version": "5.7.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/buffer/-/buffer-5.7.1.tgz", + "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", + "requires": { + "base64-js": "^1.3.1", + "ieee754": "^1.1.13" + } + }, + "buffer-crc32": { + "version": "0.2.13", + "resolved": "https://repo.huaweicloud.com/repository/npm/buffer-crc32/-/buffer-crc32-0.2.13.tgz", + "integrity": "sha1-DTM+PwDqxQqhRUq9MO+MKl2ackI=" + }, + "call-bind": { + "version": "1.0.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/call-bind/-/call-bind-1.0.2.tgz", + "integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==", + "requires": { + "function-bind": "^1.1.1", + "get-intrinsic": "^1.0.2" + } + }, + "camelcase": { + "version": "3.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/camelcase/-/camelcase-3.0.0.tgz", + "integrity": "sha1-MvxLn82vhF/N9+c7uXysImHwqwo=" + }, + "cliui": { + "version": "3.2.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/cliui/-/cliui-3.2.0.tgz", + "integrity": "sha1-EgYBU3qRbSmUD5NNo7SNWFo5IT0=", + "requires": { + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1", + "wrap-ansi": "^2.0.0" + } + }, + "code-point-at": { + "version": "1.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/code-point-at/-/code-point-at-1.1.0.tgz", + "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=" + }, + "collection-map": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/collection-map/-/collection-map-1.0.0.tgz", + "integrity": "sha1-rqDwb40mx4DCt1SUOFVEsiVa8Yw=", + "requires": { + "arr-map": "^2.0.2", + "for-own": "^1.0.0", + "make-iterator": "^1.0.0" + } + }, + "compress-commons": { + "version": "4.1.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/compress-commons/-/compress-commons-4.1.1.tgz", + "integrity": "sha512-QLdDLCKNV2dtoTorqgxngQCMA+gWXkM/Nwu7FpeBhk/RdkzimqC3jueb/FDmaZeXh+uby1jkBqE3xArsLBE5wQ==", + "requires": { + "buffer-crc32": "^0.2.13", + "crc32-stream": "^4.0.2", + "normalize-path": "^3.0.0", + "readable-stream": "^3.6.0" + } + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + }, + "core-util-is": { + "version": "1.0.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/core-util-is/-/core-util-is-1.0.3.tgz", + "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==" + }, + "crc-32": { + "version": "1.2.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/crc-32/-/crc-32-1.2.2.tgz", + "integrity": "sha512-ROmzCKrTnOwybPcJApAA6WBWij23HVfGVNKqqrZpuyZOHqK2CwHSvpGuyt/UNNvaIjEd8X5IFGp4Mh+Ie1IHJQ==" + }, + "crc32-stream": { + "version": "4.0.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/crc32-stream/-/crc32-stream-4.0.2.tgz", + "integrity": "sha512-DxFZ/Hk473b/muq1VJ///PMNLj0ZMnzye9thBpmjpJKCc5eMgB95aK8zCGrGfQ90cWo561Te6HK9D+j4KPdM6w==", + "requires": { + "crc-32": "^1.2.0", + "readable-stream": "^3.4.0" + } + }, + "cross-spawn": { + "version": "7.0.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "requires": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "dependencies": { + "which": { + "version": "2.0.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "requires": { + "isexe": "^2.0.0" + } + } + } + }, + "d": { + "version": "1.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/d/-/d-1.0.1.tgz", + "integrity": "sha512-m62ShEObQ39CfralilEQRjH6oAMtNCV1xJyEx5LpRYUVN+EviphDgUc/F3hnYbADmkiNs67Y+3ylmlG7Lnu+FA==", + "requires": { + "es5-ext": "^0.10.50", + "type": "^1.0.1" + } + }, + "date-format": { + "version": "4.0.7", + "resolved": "https://repo.huaweicloud.com/repository/npm/date-format/-/date-format-4.0.7.tgz", + "integrity": "sha512-k5xqlzDGIfv2N/DHR/BR8Kc4N9CRy9ReuDkmdxeX/jNfit94QXd36emWMm40ZOEDKNm/c91yV9EO3uGPkR7wWQ==" + }, + "debug": { + "version": "4.3.4", + "resolved": "https://repo.huaweicloud.com/repository/npm/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "requires": { + "ms": "2.1.2" + } + }, + "decamelize": { + "version": "1.2.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/decamelize/-/decamelize-1.2.0.tgz", + "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=" + }, + "default-resolution": { + "version": "2.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/default-resolution/-/default-resolution-2.0.0.tgz", + "integrity": "sha1-vLgrqnKtebQmp2cy8aga1t8m1oQ=" + }, + "define-properties": { + "version": "1.1.4", + "resolved": "https://repo.huaweicloud.com/repository/npm/define-properties/-/define-properties-1.1.4.tgz", + "integrity": "sha512-uckOqKcfaVvtBdsVkdPv3XjveQJsNQqmhXgRi8uhvWWuPYZCNlzT8qAyblUgNoXdHdjMTzAqeGjAoli8f+bzPA==", + "requires": { + "has-property-descriptors": "^1.0.0", + "object-keys": "^1.1.1" + } + }, + "detect-file": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/detect-file/-/detect-file-1.0.0.tgz", + "integrity": "sha1-8NZtA2cqglyxtzvbP+YjEMjlUrc=" + }, + "end-of-stream": { + "version": "1.4.4", + "resolved": "https://repo.huaweicloud.com/repository/npm/end-of-stream/-/end-of-stream-1.4.4.tgz", + "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", + "requires": { + "once": "^1.4.0" + } + }, + "error-ex": { + "version": "1.3.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/error-ex/-/error-ex-1.3.2.tgz", + "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==", + "requires": { + "is-arrayish": "^0.2.1" + } + }, + "es5-ext": { + "version": "0.10.61", + "resolved": "https://repo.huaweicloud.com/repository/npm/es5-ext/-/es5-ext-0.10.61.tgz", + "integrity": "sha512-yFhIqQAzu2Ca2I4SE2Au3rxVfmohU9Y7wqGR+s7+H7krk26NXhIRAZDgqd6xqjCEFUomDEA3/Bo/7fKmIkW1kA==", + "requires": { + "es6-iterator": "^2.0.3", + "es6-symbol": "^3.1.3", + "next-tick": "^1.1.0" + } + }, + "es6-iterator": { + "version": "2.0.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/es6-iterator/-/es6-iterator-2.0.3.tgz", + "integrity": "sha1-p96IkUGgWpSwhUQDstCg+/qY87c=", + "requires": { + "d": "1", + "es5-ext": "^0.10.35", + "es6-symbol": "^3.1.1" + } + }, + "es6-symbol": { + "version": "3.1.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/es6-symbol/-/es6-symbol-3.1.3.tgz", + "integrity": "sha512-NJ6Yn3FuDinBaBRWl/q5X/s4koRHBrgKAu+yGI6JCBeiu3qrcbJhwT2GeR/EXVfylRk8dpQVJoLEFhK+Mu31NA==", + "requires": { + "d": "^1.0.1", + "ext": "^1.1.2" + } + }, + "es6-weak-map": { + "version": "2.0.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/es6-weak-map/-/es6-weak-map-2.0.3.tgz", + "integrity": "sha512-p5um32HOTO1kP+w7PRnB+5lQ43Z6muuMuIMffvDN8ZB4GcnjLBV6zGStpbASIMk4DCAvEaamhe2zhyCb/QXXsA==", + "requires": { + "d": "1", + "es5-ext": "^0.10.46", + "es6-iterator": "^2.0.3", + "es6-symbol": "^3.1.1" + } + }, + "execa": { + "version": "5.1.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/execa/-/execa-5.1.1.tgz", + "integrity": "sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==", + "requires": { + "cross-spawn": "^7.0.3", + "get-stream": "^6.0.0", + "human-signals": "^2.1.0", + "is-stream": "^2.0.0", + "merge-stream": "^2.0.0", + "npm-run-path": "^4.0.1", + "onetime": "^5.1.2", + "signal-exit": "^3.0.3", + "strip-final-newline": "^2.0.0" + } + }, + "expand-tilde": { + "version": "2.0.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/expand-tilde/-/expand-tilde-2.0.2.tgz", + "integrity": "sha1-l+gBqgUt8CRU3kawK/YhZCzchQI=", + "requires": { + "homedir-polyfill": "^1.0.1" + } + }, + "ext": { + "version": "1.6.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/ext/-/ext-1.6.0.tgz", + "integrity": "sha512-sdBImtzkq2HpkdRLtlLWDa6w4DX22ijZLKx8BMPUuKe1c5lbN6xwQDQCxSfxBQnHZ13ls/FH0MQZx/q/gr6FQg==", + "requires": { + "type": "^2.5.0" + }, + "dependencies": { + "type": { + "version": "2.6.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/type/-/type-2.6.0.tgz", + "integrity": "sha512-eiDBDOmkih5pMbo9OqsqPRGMljLodLcwd5XD5JbtNB0o89xZAwynY9EdCDsJU7LtcVCClu9DvM7/0Ep1hYX3EQ==" + } + } + }, + "extend": { + "version": "3.0.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/extend/-/extend-3.0.2.tgz", + "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==" + }, + "fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==" + }, + "fill-range": { + "version": "7.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "requires": { + "to-regex-range": "^5.0.1" + } + }, + "find-up": { + "version": "1.1.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/find-up/-/find-up-1.1.2.tgz", + "integrity": "sha1-ay6YIrGizgpgq2TWEOzK1TyyTQ8=", + "requires": { + "path-exists": "^2.0.0", + "pinkie-promise": "^2.0.0" + } + }, + "findup-sync": { + "version": "5.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/findup-sync/-/findup-sync-5.0.0.tgz", + "integrity": "sha512-MzwXju70AuyflbgeOhzvQWAvvQdo1XL0A9bVvlXsYcFEBM87WR4OakL4OfZq+QRmr+duJubio+UtNQCPsVESzQ==", + "requires": { + "detect-file": "^1.0.0", + "is-glob": "^4.0.3", + "micromatch": "^4.0.4", + "resolve-dir": "^1.0.1" + } + }, + "fined": { + "version": "2.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/fined/-/fined-2.0.0.tgz", + "integrity": "sha512-OFRzsL6ZMHz5s0JrsEr+TpdGNCtrVtnuG3x1yzGNiQHT0yaDnXAj8V/lWcpJVrnoDpcwXcASxAZYbuXda2Y82A==", + "requires": { + "expand-tilde": "^2.0.2", + "is-plain-object": "^5.0.0", + "object.defaults": "^1.1.0", + "object.pick": "^1.3.0", + "parse-filepath": "^1.0.2" + } + }, + "flagged-respawn": { + "version": "2.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/flagged-respawn/-/flagged-respawn-2.0.0.tgz", + "integrity": "sha512-Gq/a6YCi8zexmGHMuJwahTGzXlAZAOsbCVKduWXC6TlLCjjFRlExMJc4GC2NYPYZ0r/brw9P7CpRgQmlPVeOoA==" + }, + "flatted": { + "version": "3.2.5", + "resolved": "https://repo.huaweicloud.com/repository/npm/flatted/-/flatted-3.2.5.tgz", + "integrity": "sha512-WIWGi2L3DyTUvUrwRKgGi9TwxQMUEqPOPQBVi71R96jZXJdFskXEmf54BoZaS1kknGODoIGASGEzBUYdyMCBJg==" + }, + "for-in": { + "version": "1.0.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/for-in/-/for-in-1.0.2.tgz", + "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=" + }, + "for-own": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/for-own/-/for-own-1.0.0.tgz", + "integrity": "sha1-xjMy9BXO3EsE2/5wz4NklMU8tEs=", + "requires": { + "for-in": "^1.0.1" + } + }, + "fs-constants": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/fs-constants/-/fs-constants-1.0.0.tgz", + "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==" + }, + "fs-extra": { + "version": "10.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/fs-extra/-/fs-extra-10.1.0.tgz", + "integrity": "sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==", + "requires": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" + }, + "function-bind": { + "version": "1.1.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/function-bind/-/function-bind-1.1.1.tgz", + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" + }, + "get-caller-file": { + "version": "1.0.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/get-caller-file/-/get-caller-file-1.0.3.tgz", + "integrity": "sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w==" + }, + "get-intrinsic": { + "version": "1.1.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/get-intrinsic/-/get-intrinsic-1.1.1.tgz", + "integrity": "sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q==", + "requires": { + "function-bind": "^1.1.1", + "has": "^1.0.3", + "has-symbols": "^1.0.1" + } + }, + "get-stream": { + "version": "6.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/get-stream/-/get-stream-6.0.1.tgz", + "integrity": "sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==" + }, + "glob": { + "version": "7.2.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/glob/-/glob-7.2.0.tgz", + "integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==", + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "global-modules": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/global-modules/-/global-modules-1.0.0.tgz", + "integrity": "sha512-sKzpEkf11GpOFuw0Zzjzmt4B4UZwjOcG757PPvrfhxcLFbq0wpsgpOqxpxtxFiCG4DtG93M6XRVbF2oGdev7bg==", + "requires": { + "global-prefix": "^1.0.1", + "is-windows": "^1.0.1", + "resolve-dir": "^1.0.0" + } + }, + "global-prefix": { + "version": "1.0.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/global-prefix/-/global-prefix-1.0.2.tgz", + "integrity": "sha1-2/dDxsFJklk8ZVVoy2btMsASLr4=", + "requires": { + "expand-tilde": "^2.0.2", + "homedir-polyfill": "^1.0.1", + "ini": "^1.3.4", + "is-windows": "^1.0.1", + "which": "^1.2.14" + } + }, + "graceful-fs": { + "version": "4.2.10", + "resolved": "https://repo.huaweicloud.com/repository/npm/graceful-fs/-/graceful-fs-4.2.10.tgz", + "integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==" + }, + "has": { + "version": "1.0.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/has/-/has-1.0.3.tgz", + "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", + "requires": { + "function-bind": "^1.1.1" + } + }, + "has-property-descriptors": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/has-property-descriptors/-/has-property-descriptors-1.0.0.tgz", + "integrity": "sha512-62DVLZGoiEBDHQyqG4w9xCuZ7eJEwNmJRWw2VY84Oedb7WFcA27fiEVe8oUQx9hAUJ4ekurquucTGwsyO1XGdQ==", + "requires": { + "get-intrinsic": "^1.1.1" + } + }, + "has-symbols": { + "version": "1.0.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/has-symbols/-/has-symbols-1.0.3.tgz", + "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==" + }, + "homedir-polyfill": { + "version": "1.0.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/homedir-polyfill/-/homedir-polyfill-1.0.3.tgz", + "integrity": "sha512-eSmmWE5bZTK2Nou4g0AI3zZ9rswp7GRKoKXS1BLUkvPviOqs4YTN1djQIqrXy9k5gEtdLPy86JjRwsNM9tnDcA==", + "requires": { + "parse-passwd": "^1.0.0" + } + }, + "hosted-git-info": { + "version": "2.8.9", + "resolved": "https://repo.huaweicloud.com/repository/npm/hosted-git-info/-/hosted-git-info-2.8.9.tgz", + "integrity": "sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==" + }, + "human-signals": { + "version": "2.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/human-signals/-/human-signals-2.1.0.tgz", + "integrity": "sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==" + }, + "hypium": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/hypium/-/hypium-1.0.0.tgz", + "integrity": "sha512-nl+RQVv2AU/5FvFRhsXyWO5wh+2huhdqRZ3bszBWZzW+kpNI3AT4ydvVRYIfaQbYwV4UlX/rSc7BtFjLAezhow==" + }, + "iconv-lite": { + "version": "0.6.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/iconv-lite/-/iconv-lite-0.6.3.tgz", + "integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==", + "requires": { + "safer-buffer": ">= 2.1.2 < 3.0.0" + } + }, + "ieee754": { + "version": "1.2.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==" + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://repo.huaweicloud.com/repository/npm/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://repo.huaweicloud.com/repository/npm/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "ini": { + "version": "1.3.8", + "resolved": "https://repo.huaweicloud.com/repository/npm/ini/-/ini-1.3.8.tgz", + "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==" + }, + "interpret": { + "version": "1.4.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/interpret/-/interpret-1.4.0.tgz", + "integrity": "sha512-agE4QfB2Lkp9uICn7BAqoscw4SZP9kTE2hxiFI3jBPmXJfdqiahTbUuKGsMoN2GtqL9AxhYioAcVvgsb1HvRbA==" + }, + "invert-kv": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/invert-kv/-/invert-kv-1.0.0.tgz", + "integrity": "sha1-EEqOSqym09jNFXqO+L+rLXo//bY=" + }, + "is-absolute": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/is-absolute/-/is-absolute-1.0.0.tgz", + "integrity": "sha512-dOWoqflvcydARa360Gvv18DZ/gRuHKi2NU/wU5X1ZFzdYfH29nkiNZsF3mp4OJ3H4yo9Mx8A/uAGNzpzPN3yBA==", + "requires": { + "is-relative": "^1.0.0", + "is-windows": "^1.0.1" + } + }, + "is-arrayish": { + "version": "0.2.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/is-arrayish/-/is-arrayish-0.2.1.tgz", + "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=" + }, + "is-core-module": { + "version": "2.9.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/is-core-module/-/is-core-module-2.9.0.tgz", + "integrity": "sha512-+5FPy5PnwmO3lvfMb0AsoPaBG+5KHUI0wYFXOtYPnVVVspTFUuMZNfNaNVRt3FZadstu2c8x23vykRW/NBoU6A==", + "requires": { + "has": "^1.0.3" + } + }, + "is-extglob": { + "version": "2.1.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=" + }, + "is-fullwidth-code-point": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", + "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", + "requires": { + "number-is-nan": "^1.0.0" + } + }, + "is-glob": { + "version": "4.0.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "requires": { + "is-extglob": "^2.1.1" + } + }, + "is-number": { + "version": "4.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/is-number/-/is-number-4.0.0.tgz", + "integrity": "sha512-rSklcAIlf1OmFdyAqbnWTLVelsQ58uvZ66S/ZyawjWqIviTWCjg2PzVGw8WUA+nNuPTqb4wgA+NszrJ+08LlgQ==" + }, + "is-plain-object": { + "version": "5.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/is-plain-object/-/is-plain-object-5.0.0.tgz", + "integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==" + }, + "is-relative": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/is-relative/-/is-relative-1.0.0.tgz", + "integrity": "sha512-Kw/ReK0iqwKeu0MITLFuj0jbPAmEiOsIwyIXvvbfa6QfmN9pkD1M+8pdk7Rl/dTKbH34/XBFMbgD4iMJhLQbGA==", + "requires": { + "is-unc-path": "^1.0.0" + } + }, + "is-stream": { + "version": "2.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/is-stream/-/is-stream-2.0.1.tgz", + "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==" + }, + "is-unc-path": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/is-unc-path/-/is-unc-path-1.0.0.tgz", + "integrity": "sha512-mrGpVd0fs7WWLfVsStvgF6iEJnbjDFZh9/emhRDcGWTduTfNHd9CHeUwH3gYIjdbwo4On6hunkztwOaAw0yllQ==", + "requires": { + "unc-path-regex": "^0.1.2" + } + }, + "is-utf8": { + "version": "0.2.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/is-utf8/-/is-utf8-0.2.1.tgz", + "integrity": "sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI=" + }, + "is-windows": { + "version": "1.0.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/is-windows/-/is-windows-1.0.2.tgz", + "integrity": "sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA==" + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" + }, + "isexe": { + "version": "2.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=" + }, + "isobject": { + "version": "3.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/isobject/-/isobject-3.0.1.tgz", + "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=" + }, + "json-schema-traverse": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==" + }, + "json5": { + "version": "2.2.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/json5/-/json5-2.2.0.tgz", + "integrity": "sha512-f+8cldu7X/y7RAJurMEJmdoKXGB/X550w2Nr3tTbezL6RwEE/iMcm+tZnXeoZtKuOq6ft8+CqzEkrIgx1fPoQA==", + "requires": { + "minimist": "^1.2.5" + } + }, + "jsonfile": { + "version": "6.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/jsonfile/-/jsonfile-6.1.0.tgz", + "integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==", + "requires": { + "graceful-fs": "^4.1.6", + "universalify": "^2.0.0" + } + }, + "kind-of": { + "version": "6.0.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/kind-of/-/kind-of-6.0.3.tgz", + "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==" + }, + "last-run": { + "version": "1.1.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/last-run/-/last-run-1.1.1.tgz", + "integrity": "sha1-RblpQsF7HHnHchmCWbqUO+v4yls=", + "requires": { + "default-resolution": "^2.0.0", + "es6-weak-map": "^2.0.1" + } + }, + "lazystream": { + "version": "1.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/lazystream/-/lazystream-1.0.1.tgz", + "integrity": "sha512-b94GiNHQNy6JNTrt5w6zNyffMrNkXZb3KTkCZJb2V1xaEGCk093vkZ2jk3tpaeP33/OiXC+WvK9AxUebnf5nbw==", + "requires": { + "readable-stream": "^2.0.5" + }, + "dependencies": { + "readable-stream": { + "version": "2.3.7", + "resolved": "https://repo.huaweicloud.com/repository/npm/readable-stream/-/readable-stream-2.3.7.tgz", + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + } + } + }, + "lcid": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/lcid/-/lcid-1.0.0.tgz", + "integrity": "sha1-MIrMr6C8SDo4Z7S28rlQYlHRuDU=", + "requires": { + "invert-kv": "^1.0.0" + } + }, + "liftoff": { + "version": "4.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/liftoff/-/liftoff-4.0.0.tgz", + "integrity": "sha512-rMGwYF8q7g2XhG2ulBmmJgWv25qBsqRbDn5gH0+wnuyeFt7QBJlHJmtg5qEdn4pN6WVAUMgXnIxytMFRX9c1aA==", + "requires": { + "extend": "^3.0.2", + "findup-sync": "^5.0.0", + "fined": "^2.0.0", + "flagged-respawn": "^2.0.0", + "is-plain-object": "^5.0.0", + "object.map": "^1.0.1", + "rechoir": "^0.8.0", + "resolve": "^1.20.0" + } + }, + "load-json-file": { + "version": "1.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/load-json-file/-/load-json-file-1.1.0.tgz", + "integrity": "sha1-lWkFcI1YtLq0wiYbBPWfMcmTdMA=", + "requires": { + "graceful-fs": "^4.1.2", + "parse-json": "^2.2.0", + "pify": "^2.0.0", + "pinkie-promise": "^2.0.0", + "strip-bom": "^2.0.0" + } + }, + "lodash": { + "version": "4.17.21", + "resolved": "https://repo.huaweicloud.com/repository/npm/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" + }, + "lodash.defaults": { + "version": "4.2.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/lodash.defaults/-/lodash.defaults-4.2.0.tgz", + "integrity": "sha1-0JF4cW/+pN3p5ft7N/bwgCJ0WAw=" + }, + "lodash.difference": { + "version": "4.5.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/lodash.difference/-/lodash.difference-4.5.0.tgz", + "integrity": "sha1-nMtOUF1Ia5FlE0V3KIWi3yf9AXw=" + }, + "lodash.flatten": { + "version": "4.4.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/lodash.flatten/-/lodash.flatten-4.4.0.tgz", + "integrity": "sha1-8xwiIlqWMtK7+OSt2+8kCqdlph8=" + }, + "lodash.isplainobject": { + "version": "4.0.6", + "resolved": "https://repo.huaweicloud.com/repository/npm/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", + "integrity": "sha1-fFJqUtibRcRcxpC4gWO+BJf1UMs=" + }, + "lodash.union": { + "version": "4.6.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/lodash.union/-/lodash.union-4.6.0.tgz", + "integrity": "sha1-SLtQiECfFvGCFmZkHETdGqrjzYg=" + }, + "log4js": { + "version": "6.4.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/log4js/-/log4js-6.4.1.tgz", + "integrity": "sha512-iUiYnXqAmNKiIZ1XSAitQ4TmNs8CdZYTAWINARF3LjnsLN8tY5m0vRwd6uuWj/yNY0YHxeZodnbmxKFUOM2rMg==", + "requires": { + "date-format": "^4.0.3", + "debug": "^4.3.3", + "flatted": "^3.2.4", + "rfdc": "^1.3.0", + "streamroller": "^3.0.2" + } + }, + "make-iterator": { + "version": "1.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/make-iterator/-/make-iterator-1.0.1.tgz", + "integrity": "sha512-pxiuXh0iVEq7VM7KMIhs5gxsfxCux2URptUQaXo4iZZJxBAzTPOLE2BumO5dbfVYq/hBJFBR/a1mFDmOx5AGmw==", + "requires": { + "kind-of": "^6.0.2" + } + }, + "map-cache": { + "version": "0.2.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/map-cache/-/map-cache-0.2.2.tgz", + "integrity": "sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8=" + }, + "merge-stream": { + "version": "2.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/merge-stream/-/merge-stream-2.0.0.tgz", + "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==" + }, + "micromatch": { + "version": "4.0.5", + "resolved": "https://repo.huaweicloud.com/repository/npm/micromatch/-/micromatch-4.0.5.tgz", + "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", + "requires": { + "braces": "^3.0.2", + "picomatch": "^2.3.1" + } + }, + "mimic-fn": { + "version": "2.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/mimic-fn/-/mimic-fn-2.1.0.tgz", + "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==" + }, + "minimatch": { + "version": "3.1.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "minimist": { + "version": "1.2.6", + "resolved": "https://repo.huaweicloud.com/repository/npm/minimist/-/minimist-1.2.6.tgz", + "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==" + }, + "ms": { + "version": "2.1.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + }, + "mute-stdout": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/mute-stdout/-/mute-stdout-1.0.0.tgz", + "integrity": "sha1-WzLqB+tDyd7WEwQ0z5JvRrKn/U0=" + }, + "next-tick": { + "version": "1.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/next-tick/-/next-tick-1.1.0.tgz", + "integrity": "sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ==" + }, + "normalize-package-data": { + "version": "2.5.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/normalize-package-data/-/normalize-package-data-2.5.0.tgz", + "integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==", + "requires": { + "hosted-git-info": "^2.1.4", + "resolve": "^1.10.0", + "semver": "2 || 3 || 4 || 5", + "validate-npm-package-license": "^3.0.1" + } + }, + "normalize-path": { + "version": "3.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==" + }, + "now-and-later": { + "version": "2.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/now-and-later/-/now-and-later-2.0.1.tgz", + "integrity": "sha512-KGvQ0cB70AQfg107Xvs/Fbu+dGmZoTRJp2TaPwcwQm3/7PteUyN2BCgk8KBMPGBUXZdVwyWS8fDCGFygBm19UQ==", + "requires": { + "once": "^1.3.2" + } + }, + "npm-run-path": { + "version": "4.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/npm-run-path/-/npm-run-path-4.0.1.tgz", + "integrity": "sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==", + "requires": { + "path-key": "^3.0.0" + } + }, + "number-is-nan": { + "version": "1.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/number-is-nan/-/number-is-nan-1.0.1.tgz", + "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=" + }, + "object-keys": { + "version": "1.1.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/object-keys/-/object-keys-1.1.1.tgz", + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==" + }, + "object.assign": { + "version": "4.1.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/object.assign/-/object.assign-4.1.2.tgz", + "integrity": "sha512-ixT2L5THXsApyiUPYKmW+2EHpXXe5Ii3M+f4e+aJFAHao5amFRW6J0OO6c/LU8Be47utCx2GL89hxGB6XSmKuQ==", + "requires": { + "call-bind": "^1.0.0", + "define-properties": "^1.1.3", + "has-symbols": "^1.0.1", + "object-keys": "^1.1.1" + } + }, + "object.defaults": { + "version": "1.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/object.defaults/-/object.defaults-1.1.0.tgz", + "integrity": "sha1-On+GgzS0B96gbaFtiNXNKeQ1/s8=", + "requires": { + "array-each": "^1.0.1", + "array-slice": "^1.0.0", + "for-own": "^1.0.0", + "isobject": "^3.0.0" + } + }, + "object.map": { + "version": "1.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/object.map/-/object.map-1.0.1.tgz", + "integrity": "sha1-z4Plncj8wK1fQlDh94s7gb2AHTc=", + "requires": { + "for-own": "^1.0.0", + "make-iterator": "^1.0.0" + } + }, + "object.pick": { + "version": "1.3.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/object.pick/-/object.pick-1.3.0.tgz", + "integrity": "sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c=", + "requires": { + "isobject": "^3.0.1" + } + }, + "object.reduce": { + "version": "1.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/object.reduce/-/object.reduce-1.0.1.tgz", + "integrity": "sha1-b+NI8qx/oPlcpiEiZZkJaCW7A60=", + "requires": { + "for-own": "^1.0.0", + "make-iterator": "^1.0.0" + } + }, + "once": { + "version": "1.4.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "requires": { + "wrappy": "1" + } + }, + "onetime": { + "version": "5.1.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/onetime/-/onetime-5.1.2.tgz", + "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", + "requires": { + "mimic-fn": "^2.1.0" + } + }, + "os-locale": { + "version": "1.4.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/os-locale/-/os-locale-1.4.0.tgz", + "integrity": "sha1-IPnxeuKe00XoveWDsT0gCYA8FNk=", + "requires": { + "lcid": "^1.0.0" + } + }, + "parse-filepath": { + "version": "1.0.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/parse-filepath/-/parse-filepath-1.0.2.tgz", + "integrity": "sha1-pjISf1Oq89FYdvWHLz/6x2PWyJE=", + "requires": { + "is-absolute": "^1.0.0", + "map-cache": "^0.2.0", + "path-root": "^0.1.1" + } + }, + "parse-json": { + "version": "2.2.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/parse-json/-/parse-json-2.2.0.tgz", + "integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=", + "requires": { + "error-ex": "^1.2.0" + } + }, + "parse-passwd": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/parse-passwd/-/parse-passwd-1.0.0.tgz", + "integrity": "sha1-bVuTSkVpk7I9N/QKOC1vFmao5cY=" + }, + "path-exists": { + "version": "2.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/path-exists/-/path-exists-2.1.0.tgz", + "integrity": "sha1-D+tsZPD8UY2adU3V77YscCJ2H0s=", + "requires": { + "pinkie-promise": "^2.0.0" + } + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" + }, + "path-key": { + "version": "3.1.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==" + }, + "path-parse": { + "version": "1.0.7", + "resolved": "https://repo.huaweicloud.com/repository/npm/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==" + }, + "path-root": { + "version": "0.1.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/path-root/-/path-root-0.1.1.tgz", + "integrity": "sha1-mkpoFMrBwM1zNgqV8yCDyOpHRbc=", + "requires": { + "path-root-regex": "^0.1.0" + } + }, + "path-root-regex": { + "version": "0.1.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/path-root-regex/-/path-root-regex-0.1.2.tgz", + "integrity": "sha1-v8zcjfWxLcUsi0PsONGNcsBLqW0=" + }, + "path-type": { + "version": "1.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/path-type/-/path-type-1.1.0.tgz", + "integrity": "sha1-WcRPfuSR2nBNpBXaWkBwuk+P5EE=", + "requires": { + "graceful-fs": "^4.1.2", + "pify": "^2.0.0", + "pinkie-promise": "^2.0.0" + } + }, + "picomatch": { + "version": "2.3.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==" + }, + "pify": { + "version": "2.3.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/pify/-/pify-2.3.0.tgz", + "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=" + }, + "pinkie": { + "version": "2.0.4", + "resolved": "https://repo.huaweicloud.com/repository/npm/pinkie/-/pinkie-2.0.4.tgz", + "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=" + }, + "pinkie-promise": { + "version": "2.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/pinkie-promise/-/pinkie-promise-2.0.1.tgz", + "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", + "requires": { + "pinkie": "^2.0.0" + } + }, + "pretty-hrtime": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/pretty-hrtime/-/pretty-hrtime-1.0.0.tgz", + "integrity": "sha1-9ualItPmBwRSK/Db5oVu0g515Nw=" + }, + "process-nextick-args": { + "version": "2.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/process-nextick-args/-/process-nextick-args-2.0.1.tgz", + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==" + }, + "punycode": { + "version": "2.1.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/punycode/-/punycode-2.1.1.tgz", + "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==" + }, + "read-pkg": { + "version": "1.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/read-pkg/-/read-pkg-1.1.0.tgz", + "integrity": "sha1-9f+qXs0pyzHAR0vKfXVra7KePyg=", + "requires": { + "load-json-file": "^1.0.0", + "normalize-package-data": "^2.3.2", + "path-type": "^1.0.0" + } + }, + "read-pkg-up": { + "version": "1.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/read-pkg-up/-/read-pkg-up-1.0.1.tgz", + "integrity": "sha1-nWPBMnbAZZGNV/ACpX9AobZD+wI=", + "requires": { + "find-up": "^1.0.0", + "read-pkg": "^1.0.0" + } + }, + "readable-stream": { + "version": "3.6.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "requires": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + } + }, + "readdir-glob": { + "version": "1.1.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/readdir-glob/-/readdir-glob-1.1.1.tgz", + "integrity": "sha512-91/k1EzZwDx6HbERR+zucygRFfiPl2zkIYZtv3Jjr6Mn7SkKcVct8aVO+sSRiGMc6fLf72du3d92/uY63YPdEA==", + "requires": { + "minimatch": "^3.0.4" + } + }, + "rechoir": { + "version": "0.8.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/rechoir/-/rechoir-0.8.0.tgz", + "integrity": "sha512-/vxpCXddiX8NGfGO/mTafwjq4aFa/71pvamip0++IQk3zG8cbCj0fifNPrjjF1XMXUne91jL9OoxmdykoEtifQ==", + "requires": { + "resolve": "^1.20.0" + } + }, + "require-directory": { + "version": "2.1.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=" + }, + "require-from-string": { + "version": "2.0.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/require-from-string/-/require-from-string-2.0.2.tgz", + "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==" + }, + "require-main-filename": { + "version": "1.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/require-main-filename/-/require-main-filename-1.0.1.tgz", + "integrity": "sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE=" + }, + "resolve": { + "version": "1.22.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/resolve/-/resolve-1.22.0.tgz", + "integrity": "sha512-Hhtrw0nLeSrFQ7phPp4OOcVjLPIeMnRlr5mcnVuMe7M/7eBn98A3hmFRLoFo3DLZkivSYwhRUJTyPyWAk56WLw==", + "requires": { + "is-core-module": "^2.8.1", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" + } + }, + "resolve-dir": { + "version": "1.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/resolve-dir/-/resolve-dir-1.0.1.tgz", + "integrity": "sha1-eaQGRMNivoLybv/nOcm7U4IEb0M=", + "requires": { + "expand-tilde": "^2.0.0", + "global-modules": "^1.0.0" + } + }, + "resolve-package-path": { + "version": "4.0.3", + "resolved": "https://repo.huaweicloud.com/repository/npm/resolve-package-path/-/resolve-package-path-4.0.3.tgz", + "integrity": "sha512-SRpNAPW4kewOaNUt8VPqhJ0UMxawMwzJD8V7m1cJfdSTK9ieZwS6K7Dabsm4bmLFM96Z5Y/UznrpG5kt1im8yA==", + "requires": { + "path-root": "^0.1.1" + } + }, + "rfdc": { + "version": "1.3.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/rfdc/-/rfdc-1.3.0.tgz", + "integrity": "sha512-V2hovdzFbOi77/WajaSMXk2OLm+xNIeQdMMuB7icj7bk6zi2F8GGAxigcnDFpJHbNyNcgyJDiP+8nOrY5cZGrA==" + }, + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + }, + "safer-buffer": { + "version": "2.1.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + }, + "semver": { + "version": "5.7.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==" + }, + "set-blocking": { + "version": "2.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=" + }, + "shebang-command": { + "version": "2.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "requires": { + "shebang-regex": "^3.0.0" + } + }, + "shebang-regex": { + "version": "3.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==" + }, + "signal-exit": { + "version": "3.0.7", + "resolved": "https://repo.huaweicloud.com/repository/npm/signal-exit/-/signal-exit-3.0.7.tgz", + "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==" + }, + "spdx-correct": { + "version": "3.1.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/spdx-correct/-/spdx-correct-3.1.1.tgz", + "integrity": "sha512-cOYcUWwhCuHCXi49RhFRCyJEK3iPj1Ziz9DpViV3tbZOwXD49QzIN3MpOLJNxh2qwq2lJJZaKMVw9qNi4jTC0w==", + "requires": { + "spdx-expression-parse": "^3.0.0", + "spdx-license-ids": "^3.0.0" + } + }, + "spdx-exceptions": { + "version": "2.3.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/spdx-exceptions/-/spdx-exceptions-2.3.0.tgz", + "integrity": "sha512-/tTrYOC7PPI1nUAgx34hUpqXuyJG+DTHJTnIULG4rDygi4xu/tfgmq1e1cIRwRzwZgo4NLySi+ricLkZkw4i5A==" + }, + "spdx-expression-parse": { + "version": "3.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/spdx-expression-parse/-/spdx-expression-parse-3.0.1.tgz", + "integrity": "sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q==", + "requires": { + "spdx-exceptions": "^2.1.0", + "spdx-license-ids": "^3.0.0" + } + }, + "spdx-license-ids": { + "version": "3.0.11", + "resolved": "https://repo.huaweicloud.com/repository/npm/spdx-license-ids/-/spdx-license-ids-3.0.11.tgz", + "integrity": "sha512-Ctl2BrFiM0X3MANYgj3CkygxhRmr9mi6xhejbdO960nF6EDJApTYpn0BQnDKlnNBULKiCN1n3w9EBkHK8ZWg+g==" + }, + "stream-exhaust": { + "version": "1.0.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/stream-exhaust/-/stream-exhaust-1.0.2.tgz", + "integrity": "sha512-b/qaq/GlBK5xaq1yrK9/zFcyRSTNxmcZwFLGSTG0mXgZl/4Z6GgiyYOXOvY7N3eEvFRAG1bkDRz5EPGSvPYQlw==" + }, + "streamroller": { + "version": "3.0.7", + "resolved": "https://repo.huaweicloud.com/repository/npm/streamroller/-/streamroller-3.0.7.tgz", + "integrity": "sha512-kh68kwiDGuIPiPDWwRbEC5us+kfARP1e9AsQiaLaSqGrctOvMn0mtL8iNY3r4/o5nIoYi3gPI1jexguZsXDlxw==", + "requires": { + "date-format": "^4.0.7", + "debug": "^4.3.4", + "fs-extra": "^10.0.1" + } + }, + "string-width": { + "version": "1.0.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/string-width/-/string-width-1.0.2.tgz", + "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", + "requires": { + "code-point-at": "^1.0.0", + "is-fullwidth-code-point": "^1.0.0", + "strip-ansi": "^3.0.0" + } + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "requires": { + "safe-buffer": "~5.1.0" + } + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "strip-bom": { + "version": "2.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/strip-bom/-/strip-bom-2.0.0.tgz", + "integrity": "sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4=", + "requires": { + "is-utf8": "^0.2.0" + } + }, + "strip-final-newline": { + "version": "2.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/strip-final-newline/-/strip-final-newline-2.0.0.tgz", + "integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==" + }, + "supports-preserve-symlinks-flag": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", + "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==" + }, + "tar-stream": { + "version": "2.2.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/tar-stream/-/tar-stream-2.2.0.tgz", + "integrity": "sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==", + "requires": { + "bl": "^4.0.3", + "end-of-stream": "^1.4.1", + "fs-constants": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^3.1.1" + } + }, + "to-regex-range": { + "version": "5.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "requires": { + "is-number": "^7.0.0" + }, + "dependencies": { + "is-number": { + "version": "7.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==" + } + } + }, + "type": { + "version": "1.2.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/type/-/type-1.2.0.tgz", + "integrity": "sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg==" + }, + "unc-path-regex": { + "version": "0.1.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/unc-path-regex/-/unc-path-regex-0.1.2.tgz", + "integrity": "sha1-5z3T17DXxe2G+6xrCufYxqadUPo=" + }, + "undertaker": { + "version": "1.2.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/undertaker/-/undertaker-1.2.1.tgz", + "integrity": "sha512-71WxIzDkgYk9ZS+spIB8iZXchFhAdEo2YU8xYqBYJ39DIUIqziK78ftm26eecoIY49X0J2MLhG4hr18Yp6/CMA==", + "requires": { + "arr-flatten": "^1.0.1", + "arr-map": "^2.0.0", + "bach": "^1.0.0", + "collection-map": "^1.0.0", + "es6-weak-map": "^2.0.1", + "last-run": "^1.1.0", + "object.defaults": "^1.0.0", + "object.reduce": "^1.0.0", + "undertaker-registry": "^1.0.0" + } + }, + "undertaker-registry": { + "version": "1.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/undertaker-registry/-/undertaker-registry-1.0.1.tgz", + "integrity": "sha1-XkvaMI5KiirlhPm5pDWaSZglzFA=" + }, + "universalify": { + "version": "2.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/universalify/-/universalify-2.0.0.tgz", + "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==" + }, + "uri-js": { + "version": "4.4.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/uri-js/-/uri-js-4.4.1.tgz", + "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "requires": { + "punycode": "^2.1.0" + } + }, + "util-deprecate": { + "version": "1.0.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" + }, + "v8flags": { + "version": "3.2.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/v8flags/-/v8flags-3.2.0.tgz", + "integrity": "sha512-mH8etigqMfiGWdeXpaaqGfs6BndypxusHHcv2qSHyZkGEznCd/qAXCWWRzeowtL54147cktFOC4P5y+kl8d8Jg==", + "requires": { + "homedir-polyfill": "^1.0.1" + } + }, + "validate-npm-package-license": { + "version": "3.0.4", + "resolved": "https://repo.huaweicloud.com/repository/npm/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz", + "integrity": "sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==", + "requires": { + "spdx-correct": "^3.0.0", + "spdx-expression-parse": "^3.0.0" + } + }, + "which": { + "version": "1.3.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/which/-/which-1.3.1.tgz", + "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", + "requires": { + "isexe": "^2.0.0" + } + }, + "which-module": { + "version": "1.0.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/which-module/-/which-module-1.0.0.tgz", + "integrity": "sha1-u6Y8qGGUiZT/MHc2CJ47lgJsKk8=" + }, + "wrap-ansi": { + "version": "2.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/wrap-ansi/-/wrap-ansi-2.1.0.tgz", + "integrity": "sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=", + "requires": { + "string-width": "^1.0.1", + "strip-ansi": "^3.0.1" + } + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + }, + "y18n": { + "version": "3.2.2", + "resolved": "https://repo.huaweicloud.com/repository/npm/y18n/-/y18n-3.2.2.tgz", + "integrity": "sha512-uGZHXkHnhF0XeeAPgnKfPv1bgKAYyVvmNL1xlKsPYZPaIHxGti2hHqvOCQv71XMsLxu1QjergkqogUnms5D3YQ==" + }, + "yargs": { + "version": "7.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/yargs/-/yargs-7.1.0.tgz", + "integrity": "sha1-a6MY6xaWFyf10oT46gA+jWFU0Mg=", + "requires": { + "camelcase": "^3.0.0", + "cliui": "^3.2.0", + "decamelize": "^1.1.1", + "get-caller-file": "^1.0.1", + "os-locale": "^1.4.0", + "read-pkg-up": "^1.0.1", + "require-directory": "^2.1.1", + "require-main-filename": "^1.0.1", + "set-blocking": "^2.0.0", + "string-width": "^1.0.2", + "which-module": "^1.0.0", + "y18n": "^3.2.1", + "yargs-parser": "^5.0.0" + } + }, + "yargs-parser": { + "version": "5.0.1", + "resolved": "https://repo.huaweicloud.com/repository/npm/yargs-parser/-/yargs-parser-5.0.1.tgz", + "integrity": "sha512-wpav5XYiddjXxirPoCTUPbqM0PXvJ9hiBMvuJgInvo4/lAOTZzUprArw17q2O1P2+GHhbBr18/iQwjL5Z9BqfA==", + "requires": { + "camelcase": "^3.0.0", + "object.assign": "^4.1.0" + } + }, + "zip-stream": { + "version": "4.1.0", + "resolved": "https://repo.huaweicloud.com/repository/npm/zip-stream/-/zip-stream-4.1.0.tgz", + "integrity": "sha512-zshzwQW7gG7hjpBlgeQP9RuyPGNxvJdzR8SUM3QhxCnLjWN2E7j3dOvpeDcQoETfHx0urRS7EtmVToql7YpU4A==", + "requires": { + "archiver-utils": "^2.1.0", + "compress-commons": "^4.1.0", + "readable-stream": "^3.6.0" + } + } + } +} diff --git a/frameworks/innerkits/file_extension_hap/package.json b/frameworks/innerkits/file_extension_hap/package.json new file mode 100644 index 0000000000000000000000000000000000000000..15be3afb1043ac71fba88cd603817b8cb9bbe2b7 --- /dev/null +++ b/frameworks/innerkits/file_extension_hap/package.json @@ -0,0 +1,18 @@ +{ + "license":"ISC", + "devDependencies":{}, + "name":"fileextension", + "ohos":{ + "org":"huawei", + "directoryLevel":"project", + "buildTool":"hvigor" + }, + "description":"FileExtension", + "repository":{}, + "version":"1.0.0", + "dependencies":{ + "@ohos/hvigor-ohos-plugin":"1.0.6", + "hypium":"^1.0.0", + "@ohos/hvigor":"1.0.6" + } +} \ No newline at end of file diff --git a/frameworks/innerkits/signature/fileextension.p7b b/frameworks/innerkits/signature/fileextension.p7b new file mode 100644 index 0000000000000000000000000000000000000000..5b1328605f9fda63b5b61fa317f25bcff26028fa Binary files /dev/null and b/frameworks/innerkits/signature/fileextension.p7b differ 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..cb6a0605d65030f707c76ae67e553bdae5361a4a --- /dev/null +++ b/interfaces/kits/napi/file_access_module/BUILD.gn @@ -0,0 +1,48 @@ +# 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", + ] + + sources = [ + "napi_fileaccess_helper.cpp", + "native_fileaccess_module.cpp", + ] + + deps = [ + "${BASE_DIR}/frameworks/innerkits/file_extension:file_extension_ability_kit", + "//foundation/aafwk/standard/interfaces/kits/napi/aafwk/inner/napi_common:napi_common", + ] + + 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", + ] +} \ No newline at end of file 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..3dae7588e73df5dcde2140cb266918fc8a8ce680 --- /dev/null +++ b/interfaces/kits/napi/file_access_module/file_access_common.h @@ -0,0 +1,118 @@ +/* + * 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 OHOS_APPEXECFWK_FILEACCESS_COMMON_H +#define OHOS_APPEXECFWK_FILEACCESS_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" +#include "want.h" + +using Want = OHOS::AAFwk::Want; +using Ability = OHOS::AppExecFwk::Ability; +using AbilityStartSetting = OHOS::AppExecFwk::AbilityStartSetting; + +namespace OHOS { +namespace AppExecFwk { + +struct CBBase { + CallbackInfo cbInfo; + napi_async_work asyncWork; + napi_deferred deferred; + Ability *ability = nullptr; + AbilityType abilityType = AbilityType::UNKNOWN; + int errCode = 0; +}; + +struct FileAccessHelperCB { + CBBase cbBase; + napi_ref uri = nullptr; + napi_value result = nullptr; +}; + +struct FileAccessHelperOpenFileCB { + CBBase cbBase; + FileAccessHelper *fileAccessHelper = nullptr; + std::string uri; + std::string mode; + int result = 0; + 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 = 0; + 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 FileAccessHelperCloseFileCB { + CBBase cbBase; + FileAccessHelper *fileAccessHelper = nullptr; + int fd; + std::string uri; + int result; + int execResult; +}; + +struct FileAccessHelperReleaseCB { + CBBase cbBase; + FileAccessHelper *fileAccessHelper = nullptr; + bool result = false; +}; +} +} +#endif \ No newline at end of file diff --git a/interfaces/kits/napi/file_access_module/napi_fileaccess_helper.cpp b/interfaces/kits/napi/file_access_module/napi_fileaccess_helper.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7a0c45d9bd7244ed33b640ae86a1c534a54ae9fb --- /dev/null +++ b/interfaces/kits/napi/file_access_module/napi_fileaccess_helper.cpp @@ -0,0 +1,1651 @@ +/* + * 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 "napi_fileaccess_helper.h" + +#include +#include + +#include "uri.h" + +#include "hilog_wrapper.h" +#include "napi_base_context.h" +#include "securec.h" + +using namespace OHOS::AAFwk; +using namespace OHOS::AppExecFwk; + +namespace OHOS { +namespace AppExecFwk { +namespace { +const std::string FILEACCESS_CLASS_NAME = "FileAccessHelper"; +constexpr int NO_ERROR = 0; +constexpr int INVALID_PARAMETER = -1; + +std::string NapiValueToStringUtf8(napi_env env, napi_value value) +{ + HILOG_INFO("tag dsa %{public}s,called", __func__); + std::string result = ""; + return UnwrapStringFromJS(env, value, result); +} + +int NapiValueToInt32Utf8(napi_env env, napi_value value) +{ + HILOG_INFO("tag dsa %{public}s,called", __func__); + int result = 0; + return UnwrapInt32FromJS(env, value, result); +} +} + +std::list> g_fileAccessHelperList; +static napi_ref g_constructorRef = nullptr; + +napi_value AcquireFileAccessHelperWrap(napi_env env, napi_callback_info info, FileAccessHelperCB *fileAccessHelperCB) +{ + HILOG_INFO("tag dsa %{public}s,called", __func__); + if (fileAccessHelperCB == nullptr) { + HILOG_ERROR("tag dsa %{public}s,fileAccessHelperCB == nullptr", __func__); + return nullptr; + } + + size_t requireArgc = ARGS_THREE; + size_t argc = ARGS_THREE; + napi_value args[ARGS_THREE] = {nullptr}; + NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, nullptr, nullptr)); + if (argc > requireArgc) { + HILOG_ERROR("tag dsa %{public}s, Wrong argument count %{public}zu.", __func__, argc); + return nullptr; + } + + napi_value result = nullptr; + napi_value cons = nullptr; + if (napi_get_reference_value(env, g_constructorRef, &cons) != napi_ok) { + return nullptr; + } + NAPI_CALL(env, napi_new_instance(env, cons, ARGS_THREE, args, &result)); + + if (!IsTypeForNapiValue(env, result, napi_object)) { + HILOG_ERROR("tag dsa %{public}s, IsTypeForNapiValue isn`t object", __func__); + return nullptr; + } + + if (IsTypeForNapiValue(env, result, napi_null)) { + HILOG_ERROR("tag dsa %{public}s, IsTypeForNapiValue is null", __func__); + return nullptr; + } + + if (IsTypeForNapiValue(env, result, napi_undefined)) { + HILOG_ERROR("tag dsa %{public}s, IsTypeForNapiValue is undefined", __func__); + return nullptr; + } + + delete fileAccessHelperCB; + fileAccessHelperCB = nullptr; + HILOG_INFO("tag dsa %{public}s,end", __func__); + return result; +} + +napi_value NAPI_AcquireFileAccessHelperCommon(napi_env env, napi_callback_info info, AbilityType abilityType) +{ + HILOG_INFO("tag dsa %{public}s,called", __func__); + FileAccessHelperCB *fileAccessHelperCB = new (std::nothrow) FileAccessHelperCB; + if (fileAccessHelperCB == nullptr) { + HILOG_ERROR("tag dsa %{public}s, FileAccessHelperCB == nullptr", __func__); + return WrapVoidToJS(env); + } + + fileAccessHelperCB->cbBase.cbInfo.env = env; + fileAccessHelperCB->cbBase.errCode = NAPI_ERR_NO_ERROR; + fileAccessHelperCB->cbBase.abilityType = abilityType; + napi_value ret = AcquireFileAccessHelperWrap(env, info, fileAccessHelperCB); + if (ret == nullptr) { + HILOG_ERROR("tag dsa %{public}s, ret == nullptr", __func__); + if (fileAccessHelperCB != nullptr) { + delete fileAccessHelperCB; + fileAccessHelperCB = nullptr; + } + ret = WrapVoidToJS(env); + } + HILOG_INFO("tag dsa %{public}s,end", __func__); + return ret; +} + +napi_value NAPI_CreateFileAccessHelper(napi_env env, napi_callback_info info) +{ + HILOG_INFO("tag dsa %{public}s, called", __func__); + return NAPI_AcquireFileAccessHelperCommon(env, info, AbilityType::EXTENSION); +} + +napi_value FileAccessHelperInit(napi_env env, napi_value exports) +{ + HILOG_INFO("tag dsa %{public}s,called start ", __func__); + napi_property_descriptor properties[] = { + DECLARE_NAPI_FUNCTION("openFile", NAPI_OpenFile), + DECLARE_NAPI_FUNCTION("mkdir", NAPI_Mkdir), + DECLARE_NAPI_FUNCTION("createFile", NAPI_CreateFile), + DECLARE_NAPI_FUNCTION("delete", NAPI_Delete), + DECLARE_NAPI_FUNCTION("move", NAPI_Move), + DECLARE_NAPI_FUNCTION("rename", NAPI_Rename), + DECLARE_NAPI_FUNCTION("closeFile", NAPI_CloseFile), + DECLARE_NAPI_FUNCTION("release", NAPI_Release), + }; + napi_value cons = nullptr; + NAPI_CALL(env, + napi_define_class(env, + FILEACCESS_CLASS_NAME.c_str(), + NAPI_AUTO_LENGTH, + FileAccessHelperConstructor, + nullptr, + sizeof(properties) / sizeof(*properties), + properties, + &cons)); + g_fileAccessHelperList.clear(); + NAPI_CALL(env, napi_create_reference(env, cons, 1, &g_constructorRef)); + NAPI_CALL(env, napi_set_named_property(env, exports, FILEACCESS_CLASS_NAME.c_str(), cons)); + + napi_property_descriptor export_properties[] = { + DECLARE_NAPI_FUNCTION("createFileAccessHelper", NAPI_CreateFileAccessHelper), + }; + NAPI_CALL(env, napi_define_properties(env, exports, sizeof(export_properties) / sizeof(export_properties[0]), + export_properties)); + return exports; +} + +napi_value FileAccessHelperConstructor(napi_env env, napi_callback_info info) +{ + HILOG_INFO("tag dsa %{public}s, called", __func__); + size_t argc = ARGS_TWO; + napi_value argv[ARGS_TWO] = {nullptr}; + napi_value thisVar = nullptr; + NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, &thisVar, nullptr)); + NAPI_ASSERT(env, argc > 0, "Wrong number of arguments"); + AAFwk::Want want; + OHOS::AppExecFwk::UnwrapWant(env, argv[PARAM1], want); + std::shared_ptr fileAccessHelper = nullptr; + bool isStageMode = false; + napi_status status = AbilityRuntime::IsStageContext(env, argv[PARAM0], isStageMode); + if (status != napi_ok || !isStageMode) { + HILOG_INFO("tag dsa FA Model"); + return nullptr; + } else { + auto context = OHOS::AbilityRuntime::GetStageModeContext(env, argv[PARAM0]); + NAPI_ASSERT(env, context != nullptr, "FileAccessHelperConstructor: failed to get native context"); + HILOG_INFO("tag dsa Stage Model"); + fileAccessHelper = FileAccessHelper::Creator(context, want); + } + NAPI_ASSERT(env, fileAccessHelper != nullptr, "FileAccessHelperConstructor: fileAccessHelper is nullptr"); + g_fileAccessHelperList.emplace_back(fileAccessHelper); + napi_wrap(env, thisVar, fileAccessHelper.get(), [](napi_env env, void *data, void *hint) { + FileAccessHelper *objectInfo = static_cast(data); + g_fileAccessHelperList.remove_if([objectInfo](const std::shared_ptr &fileAccessHelper) { + return objectInfo == fileAccessHelper.get(); + }); + }, nullptr, nullptr); + HILOG_INFO("tag dsa %{public}s,called end", __func__); + return thisVar; +} + +napi_value NAPI_OpenFile(napi_env env, napi_callback_info info) +{ + HILOG_INFO("tag dsa %{public}s,called", __func__); + FileAccessHelperOpenFileCB *openFileCB = new (std::nothrow) FileAccessHelperOpenFileCB; + if (openFileCB == nullptr) { + HILOG_ERROR("tag dsa %{public}s, openFileCB == nullptr.", __func__); + return WrapVoidToJS(env); + } + openFileCB->cbBase.cbInfo.env = env; + openFileCB->cbBase.asyncWork = nullptr; + openFileCB->cbBase.deferred = nullptr; + openFileCB->cbBase.ability = nullptr; + + napi_value ret = OpenFileWrap(env, info, openFileCB); + if (ret == nullptr) { + HILOG_ERROR("tag dsa %{public}s,ret == nullptr", __func__); + if (openFileCB != nullptr) { + delete openFileCB; + openFileCB = nullptr; + } + ret = WrapVoidToJS(env); + } + HILOG_INFO("tag dsa %{public}s,end", __func__); + return ret; +} + +napi_value OpenFileWrap(napi_env env, napi_callback_info info, FileAccessHelperOpenFileCB *openFileCB) +{ + HILOG_INFO("tag dsa %{public}s,called", __func__); + size_t argcAsync = ARGS_THREE; + const size_t argcPromise = ARGS_TWO; + const size_t argCountWithAsync = argcPromise + ARGS_ASYNC_COUNT; + napi_value args[ARGS_MAX_COUNT] = {nullptr}; + napi_value ret = 0; + napi_value thisVar = nullptr; + + NAPI_CALL(env, napi_get_cb_info(env, info, &argcAsync, args, &thisVar, nullptr)); + if (argcAsync > argCountWithAsync || argcAsync > ARGS_MAX_COUNT) { + HILOG_ERROR("tag dsa %{public}s, Wrong argument count.", __func__); + return nullptr; + } + + napi_valuetype valuetype = napi_undefined; + NAPI_CALL(env, napi_typeof(env, args[PARAM0], &valuetype)); + if (valuetype == napi_string) { + openFileCB->uri = NapiValueToStringUtf8(env, args[PARAM0]); + HILOG_INFO("tag dsa %{public}s,uri=%{public}s", __func__, openFileCB->uri.c_str()); + } + + NAPI_CALL(env, napi_typeof(env, args[PARAM1], &valuetype)); + if (valuetype == napi_string) { + openFileCB->mode = NapiValueToStringUtf8(env, args[PARAM1]); + HILOG_INFO("tag dsa %{public}s,mode=%{public}s", __func__, openFileCB->mode.c_str()); + } + + FileAccessHelper *objectInfo = nullptr; + napi_unwrap(env, thisVar, (void **)&objectInfo); + HILOG_INFO("tag dsa %{public}s,FileAccessHelper objectInfo", __func__); + openFileCB->fileAccessHelper = objectInfo; + + if (argcAsync > argcPromise) { + ret = OpenFileAsync(env, args, ARGS_TWO, openFileCB); + } else { + ret = OpenFilePromise(env, openFileCB); + } + HILOG_INFO("tag dsa %{public}s,end", __func__); + return ret; +} + +napi_value OpenFileAsync(napi_env env, napi_value *args, const size_t argCallback, FileAccessHelperOpenFileCB *openFileCB) +{ + HILOG_INFO("tag dsa %{public}s, asyncCallback.", __func__); + if (args == nullptr || openFileCB == nullptr) { + HILOG_ERROR("tag dsa %{public}s, param == nullptr.", __func__); + return nullptr; + } + napi_value resourceName = 0; + NAPI_CALL(env, napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName)); + + napi_valuetype valuetype = napi_undefined; + NAPI_CALL(env, napi_typeof(env, args[argCallback], &valuetype)); + if (valuetype == napi_function) { + NAPI_CALL(env, napi_create_reference(env, args[argCallback], 1, &openFileCB->cbBase.cbInfo.callback)); + } + + NAPI_CALL(env, + napi_create_async_work(env, + nullptr, + resourceName, + OpenFileExecuteCB, + OpenFileAsyncCompleteCB, + (void *)openFileCB, + &openFileCB->cbBase.asyncWork)); + NAPI_CALL(env, napi_queue_async_work(env, openFileCB->cbBase.asyncWork)); + napi_value result = 0; + NAPI_CALL(env, napi_get_null(env, &result)); + HILOG_INFO("tag dsa %{public}s, asyncCallback end.", __func__); + return result; +} + +napi_value OpenFilePromise(napi_env env, FileAccessHelperOpenFileCB *openFileCB) +{ + HILOG_INFO("tag dsa %{public}s, promise.", __func__); + if (openFileCB == nullptr) { + HILOG_ERROR("tag dsa %{public}s, param == nullptr.", __func__); + return nullptr; + } + napi_value resourceName; + NAPI_CALL(env, napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName)); + napi_deferred deferred; + napi_value promise = 0; + NAPI_CALL(env, napi_create_promise(env, &deferred, &promise)); + openFileCB->cbBase.deferred = deferred; + + NAPI_CALL(env, + napi_create_async_work(env, + nullptr, + resourceName, + OpenFileExecuteCB, + OpenFilePromiseCompleteCB, + (void *)openFileCB, + &openFileCB->cbBase.asyncWork)); + NAPI_CALL(env, napi_queue_async_work(env, openFileCB->cbBase.asyncWork)); + HILOG_INFO("tag dsa %{public}s, promise end.", __func__); + return promise; +} + +void OpenFileExecuteCB(napi_env env, void *data) +{ + HILOG_INFO("tag dsa NAPI_OpenFile, worker pool thread execute."); + FileAccessHelperOpenFileCB *OpenFileCB = static_cast(data); + if (OpenFileCB->fileAccessHelper != nullptr) { + OpenFileCB->execResult = INVALID_PARAMETER; + if (!OpenFileCB->uri.empty()) { + OHOS::Uri uri(OpenFileCB->uri); + OpenFileCB->result = OpenFileCB->fileAccessHelper->OpenFile(uri, OpenFileCB->mode); + OpenFileCB->execResult = NO_ERROR; + } else { + HILOG_ERROR("tag dsa NAPI_OpenFile, fileAccessHelper uri is empty"); + } + } else { + HILOG_ERROR("tag dsa NAPI_OpenFile, fileAccessHelper == nullptr"); + } + HILOG_INFO("tag dsa NAPI_OpenFile, worker pool thread execute end."); +} + +void OpenFileAsyncCompleteCB(napi_env env, napi_status status, void *data) +{ + HILOG_INFO("tag dsa NAPI_OpenFile, main event thread complete."); + FileAccessHelperOpenFileCB *OpenFileCB = static_cast(data); + napi_value callback = nullptr; + napi_value undefined = nullptr; + napi_value result[ARGS_TWO] = {nullptr}; + napi_value callResult = nullptr; + NAPI_CALL_RETURN_VOID(env, napi_get_undefined(env, &undefined)); + NAPI_CALL_RETURN_VOID(env, napi_get_reference_value(env, OpenFileCB->cbBase.cbInfo.callback, &callback)); + + result[PARAM0] = GetCallbackErrorValue(env, OpenFileCB->execResult); + napi_create_int32(env, OpenFileCB->result, &result[PARAM1]); + NAPI_CALL_RETURN_VOID(env, napi_call_function(env, undefined, callback, ARGS_TWO, &result[PARAM0], &callResult)); + + if (OpenFileCB->cbBase.cbInfo.callback != nullptr) { + NAPI_CALL_RETURN_VOID(env, napi_delete_reference(env, OpenFileCB->cbBase.cbInfo.callback)); + } + NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, OpenFileCB->cbBase.asyncWork)); + delete OpenFileCB; + OpenFileCB = nullptr; + HILOG_INFO("tag dsa NAPI_OpenFile, main event thread complete end."); +} + +void OpenFilePromiseCompleteCB(napi_env env, napi_status status, void *data) +{ + HILOG_INFO("tag dsa NAPI_OpenFileCB, main event thread complete."); + FileAccessHelperOpenFileCB *OpenFileCB = static_cast(data); + napi_value result = nullptr; + napi_create_int32(env, OpenFileCB->result, &result); + NAPI_CALL_RETURN_VOID(env, napi_resolve_deferred(env, OpenFileCB->cbBase.deferred, result)); + NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, OpenFileCB->cbBase.asyncWork)); + delete OpenFileCB; + OpenFileCB = nullptr; + HILOG_INFO("tag dsa NAPI_OpenFileCB, main event thread complete end."); +} + +napi_value NAPI_CreateFile(napi_env env, napi_callback_info info) +{ + HILOG_INFO("tag dsa %{public}s,called", __func__); + FileAccessHelperCreateFileCB *createFileCB = new (std::nothrow) FileAccessHelperCreateFileCB; + if (createFileCB == nullptr) { + HILOG_ERROR("tag dsa %{public}s, createFileCB == nullptr.", __func__); + return WrapVoidToJS(env); + } + createFileCB->cbBase.cbInfo.env = env; + createFileCB->cbBase.asyncWork = nullptr; + createFileCB->cbBase.deferred = nullptr; + createFileCB->cbBase.ability = nullptr; + + napi_value ret = CreateFileWrap(env, info, createFileCB); + if (ret == nullptr) { + HILOG_ERROR("tag dsa %{public}s,ret == nullptr", __func__); + if (createFileCB != nullptr) { + delete createFileCB; + createFileCB = nullptr; + } + ret = WrapVoidToJS(env); + } + HILOG_INFO("tag dsa %{public}s,end", __func__); + return ret; +} + +napi_value CreateFileWrap(napi_env env, napi_callback_info info, FileAccessHelperCreateFileCB *createFileCB) +{ + HILOG_INFO("tag dsa %{public}s,called", __func__); + size_t argcAsync = ARGS_THREE; + const size_t argcPromise = ARGS_TWO; + const size_t argCountWithAsync = argcPromise + ARGS_ASYNC_COUNT; + napi_value args[ARGS_MAX_COUNT] = {nullptr}; + napi_value ret = 0; + napi_value thisVar = nullptr; + + NAPI_CALL(env, napi_get_cb_info(env, info, &argcAsync, args, &thisVar, nullptr)); + if (argcAsync > argCountWithAsync || argcAsync > ARGS_MAX_COUNT) { + HILOG_ERROR("tag dsa %{public}s, Wrong argument count.", __func__); + return nullptr; + } + + napi_valuetype valuetype = napi_undefined; + NAPI_CALL(env, napi_typeof(env, args[PARAM0], &valuetype)); + if (valuetype == napi_string) { + createFileCB->parentUri = NapiValueToStringUtf8(env, args[PARAM0]); + HILOG_INFO("tag dsa %{public}s,parentUri=%{public}s", __func__, createFileCB->parentUri.c_str()); + } + + NAPI_CALL(env, napi_typeof(env, args[PARAM1], &valuetype)); + if (valuetype == napi_string) { + createFileCB->name = NapiValueToStringUtf8(env, args[PARAM1]); + HILOG_INFO("tag dsa %{public}s,name=%{public}s", __func__, createFileCB->name.c_str()); + } + + FileAccessHelper *objectInfo = nullptr; + napi_unwrap(env, thisVar, (void **)&objectInfo); + HILOG_INFO("tag dsa %{public}s,FileAccessHelper objectInfo", __func__); + createFileCB->fileAccessHelper = objectInfo; + + if (argcAsync > argcPromise) { + ret = CreateFileAsync(env, args, ARGS_TWO, createFileCB); + } else { + ret = CreateFilePromise(env, createFileCB); + } + HILOG_INFO("tag dsa %{public}s,end", __func__); + return ret; +} + +napi_value CreateFileAsync(napi_env env, napi_value *args, const size_t argCallback, FileAccessHelperCreateFileCB *createFileCB) +{ + HILOG_INFO("tag dsa %{public}s, asyncCallback.", __func__); + if (args == nullptr || createFileCB == nullptr) { + HILOG_ERROR("tag dsa %{public}s, param == nullptr.", __func__); + return nullptr; + } + napi_value resourceName = 0; + NAPI_CALL(env, napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName)); + + napi_valuetype valuetype = napi_undefined; + NAPI_CALL(env, napi_typeof(env, args[argCallback], &valuetype)); + if (valuetype == napi_function) { + NAPI_CALL(env, napi_create_reference(env, args[argCallback], 1, &createFileCB->cbBase.cbInfo.callback)); + } + + NAPI_CALL(env, + napi_create_async_work(env, + nullptr, + resourceName, + CreateFileExecuteCB, + CreateFileAsyncCompleteCB, + (void *)createFileCB, + &createFileCB->cbBase.asyncWork)); + NAPI_CALL(env, napi_queue_async_work(env, createFileCB->cbBase.asyncWork)); + napi_value result = 0; + NAPI_CALL(env, napi_get_null(env, &result)); + HILOG_INFO("tag dsa %{public}s, asyncCallback end.", __func__); + return result; +} + +napi_value CreateFilePromise(napi_env env, FileAccessHelperCreateFileCB *createFileCB) +{ + HILOG_INFO("tag dsa %{public}s, promise.", __func__); + if (createFileCB == nullptr) { + HILOG_ERROR("tag dsa %{public}s, param == nullptr.", __func__); + return nullptr; + } + napi_value resourceName; + NAPI_CALL(env, napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName)); + napi_deferred deferred; + napi_value promise = 0; + NAPI_CALL(env, napi_create_promise(env, &deferred, &promise)); + createFileCB->cbBase.deferred = deferred; + + NAPI_CALL(env, + napi_create_async_work(env, + nullptr, + resourceName, + CreateFileExecuteCB, + CreateFilePromiseCompleteCB, + (void *)createFileCB, + &createFileCB->cbBase.asyncWork)); + NAPI_CALL(env, napi_queue_async_work(env, createFileCB->cbBase.asyncWork)); + HILOG_INFO("tag dsa %{public}s, promise end.", __func__); + return promise; +} + +void CreateFileExecuteCB(napi_env env, void *data) +{ + HILOG_INFO("tag dsa NAPI_CreateFile, worker pool thread execute."); + FileAccessHelperCreateFileCB *CreateFileCB = static_cast(data); + if (CreateFileCB->fileAccessHelper != nullptr) { + CreateFileCB->execResult = INVALID_PARAMETER; + if (!CreateFileCB->parentUri.empty()) { + OHOS::Uri parentUri(CreateFileCB->parentUri); + std::string newFile = ""; + OHOS::Uri newFileUri(newFile); + int err = CreateFileCB->fileAccessHelper->CreateFile(parentUri, CreateFileCB->name, newFileUri); + CreateFileCB->result = newFileUri.ToString(); + CreateFileCB->execResult = err; + } else { + HILOG_ERROR("tag dsa NAPI_CreateFile, fileAccessHelper uri is empty"); + } + } else { + HILOG_ERROR("tag dsa NAPI_CreateFile, fileAccessHelper == nullptr"); + } + HILOG_INFO("tag dsa NAPI_CreateFile, worker pool thread execute end."); +} + +void CreateFileAsyncCompleteCB(napi_env env, napi_status status, void *data) +{ + HILOG_INFO("tag dsa NAPI_CreateFile, main event thread complete."); + FileAccessHelperCreateFileCB *CreateFileCB = static_cast(data); + napi_value callback = nullptr; + napi_value undefined = nullptr; + napi_value result[ARGS_TWO] = {nullptr}; + napi_value callResult = nullptr; + NAPI_CALL_RETURN_VOID(env, napi_get_undefined(env, &undefined)); + NAPI_CALL_RETURN_VOID(env, napi_get_reference_value(env, CreateFileCB->cbBase.cbInfo.callback, &callback)); + + result[PARAM0] = GetCallbackErrorValue(env, CreateFileCB->execResult); + NAPI_CALL_RETURN_VOID( + env, napi_create_string_utf8(env, CreateFileCB->result.c_str(), NAPI_AUTO_LENGTH, &result[PARAM1])); + NAPI_CALL_RETURN_VOID(env, napi_call_function(env, undefined, callback, ARGS_TWO, &result[PARAM0], &callResult)); + + if (CreateFileCB->cbBase.cbInfo.callback != nullptr) { + NAPI_CALL_RETURN_VOID(env, napi_delete_reference(env, CreateFileCB->cbBase.cbInfo.callback)); + } + NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, CreateFileCB->cbBase.asyncWork)); + delete CreateFileCB; + CreateFileCB = nullptr; + HILOG_INFO("tag dsa NAPI_CreateFile, main event thread complete end."); +} + +void CreateFilePromiseCompleteCB(napi_env env, napi_status status, void *data) +{ + HILOG_INFO("tag dsa NAPI_CreateFile, main event thread complete."); + FileAccessHelperCreateFileCB *CreateFileCB = static_cast(data); + napi_value result = nullptr; + NAPI_CALL_RETURN_VOID(env, napi_create_string_utf8(env, CreateFileCB->result.c_str(), NAPI_AUTO_LENGTH, &result)); + NAPI_CALL_RETURN_VOID(env, napi_resolve_deferred(env, CreateFileCB->cbBase.deferred, result)); + NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, CreateFileCB->cbBase.asyncWork)); + delete CreateFileCB; + CreateFileCB = nullptr; + HILOG_INFO("tag dsa NAPI_CreateFile, main event thread complete end."); +} + +napi_value NAPI_Mkdir(napi_env env, napi_callback_info info) +{ + HILOG_INFO("tag dsa%{public}s,called", __func__); + FileAccessHelperMkdirCB *mkdirCB = new (std::nothrow) FileAccessHelperMkdirCB; + if (mkdirCB == nullptr) { + HILOG_ERROR("tag dsa%{public}s, mkdirCB == nullptr.", __func__); + return WrapVoidToJS(env); + } + mkdirCB->cbBase.cbInfo.env = env; + mkdirCB->cbBase.asyncWork = nullptr; + mkdirCB->cbBase.deferred = nullptr; + mkdirCB->cbBase.ability = nullptr; + + napi_value ret = MkdirWrap(env, info, mkdirCB); + if (ret == nullptr) { + HILOG_ERROR("tag dsa%{public}s,ret == nullptr", __func__); + if (mkdirCB != nullptr) { + delete mkdirCB; + mkdirCB = nullptr; + } + ret = WrapVoidToJS(env); + } + HILOG_INFO("tag dsa%{public}s,end", __func__); + return ret; +} + +napi_value MkdirWrap(napi_env env, napi_callback_info info, FileAccessHelperMkdirCB *mkdirCB) +{ + HILOG_INFO("tag dsa%{public}s,called", __func__); + size_t argcAsync = ARGS_THREE; + const size_t argcPromise = ARGS_TWO; + const size_t argCountWithAsync = argcPromise + ARGS_ASYNC_COUNT; + napi_value args[ARGS_MAX_COUNT] = {nullptr}; + napi_value ret = 0; + napi_value thisVar = nullptr; + + NAPI_CALL(env, napi_get_cb_info(env, info, &argcAsync, args, &thisVar, nullptr)); + if (argcAsync > argCountWithAsync || argcAsync > ARGS_MAX_COUNT) { + HILOG_ERROR("tag dsa%{public}s, Wrong argument count.", __func__); + return nullptr; + } + + napi_valuetype valuetype = napi_undefined; + NAPI_CALL(env, napi_typeof(env, args[PARAM0], &valuetype)); + if (valuetype == napi_string) { + mkdirCB->parentUri = NapiValueToStringUtf8(env, args[PARAM0]); + HILOG_INFO("tag dsa%{public}s,parentUri=%{public}s", __func__, mkdirCB->parentUri.c_str()); + } + + NAPI_CALL(env, napi_typeof(env, args[PARAM1], &valuetype)); + if (valuetype == napi_string) { + mkdirCB->name = NapiValueToStringUtf8(env, args[PARAM1]); + HILOG_INFO("tag dsa%{public}s,name=%{public}s", __func__, mkdirCB->name.c_str()); + } + + FileAccessHelper *objectInfo = nullptr; + napi_unwrap(env, thisVar, (void **)&objectInfo); + HILOG_INFO("tag dsa%{public}s,FileAccessHelper objectInfo", __func__); + mkdirCB->fileAccessHelper = objectInfo; + + if (argcAsync > argcPromise) { + ret = MkdirAsync(env, args, ARGS_TWO, mkdirCB); + } else { + ret = MkdirPromise(env, mkdirCB); + } + HILOG_INFO("tag dsa%{public}s,end", __func__); + return ret; +} + +napi_value MkdirAsync(napi_env env, napi_value *args, const size_t argCallback, FileAccessHelperMkdirCB *mkdirCB) +{ + HILOG_INFO("tag dsa%{public}s, asyncCallback.", __func__); + if (args == nullptr || mkdirCB == nullptr) { + HILOG_ERROR("tag dsa%{public}s, param == nullptr.", __func__); + return nullptr; + } + napi_value resourceName = 0; + NAPI_CALL(env, napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName)); + + napi_valuetype valuetype = napi_undefined; + NAPI_CALL(env, napi_typeof(env, args[argCallback], &valuetype)); + if (valuetype == napi_function) { + NAPI_CALL(env, napi_create_reference(env, args[argCallback], 1, &mkdirCB->cbBase.cbInfo.callback)); + } + + NAPI_CALL(env, + napi_create_async_work(env, + nullptr, + resourceName, + MkdirExecuteCB, + MkdirAsyncCompleteCB, + (void *)mkdirCB, + &mkdirCB->cbBase.asyncWork)); + NAPI_CALL(env, napi_queue_async_work(env, mkdirCB->cbBase.asyncWork)); + napi_value result = 0; + NAPI_CALL(env, napi_get_null(env, &result)); + HILOG_INFO("tag dsa%{public}s, asyncCallback end.", __func__); + return result; +} + +napi_value MkdirPromise(napi_env env, FileAccessHelperMkdirCB *mkdirCB) +{ + HILOG_INFO("tag dsa%{public}s, promise.", __func__); + if (mkdirCB == nullptr) { + HILOG_ERROR("tag dsa%{public}s, param == nullptr.", __func__); + return nullptr; + } + napi_value resourceName; + NAPI_CALL(env, napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName)); + napi_deferred deferred; + napi_value promise = 0; + NAPI_CALL(env, napi_create_promise(env, &deferred, &promise)); + mkdirCB->cbBase.deferred = deferred; + + NAPI_CALL(env, + napi_create_async_work(env, + nullptr, + resourceName, + MkdirExecuteCB, + MkdirPromiseCompleteCB, + (void *)mkdirCB, + &mkdirCB->cbBase.asyncWork)); + NAPI_CALL(env, napi_queue_async_work(env, mkdirCB->cbBase.asyncWork)); + HILOG_INFO("tag dsa%{public}s, promise end.", __func__); + return promise; +} + +void MkdirExecuteCB(napi_env env, void *data) +{ + HILOG_INFO("tag dsaNAPI_Mkdir, worker pool thread execute."); + FileAccessHelperMkdirCB *MkdirCB = static_cast(data); + if (MkdirCB->fileAccessHelper != nullptr) { + MkdirCB->execResult = INVALID_PARAMETER; + if (!MkdirCB->parentUri.empty()) { + OHOS::Uri parentUri(MkdirCB->parentUri); + std::string newDir = ""; + OHOS::Uri newDirUri(newDir); + int err = MkdirCB->fileAccessHelper->Mkdir(parentUri, MkdirCB->name, newDirUri); + MkdirCB->result = newDirUri.ToString(); + MkdirCB->execResult = err; + } else { + HILOG_ERROR("tag dsaNAPI_Mkdir, fileAccessHelper parentUri is empty"); + } + } else { + HILOG_ERROR("tag dsaNAPI_Mkdir, fileAccessHelper == nullptr"); + } + HILOG_INFO("tag dsaNAPI_Mkdir, worker pool thread execute end."); +} + +void MkdirAsyncCompleteCB(napi_env env, napi_status status, void *data) +{ + HILOG_INFO("tag dsaNAPI_Mkdir, main event thread complete."); + FileAccessHelperMkdirCB *MkdirCB = static_cast(data); + napi_value callback = nullptr; + napi_value undefined = nullptr; + napi_value result[ARGS_TWO] = {nullptr}; + napi_value callResult = nullptr; + NAPI_CALL_RETURN_VOID(env, napi_get_undefined(env, &undefined)); + NAPI_CALL_RETURN_VOID(env, napi_get_reference_value(env, MkdirCB->cbBase.cbInfo.callback, &callback)); + + result[PARAM0] = GetCallbackErrorValue(env, MkdirCB->execResult); + NAPI_CALL_RETURN_VOID( + env, napi_create_string_utf8(env, MkdirCB->result.c_str(), NAPI_AUTO_LENGTH, &result[PARAM1])); + NAPI_CALL_RETURN_VOID(env, napi_call_function(env, undefined, callback, ARGS_TWO, &result[PARAM0], &callResult)); + + if (MkdirCB->cbBase.cbInfo.callback != nullptr) { + NAPI_CALL_RETURN_VOID(env, napi_delete_reference(env, MkdirCB->cbBase.cbInfo.callback)); + } + NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, MkdirCB->cbBase.asyncWork)); + delete MkdirCB; + MkdirCB = nullptr; + HILOG_INFO("tag dsaNAPI_Mkdir, main event thread complete end."); +} + +void MkdirPromiseCompleteCB(napi_env env, napi_status status, void *data) +{ + HILOG_INFO("tag dsaNAPI_Mkdir, main event thread complete."); + FileAccessHelperMkdirCB *MkdirCB = static_cast(data); + napi_value result = nullptr; + NAPI_CALL_RETURN_VOID(env, napi_create_string_utf8(env, MkdirCB->result.c_str(), NAPI_AUTO_LENGTH, &result)); + NAPI_CALL_RETURN_VOID(env, napi_resolve_deferred(env, MkdirCB->cbBase.deferred, result)); + NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, MkdirCB->cbBase.asyncWork)); + delete MkdirCB; + MkdirCB = nullptr; + HILOG_INFO("tag dsaNAPI_Mkdir, main event thread complete end."); +} + +napi_value NAPI_Delete(napi_env env, napi_callback_info info) +{ + HILOG_INFO("tag dsa %{public}s,called", __func__); + FileAccessHelperDeleteCB *deleteCB = new (std::nothrow) FileAccessHelperDeleteCB; + if (deleteCB == nullptr) { + HILOG_ERROR("%{public}s, deleteCB == nullptr.", __func__); + return WrapVoidToJS(env); + } + deleteCB->cbBase.cbInfo.env = env; + deleteCB->cbBase.asyncWork = nullptr; + deleteCB->cbBase.deferred = nullptr; + deleteCB->cbBase.ability = nullptr; + + napi_value ret = DeleteWrap(env, info, deleteCB); + if (ret == nullptr) { + HILOG_ERROR("tag dsa %{public}s,ret == nullptr", __func__); + if (deleteCB != nullptr) { + delete deleteCB; + deleteCB = nullptr; + } + ret = WrapVoidToJS(env); + } + HILOG_INFO("tag dsa %{public}s,end", __func__); + return ret; +} + +napi_value DeleteWrap(napi_env env, napi_callback_info info, FileAccessHelperDeleteCB *deleteCB) +{ + HILOG_INFO("tag dsa %{public}s,called", __func__); + size_t argcAsync = ARGS_TWO; + const size_t argcPromise = ARGS_ONE; + const size_t argCountWithAsync = argcPromise + ARGS_ASYNC_COUNT; + napi_value args[ARGS_MAX_COUNT] = {nullptr}; + napi_value ret = 0; + napi_value thisVar = nullptr; + + NAPI_CALL(env, napi_get_cb_info(env, info, &argcAsync, args, &thisVar, nullptr)); + if (argcAsync > argCountWithAsync || argcAsync > ARGS_MAX_COUNT) { + HILOG_ERROR("tag dsa %{public}s, Wrong argument count.", __func__); + return nullptr; + } + + napi_valuetype valuetype = napi_undefined; + NAPI_CALL(env, napi_typeof(env, args[PARAM0], &valuetype)); + if (valuetype == napi_string) { + deleteCB->selectFileUri = NapiValueToStringUtf8(env, args[PARAM0]); + HILOG_INFO("tag dsa %{public}s,selectFileUri=%{public}s", __func__, deleteCB->selectFileUri.c_str()); + } + + FileAccessHelper *objectInfo = nullptr; + napi_unwrap(env, thisVar, (void **)&objectInfo); + HILOG_INFO("tag dsa %{public}s,FileAccessHelper objectInfo", __func__); + deleteCB->fileAccessHelper = objectInfo; + + if (argcAsync > argcPromise) { + ret = DeleteAsync(env, args, ARGS_ONE, deleteCB); + } else { + ret = DeletePromise(env, deleteCB); + } + HILOG_INFO("tag dsa %{public}s,end", __func__); + return ret; +} + +napi_value DeleteAsync(napi_env env, napi_value *args, const size_t argCallback, FileAccessHelperDeleteCB *deleteCB) +{ + HILOG_INFO("tag dsa %{public}s, asyncCallback.", __func__); + if (args == nullptr || deleteCB == nullptr) { + HILOG_ERROR("tag dsa %{public}s, param == nullptr.", __func__); + return nullptr; + } + napi_value resourceName = 0; + NAPI_CALL(env, napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName)); + + napi_valuetype valuetype = napi_undefined; + NAPI_CALL(env, napi_typeof(env, args[argCallback], &valuetype)); + if (valuetype == napi_function) { + NAPI_CALL(env, napi_create_reference(env, args[argCallback], 1, &deleteCB->cbBase.cbInfo.callback)); + } + + NAPI_CALL(env, + napi_create_async_work(env, + nullptr, + resourceName, + DeleteExecuteCB, + DeleteAsyncCompleteCB, + (void *)deleteCB, + &deleteCB->cbBase.asyncWork)); + NAPI_CALL(env, napi_queue_async_work(env, deleteCB->cbBase.asyncWork)); + napi_value result = 0; + NAPI_CALL(env, napi_get_null(env, &result)); + HILOG_INFO("tag dsa %{public}s, asyncCallback end.", __func__); + return result; +} + +napi_value DeletePromise(napi_env env, FileAccessHelperDeleteCB *deleteCB) +{ + HILOG_INFO("tag dsa %{public}s, promise.", __func__); + if (deleteCB == nullptr) { + HILOG_ERROR("tag dsa %{public}s, param == nullptr.", __func__); + return nullptr; + } + napi_value resourceName; + NAPI_CALL(env, napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName)); + napi_deferred deferred; + napi_value promise = 0; + NAPI_CALL(env, napi_create_promise(env, &deferred, &promise)); + deleteCB->cbBase.deferred = deferred; + + NAPI_CALL(env, + napi_create_async_work(env, + nullptr, + resourceName, + DeleteExecuteCB, + DeletePromiseCompleteCB, + (void *)deleteCB, + &deleteCB->cbBase.asyncWork)); + NAPI_CALL(env, napi_queue_async_work(env, deleteCB->cbBase.asyncWork)); + HILOG_INFO("tag dsa %{public}s, promise end.", __func__); + return promise; +} + +void DeleteExecuteCB(napi_env env, void *data) +{ + HILOG_INFO("tag dsa NAPI_Delete, worker pool thread execute."); + FileAccessHelperDeleteCB *DeleteCB = static_cast(data); + if (DeleteCB->fileAccessHelper != nullptr) { + DeleteCB->execResult = INVALID_PARAMETER; + if (!DeleteCB->selectFileUri.empty()) { + OHOS::Uri selectFileUri(DeleteCB->selectFileUri); + DeleteCB->result = DeleteCB->fileAccessHelper->Delete(selectFileUri); + DeleteCB->execResult = NO_ERROR; + } else { + HILOG_ERROR("tag dsa NAPI_Delete, fileAccessHelper selectFileUri is empty"); + } + } else { + HILOG_ERROR("tag dsa NAPI_Delete, fileAccessHelper == nullptr"); + } + HILOG_INFO("tag dsa NAPI_Delete, worker pool thread execute end."); +} + +void DeleteAsyncCompleteCB(napi_env env, napi_status status, void *data) +{ + HILOG_INFO("tag dsa NAPI_Delete, main event thread complete."); + FileAccessHelperDeleteCB *DeleteCB = static_cast(data); + napi_value callback = nullptr; + napi_value undefined = nullptr; + napi_value result[ARGS_TWO] = {nullptr}; + napi_value callResult = nullptr; + NAPI_CALL_RETURN_VOID(env, napi_get_undefined(env, &undefined)); + NAPI_CALL_RETURN_VOID(env, napi_get_reference_value(env, DeleteCB->cbBase.cbInfo.callback, &callback)); + + result[PARAM0] = GetCallbackErrorValue(env, DeleteCB->execResult); + napi_create_int32(env, DeleteCB->result, &result[PARAM1]); + NAPI_CALL_RETURN_VOID(env, napi_call_function(env, undefined, callback, ARGS_TWO, &result[PARAM0], &callResult)); + + if (DeleteCB->cbBase.cbInfo.callback != nullptr) { + NAPI_CALL_RETURN_VOID(env, napi_delete_reference(env, DeleteCB->cbBase.cbInfo.callback)); + } + NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, DeleteCB->cbBase.asyncWork)); + delete DeleteCB; + DeleteCB = nullptr; + HILOG_INFO("tag dsa NAPI_Delete, main event thread complete end."); +} + +void DeletePromiseCompleteCB(napi_env env, napi_status status, void *data) +{ + HILOG_INFO("tag dsa NAPI_Delete, main event thread complete."); + FileAccessHelperDeleteCB *DeleteCB = static_cast(data); + napi_value result = nullptr; + napi_create_int32(env, DeleteCB->result, &result); + NAPI_CALL_RETURN_VOID(env, napi_resolve_deferred(env, DeleteCB->cbBase.deferred, result)); + NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, DeleteCB->cbBase.asyncWork)); + delete DeleteCB; + DeleteCB = nullptr; + HILOG_INFO("tag dsa NAPI_Delete, main event thread complete end."); +} + +napi_value NAPI_Move(napi_env env, napi_callback_info info) +{ + HILOG_INFO("tag dsa %{public}s,called", __func__); + FileAccessHelperMoveCB *moveCB = new (std::nothrow) FileAccessHelperMoveCB; + if (moveCB == nullptr) { + HILOG_ERROR("tag dsa %{public}s, moveCB == nullptr.", __func__); + return WrapVoidToJS(env); + } + moveCB->cbBase.cbInfo.env = env; + moveCB->cbBase.asyncWork = nullptr; + moveCB->cbBase.deferred = nullptr; + moveCB->cbBase.ability = nullptr; + + napi_value ret = MoveWrap(env, info, moveCB); + if (ret == nullptr) { + HILOG_ERROR("tag dsa %{public}s,ret == nullptr", __func__); + if (moveCB != nullptr) { + delete moveCB; + moveCB = nullptr; + } + ret = WrapVoidToJS(env); + } + HILOG_INFO("tag dsa %{public}s,end", __func__); + return ret; +} + +napi_value MoveWrap(napi_env env, napi_callback_info info, FileAccessHelperMoveCB *moveCB) +{ + HILOG_INFO("tag dsa %{public}s,called", __func__); + size_t argcAsync = ARGS_THREE; + const size_t argcPromise = ARGS_TWO; + const size_t argCountWithAsync = argcPromise + ARGS_ASYNC_COUNT; + napi_value args[ARGS_MAX_COUNT] = {nullptr}; + napi_value ret = 0; + napi_value thisVar = nullptr; + + NAPI_CALL(env, napi_get_cb_info(env, info, &argcAsync, args, &thisVar, nullptr)); + if (argcAsync > argCountWithAsync || argcAsync > ARGS_MAX_COUNT) { + HILOG_ERROR("tag dsa %{public}s, Wrong argument count.", __func__); + return nullptr; + } + + napi_valuetype valuetype = napi_undefined; + NAPI_CALL(env, napi_typeof(env, args[PARAM0], &valuetype)); + if (valuetype == napi_string) { + moveCB->sourceFileUri = NapiValueToStringUtf8(env, args[PARAM0]); + HILOG_INFO("tag dsa %{public}s,sourceFileUri=%{public}s", __func__, moveCB->sourceFileUri.c_str()); + } + + NAPI_CALL(env, napi_typeof(env, args[PARAM1], &valuetype)); + if (valuetype == napi_string) { + moveCB->targetParentUri = NapiValueToStringUtf8(env, args[PARAM1]); + HILOG_INFO("tag dsa %{public}s,targetParentUri=%{public}s", __func__, moveCB->targetParentUri.c_str()); + } + + FileAccessHelper *objectInfo = nullptr; + napi_unwrap(env, thisVar, (void **)&objectInfo); + HILOG_INFO("tag dsa %{public}s,FileAccessHelper objectInfo", __func__); + moveCB->fileAccessHelper = objectInfo; + + if (argcAsync > argcPromise) { + ret = MoveAsync(env, args, ARGS_TWO, moveCB); + } else { + ret = MovePromise(env, moveCB); + } + HILOG_INFO("tag dsa %{public}s,end", __func__); + return ret; +} + +napi_value MoveAsync(napi_env env, napi_value *args, const size_t argCallback, FileAccessHelperMoveCB *moveCB) +{ + HILOG_INFO("tag dsa %{public}s, asyncCallback.", __func__); + if (args == nullptr || moveCB == nullptr) { + HILOG_ERROR("tag dsa %{public}s, param == nullptr.", __func__); + return nullptr; + } + napi_value resourceName = 0; + NAPI_CALL(env, napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName)); + + napi_valuetype valuetype = napi_undefined; + NAPI_CALL(env, napi_typeof(env, args[argCallback], &valuetype)); + if (valuetype == napi_function) { + NAPI_CALL(env, napi_create_reference(env, args[argCallback], 1, &moveCB->cbBase.cbInfo.callback)); + } + + NAPI_CALL(env, + napi_create_async_work(env, + nullptr, + resourceName, + MoveExecuteCB, + MoveAsyncCompleteCB, + (void *)moveCB, + &moveCB->cbBase.asyncWork)); + NAPI_CALL(env, napi_queue_async_work(env, moveCB->cbBase.asyncWork)); + napi_value result = 0; + NAPI_CALL(env, napi_get_null(env, &result)); + HILOG_INFO("tag dsa %{public}s, asyncCallback end.", __func__); + return result; +} + +napi_value MovePromise(napi_env env, FileAccessHelperMoveCB *moveCB) +{ + HILOG_INFO("tag dsa %{public}s, promise.", __func__); + if (moveCB == nullptr) { + HILOG_ERROR("tag dsa %{public}s, param == nullptr.", __func__); + return nullptr; + } + napi_value resourceName; + NAPI_CALL(env, napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName)); + napi_deferred deferred; + napi_value promise = 0; + NAPI_CALL(env, napi_create_promise(env, &deferred, &promise)); + moveCB->cbBase.deferred = deferred; + + NAPI_CALL(env, + napi_create_async_work(env, + nullptr, + resourceName, + MoveExecuteCB, + MovePromiseCompleteCB, + (void *)moveCB, + &moveCB->cbBase.asyncWork)); + NAPI_CALL(env, napi_queue_async_work(env, moveCB->cbBase.asyncWork)); + HILOG_INFO("tag dsa %{public}s, promise end.", __func__); + return promise; +} + +void MoveExecuteCB(napi_env env, void *data) +{ + HILOG_INFO("tag dsa NAPI_Move, worker pool thread execute."); + FileAccessHelperMoveCB *MoveCB = static_cast(data); + if (MoveCB->fileAccessHelper != nullptr) { + MoveCB->execResult = INVALID_PARAMETER; + if (!MoveCB->sourceFileUri.empty()) { + OHOS::Uri sourceFileUri(MoveCB->sourceFileUri); + OHOS::Uri targetParentUri(MoveCB->targetParentUri); + std::string newFile = ""; + OHOS::Uri newFileUri(newFile); + int err = MoveCB->fileAccessHelper->Move(sourceFileUri, targetParentUri, newFileUri); + MoveCB->result = newFileUri.ToString(); + MoveCB->execResult = err; + } else { + HILOG_ERROR("tag dsa NAPI_Move, fileAccessHelper sourceFileUri is empty"); + } + } else { + HILOG_ERROR("tag dsa NAPI_Move, fileAccessHelper == nullptr"); + } + HILOG_INFO("tag dsa NAPI_Move, worker pool thread execute end."); +} + +void MoveAsyncCompleteCB(napi_env env, napi_status status, void *data) +{ + HILOG_INFO("tag dsa NAPI_Move, main event thread complete."); + FileAccessHelperCreateFileCB *MoveCB = static_cast(data); + napi_value callback = nullptr; + napi_value undefined = nullptr; + napi_value result[ARGS_TWO] = {nullptr}; + napi_value callResult = nullptr; + NAPI_CALL_RETURN_VOID(env, napi_get_undefined(env, &undefined)); + NAPI_CALL_RETURN_VOID(env, napi_get_reference_value(env, MoveCB->cbBase.cbInfo.callback, &callback)); + + result[PARAM0] = GetCallbackErrorValue(env, MoveCB->execResult); + NAPI_CALL_RETURN_VOID( + env, napi_create_string_utf8(env, MoveCB->result.c_str(), NAPI_AUTO_LENGTH, &result[PARAM1])); + NAPI_CALL_RETURN_VOID(env, napi_call_function(env, undefined, callback, ARGS_TWO, &result[PARAM0], &callResult)); + + if (MoveCB->cbBase.cbInfo.callback != nullptr) { + NAPI_CALL_RETURN_VOID(env, napi_delete_reference(env, MoveCB->cbBase.cbInfo.callback)); + } + NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, MoveCB->cbBase.asyncWork)); + delete MoveCB; + MoveCB = nullptr; + HILOG_INFO("tag dsa NAPI_Move, main event thread complete end."); +} + +void MovePromiseCompleteCB(napi_env env, napi_status status, void *data) +{ + HILOG_INFO("tag dsa NAPI_Move, main event thread complete."); + FileAccessHelperCreateFileCB *MoveCB = static_cast(data); + napi_value result = nullptr; + NAPI_CALL_RETURN_VOID(env, napi_create_string_utf8(env, MoveCB->result.c_str(), NAPI_AUTO_LENGTH, &result)); + NAPI_CALL_RETURN_VOID(env, napi_resolve_deferred(env, MoveCB->cbBase.deferred, result)); + NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, MoveCB->cbBase.asyncWork)); + delete MoveCB; + MoveCB = nullptr; + HILOG_INFO("tag dsa NAPI_Move, main event thread complete end."); +} + +napi_value NAPI_Rename(napi_env env, napi_callback_info info) +{ + HILOG_INFO("tag dsa %{public}s,called", __func__); + FileAccessHelperRenameCB *renameCB = new (std::nothrow) FileAccessHelperRenameCB; + if (renameCB == nullptr) { + HILOG_ERROR("tag dsa %{public}s, renameCB == nullptr.", __func__); + return WrapVoidToJS(env); + } + renameCB->cbBase.cbInfo.env = env; + renameCB->cbBase.asyncWork = nullptr; + renameCB->cbBase.deferred = nullptr; + renameCB->cbBase.ability = nullptr; + + napi_value ret = RenameWrap(env, info, renameCB); + if (ret == nullptr) { + HILOG_ERROR("tag dsa %{public}s,ret == nullptr", __func__); + if (renameCB != nullptr) { + delete renameCB; + renameCB = nullptr; + } + ret = WrapVoidToJS(env); + } + HILOG_INFO("tag dsa %{public}s,end", __func__); + return ret; +} + +napi_value RenameWrap(napi_env env, napi_callback_info info, FileAccessHelperRenameCB *renameCB) +{ + HILOG_INFO("tag dsa %{public}s,called", __func__); + size_t argcAsync = ARGS_THREE; + const size_t argcPromise = ARGS_TWO; + const size_t argCountWithAsync = argcPromise + ARGS_ASYNC_COUNT; + napi_value args[ARGS_MAX_COUNT] = {nullptr}; + napi_value ret = 0; + napi_value thisVar = nullptr; + + NAPI_CALL(env, napi_get_cb_info(env, info, &argcAsync, args, &thisVar, nullptr)); + if (argcAsync > argCountWithAsync || argcAsync > ARGS_MAX_COUNT) { + HILOG_ERROR("tag dsa %{public}s, Wrong argument count.", __func__); + return nullptr; + } + + napi_valuetype valuetype = napi_undefined; + NAPI_CALL(env, napi_typeof(env, args[PARAM0], &valuetype)); + if (valuetype == napi_string) { + renameCB->sourceFileUri = NapiValueToStringUtf8(env, args[PARAM0]); + HILOG_INFO("tag dsa %{public}s,sourceFileUri=%{public}s", __func__, renameCB->sourceFileUri.c_str()); + } + + NAPI_CALL(env, napi_typeof(env, args[PARAM1], &valuetype)); + if (valuetype == napi_string) { + renameCB->displayName = NapiValueToStringUtf8(env, args[PARAM1]); + HILOG_INFO("tag dsa %{public}s,displayName=%{public}s", __func__, renameCB->displayName.c_str()); + } + + FileAccessHelper *objectInfo = nullptr; + napi_unwrap(env, thisVar, (void **)&objectInfo); + HILOG_INFO("tag dsa %{public}s,FileAccessHelper objectInfo", __func__); + renameCB->fileAccessHelper = objectInfo; + + if (argcAsync > argcPromise) { + ret = RenameAsync(env, args, ARGS_TWO, renameCB); + } else { + ret = RenamePromise(env, renameCB); + } + HILOG_INFO("tag dsa %{public}s,end", __func__); + return ret; +} + +napi_value RenameAsync(napi_env env, napi_value *args, const size_t argCallback, FileAccessHelperRenameCB *renameCB) +{ + HILOG_INFO("tag dsa %{public}s, asyncCallback.", __func__); + if (args == nullptr || renameCB == nullptr) { + HILOG_ERROR("tag dsa %{public}s, param == nullptr.", __func__); + return nullptr; + } + napi_value resourceName = 0; + NAPI_CALL(env, napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName)); + + napi_valuetype valuetype = napi_undefined; + NAPI_CALL(env, napi_typeof(env, args[argCallback], &valuetype)); + if (valuetype == napi_function) { + NAPI_CALL(env, napi_create_reference(env, args[argCallback], 1, &renameCB->cbBase.cbInfo.callback)); + } + + NAPI_CALL(env, + napi_create_async_work(env, + nullptr, + resourceName, + RenameExecuteCB, + RenameAsyncCompleteCB, + (void *)renameCB, + &renameCB->cbBase.asyncWork)); + NAPI_CALL(env, napi_queue_async_work(env, renameCB->cbBase.asyncWork)); + napi_value result = 0; + NAPI_CALL(env, napi_get_null(env, &result)); + HILOG_INFO("tag dsa %{public}s, asyncCallback end.", __func__); + return result; +} + +napi_value RenamePromise(napi_env env, FileAccessHelperRenameCB *renameCB) +{ + HILOG_INFO("tag dsa %{public}s, promise.", __func__); + if (renameCB == nullptr) { + HILOG_ERROR("tag dsa %{public}s, param == nullptr.", __func__); + return nullptr; + } + napi_value resourceName; + NAPI_CALL(env, napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName)); + napi_deferred deferred; + napi_value promise = 0; + NAPI_CALL(env, napi_create_promise(env, &deferred, &promise)); + renameCB->cbBase.deferred = deferred; + + NAPI_CALL(env, + napi_create_async_work(env, + nullptr, + resourceName, + RenameExecuteCB, + RenamePromiseCompleteCB, + (void *)renameCB, + &renameCB->cbBase.asyncWork)); + NAPI_CALL(env, napi_queue_async_work(env, renameCB->cbBase.asyncWork)); + HILOG_INFO("tag dsa %{public}s, promise end.", __func__); + return promise; +} + +void RenameExecuteCB(napi_env env, void *data) +{ + HILOG_INFO("tag dsa NAPI_Rename, worker pool thread execute."); + FileAccessHelperRenameCB *renameCB = static_cast(data); + if (renameCB->fileAccessHelper != nullptr) { + renameCB->execResult = INVALID_PARAMETER; + if (!renameCB->sourceFileUri.empty()) { + OHOS::Uri sourceFileUri(renameCB->sourceFileUri); + std::string newFile = ""; + OHOS::Uri newFileUri(newFile); + int err = renameCB->fileAccessHelper->Rename(sourceFileUri, renameCB->displayName, newFileUri); + renameCB->result = newFileUri.ToString(); + renameCB->execResult = err; + } else { + HILOG_ERROR("tag dsa NAPI_Rename, fileAccessHelper sourceFileUri is empty"); + } + } else { + HILOG_ERROR("tag dsa NAPI_Rename, fileAccessHelper == nullptr"); + } + HILOG_INFO("tag dsa NAPI_Rename, worker pool thread execute end."); +} + +void RenameAsyncCompleteCB(napi_env env, napi_status status, void *data) +{ + HILOG_INFO("tag dsa NAPI_Rename, main event thread complete."); + FileAccessHelperRenameCB *RenameCB = static_cast(data); + napi_value callback = nullptr; + napi_value undefined = nullptr; + napi_value result[ARGS_TWO] = {nullptr}; + napi_value callResult = nullptr; + NAPI_CALL_RETURN_VOID(env, napi_get_undefined(env, &undefined)); + NAPI_CALL_RETURN_VOID(env, napi_get_reference_value(env, RenameCB->cbBase.cbInfo.callback, &callback)); + + result[PARAM0] = GetCallbackErrorValue(env, RenameCB->execResult); + NAPI_CALL_RETURN_VOID( + env, napi_create_string_utf8(env, RenameCB->result.c_str(), NAPI_AUTO_LENGTH, &result[PARAM1])); + NAPI_CALL_RETURN_VOID(env, napi_call_function(env, undefined, callback, ARGS_TWO, &result[PARAM0], &callResult)); + + if (RenameCB->cbBase.cbInfo.callback != nullptr) { + NAPI_CALL_RETURN_VOID(env, napi_delete_reference(env, RenameCB->cbBase.cbInfo.callback)); + } + NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, RenameCB->cbBase.asyncWork)); + delete RenameCB; + RenameCB = nullptr; + HILOG_INFO("tag dsa NAPI_Rename, main event thread complete end."); +} + +void RenamePromiseCompleteCB(napi_env env, napi_status status, void *data) +{ + HILOG_INFO("tag dsa NAPI_Rename, main event thread complete."); + FileAccessHelperRenameCB *RenameCB = static_cast(data); + napi_value result = nullptr; + NAPI_CALL_RETURN_VOID(env, napi_create_string_utf8(env, RenameCB->result.c_str(), NAPI_AUTO_LENGTH, &result)); + NAPI_CALL_RETURN_VOID(env, napi_resolve_deferred(env, RenameCB->cbBase.deferred, result)); + NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, RenameCB->cbBase.asyncWork)); + delete RenameCB; + RenameCB = nullptr; + HILOG_INFO("tag dsa NAPI_Rename, main event thread complete end."); +} + +napi_value NAPI_CloseFile(napi_env env, napi_callback_info info) +{ + HILOG_INFO("tag dsa %{public}s,called", __func__); + FileAccessHelperCloseFileCB *closeFileCB = new (std::nothrow) FileAccessHelperCloseFileCB; + if (closeFileCB == nullptr) { + HILOG_ERROR("%{public}s, closeFileCB == nullptr.", __func__); + return WrapVoidToJS(env); + } + closeFileCB->cbBase.cbInfo.env = env; + closeFileCB->cbBase.asyncWork = nullptr; + closeFileCB->cbBase.deferred = nullptr; + closeFileCB->cbBase.ability = nullptr; + + napi_value ret = CloseFileWrap(env, info, closeFileCB); + if (ret == nullptr) { + HILOG_ERROR("tag dsa %{public}s,ret == nullptr", __func__); + if (closeFileCB != nullptr) { + delete closeFileCB; + closeFileCB = nullptr; + } + ret = WrapVoidToJS(env); + } + HILOG_INFO("tag dsa %{public}s,end", __func__); + return ret; +} + +napi_value CloseFileWrap(napi_env env, napi_callback_info info, FileAccessHelperCloseFileCB *closeFileCB) +{ + HILOG_INFO("tag dsa %{public}s,called", __func__); + size_t argcAsync = ARGS_THREE; + const size_t argcPromise = ARGS_TWO; + const size_t argCountWithAsync = argcPromise + ARGS_ASYNC_COUNT; + napi_value args[ARGS_MAX_COUNT] = {nullptr}; + napi_value ret = 0; + napi_value thisVar = nullptr; + + NAPI_CALL(env, napi_get_cb_info(env, info, &argcAsync, args, &thisVar, nullptr)); + if (argcAsync > argCountWithAsync || argcAsync > ARGS_MAX_COUNT) { + HILOG_ERROR("tag dsa %{public}s, Wrong argument count.", __func__); + return nullptr; + } + + napi_valuetype valuetype = napi_undefined; + NAPI_CALL(env, napi_typeof(env, args[PARAM0], &valuetype)); + if (valuetype == napi_number) { + closeFileCB->fd = NapiValueToInt32Utf8(env, args[PARAM0]); + HILOG_INFO("tag dsa %{public}s,fd=%d", __func__, closeFileCB->fd); + } + + NAPI_CALL(env, napi_typeof(env, args[PARAM1], &valuetype)); + if (valuetype == napi_string) { + closeFileCB->uri = NapiValueToStringUtf8(env, args[PARAM1]); + HILOG_INFO("tag dsa %{public}s,uri=%{public}s", __func__, closeFileCB->uri.c_str()); + } + + FileAccessHelper *objectInfo = nullptr; + napi_unwrap(env, thisVar, (void **)&objectInfo); + HILOG_INFO("tag dsa %{public}s,FileAccessHelper objectInfo", __func__); + closeFileCB->fileAccessHelper = objectInfo; + + if (argcAsync > argcPromise) { + ret = CloseFileAsync(env, args, ARGS_TWO, closeFileCB); + } else { + ret = CloseFilePromise(env, closeFileCB); + } + HILOG_INFO("tag dsa %{public}s,end", __func__); + return ret; +} + +napi_value CloseFileAsync(napi_env env, napi_value *args, const size_t argCallback, FileAccessHelperCloseFileCB *closeFileCB) +{ + HILOG_INFO("tag dsa %{public}s, asyncCallback.", __func__); + if (args == nullptr || closeFileCB == nullptr) { + HILOG_ERROR("tag dsa %{public}s, param == nullptr.", __func__); + return nullptr; + } + napi_value resourceName = 0; + NAPI_CALL(env, napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName)); + + napi_valuetype valuetype = napi_undefined; + NAPI_CALL(env, napi_typeof(env, args[argCallback], &valuetype)); + if (valuetype == napi_function) { + NAPI_CALL(env, napi_create_reference(env, args[argCallback], 1, &closeFileCB->cbBase.cbInfo.callback)); + } + + NAPI_CALL(env, + napi_create_async_work(env, + nullptr, + resourceName, + CloseFileExecuteCB, + CloseFileAsyncCompleteCB, + (void *)closeFileCB, + &closeFileCB->cbBase.asyncWork)); + NAPI_CALL(env, napi_queue_async_work(env, closeFileCB->cbBase.asyncWork)); + napi_value result = 0; + NAPI_CALL(env, napi_get_null(env, &result)); + HILOG_INFO("tag dsa %{public}s, asyncCallback end.", __func__); + return result; +} + +napi_value CloseFilePromise(napi_env env, FileAccessHelperCloseFileCB *closeFileCB) +{ + HILOG_INFO("tag dsa %{public}s, promise.", __func__); + if (closeFileCB == nullptr) { + HILOG_ERROR("tag dsa %{public}s, param == nullptr.", __func__); + return nullptr; + } + napi_value resourceName; + NAPI_CALL(env, napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName)); + napi_deferred deferred; + napi_value promise = 0; + NAPI_CALL(env, napi_create_promise(env, &deferred, &promise)); + closeFileCB->cbBase.deferred = deferred; + + NAPI_CALL(env, + napi_create_async_work(env, + nullptr, + resourceName, + CloseFileExecuteCB, + CloseFilePromiseCompleteCB, + (void *)closeFileCB, + &closeFileCB->cbBase.asyncWork)); + NAPI_CALL(env, napi_queue_async_work(env, closeFileCB->cbBase.asyncWork)); + HILOG_INFO("tag dsa %{public}s, promise end.", __func__); + return promise; +} + +void CloseFileExecuteCB(napi_env env, void *data) +{ + HILOG_INFO("tag dsa NAPI_CloseFile, worker pool thread execute."); + FileAccessHelperCloseFileCB *CloseFileCB = static_cast(data); + if (CloseFileCB->fileAccessHelper != nullptr) { + CloseFileCB->execResult = INVALID_PARAMETER; + if (CloseFileCB->fd!=NO_ERROR) { + CloseFileCB->result = CloseFileCB->fileAccessHelper->CloseFile(CloseFileCB->fd, CloseFileCB->uri); + CloseFileCB->execResult = NO_ERROR; + } else { + HILOG_ERROR("tag dsa NAPI_CloseFile, fileAccessHelper fd != NO_ERROR"); + } + } else { + HILOG_ERROR("tag dsa NAPI_CloseFile, fileAccessHelper == nullptr"); + } + HILOG_INFO("tag dsa NAPI_CloseFile, worker pool thread execute end."); +} + +void CloseFileAsyncCompleteCB(napi_env env, napi_status status, void *data) +{ + HILOG_INFO("tag dsa NAPI_CloseFile, main event thread complete."); + FileAccessHelperCloseFileCB *CloseFileCB = static_cast(data); + napi_value callback = nullptr; + napi_value undefined = nullptr; + napi_value result[ARGS_TWO] = {nullptr}; + napi_value callResult = nullptr; + NAPI_CALL_RETURN_VOID(env, napi_get_undefined(env, &undefined)); + NAPI_CALL_RETURN_VOID(env, napi_get_reference_value(env, CloseFileCB->cbBase.cbInfo.callback, &callback)); + + result[PARAM0] = GetCallbackErrorValue(env, CloseFileCB->execResult); + napi_create_int32(env, CloseFileCB->result, &result[PARAM1]); + NAPI_CALL_RETURN_VOID(env, napi_call_function(env, undefined, callback, ARGS_TWO, &result[PARAM0], &callResult)); + + if (CloseFileCB->cbBase.cbInfo.callback != nullptr) { + NAPI_CALL_RETURN_VOID(env, napi_delete_reference(env, CloseFileCB->cbBase.cbInfo.callback)); + } + NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, CloseFileCB->cbBase.asyncWork)); + delete CloseFileCB; + CloseFileCB = nullptr; + HILOG_INFO("tag dsa NAPI_CloseFile, main event thread complete end."); +} + +void CloseFilePromiseCompleteCB(napi_env env, napi_status status, void *data) +{ + HILOG_INFO("tag dsa NAPI_CloseFile, main event thread complete."); + FileAccessHelperCloseFileCB *CloseFileCB = static_cast(data); + napi_value result = nullptr; + napi_create_int32(env, CloseFileCB->result, &result); + NAPI_CALL_RETURN_VOID(env, napi_resolve_deferred(env, CloseFileCB->cbBase.deferred, result)); + NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, CloseFileCB->cbBase.asyncWork)); + delete CloseFileCB; + CloseFileCB = nullptr; + HILOG_INFO("tag dsa NAPI_CloseFile, main event thread complete end."); +} + +napi_value NAPI_Release(napi_env env, napi_callback_info info) +{ + HILOG_INFO("tag dsa %{public}s,called", __func__); + FileAccessHelperReleaseCB *releaseCB = new (std::nothrow) FileAccessHelperReleaseCB; + if (releaseCB == nullptr) { + HILOG_ERROR("tag dsa %{public}s, releaseCB == nullptr.", __func__); + return WrapVoidToJS(env); + } + releaseCB->cbBase.cbInfo.env = env; + releaseCB->cbBase.asyncWork = nullptr; + releaseCB->cbBase.deferred = nullptr; + + napi_value ret = ReleaseWrap(env, info, releaseCB); + if (ret == nullptr) { + HILOG_ERROR("tag dsa %{public}s,ret == nullptr", __func__); + delete releaseCB; + releaseCB = nullptr; + ret = WrapVoidToJS(env); + } + HILOG_INFO("tag dsa %{public}s,end", __func__); + return ret; +} + +napi_value ReleaseWrap(napi_env env, napi_callback_info info, FileAccessHelperReleaseCB *releaseCB) +{ + HILOG_INFO("tag dsa %{public}s,called", __func__); + size_t argcAsync = ARGS_ONE; + const size_t argcPromise = ARGS_ZERO; + const size_t argCountWithAsync = argcPromise + ARGS_ASYNC_COUNT; + napi_value args[ARGS_MAX_COUNT] = {nullptr}; + napi_value ret = nullptr; + napi_value thisVar = nullptr; + + NAPI_CALL(env, napi_get_cb_info(env, info, &argcAsync, args, &thisVar, nullptr)); + if (argcAsync > argCountWithAsync || argcAsync > ARGS_MAX_COUNT) { + HILOG_ERROR("tag dsa %{public}s, Wrong argument count.", __func__); + return nullptr; + } + + FileAccessHelper *objectInfo = nullptr; + napi_unwrap(env, thisVar, (void **)&objectInfo); + HILOG_INFO("tag dsa FileAccessHelper ReleaseWrap objectInfo = %{public}p", objectInfo); + releaseCB->fileAccessHelper = objectInfo; + + if (argcAsync > argcPromise) { + ret = ReleaseAsync(env, args, PARAM0, releaseCB); + } else { + ret = ReleasePromise(env, releaseCB); + } + HILOG_INFO("tag dsa %{public}s,end", __func__); + return ret; +} + +napi_value ReleaseAsync(napi_env env, napi_value *args, const size_t argCallback, FileAccessHelperReleaseCB *releaseCB) +{ + HILOG_INFO("tag dsa %{public}s, asyncCallback.", __func__); + if (args == nullptr || releaseCB == nullptr) { + HILOG_ERROR("tag dsa %{public}s, param == nullptr.", __func__); + return nullptr; + } + napi_value resourceName = 0; + NAPI_CALL(env, napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName)); + + napi_valuetype valuetype = napi_undefined; + NAPI_CALL(env, napi_typeof(env, args[argCallback], &valuetype)); + if (valuetype == napi_function) { + NAPI_CALL(env, napi_create_reference(env, args[argCallback], 1, &releaseCB->cbBase.cbInfo.callback)); + } + + NAPI_CALL(env, + napi_create_async_work(env, + nullptr, + resourceName, + ReleaseExecuteCB, + ReleaseAsyncCompleteCB, + (void *)releaseCB, + &releaseCB->cbBase.asyncWork)); + NAPI_CALL(env, napi_queue_async_work(env, releaseCB->cbBase.asyncWork)); + napi_value result = 0; + NAPI_CALL(env, napi_get_null(env, &result)); + HILOG_INFO("tag dsa %{public}s, asyncCallback end.", __func__); + return result; +} + +napi_value ReleasePromise(napi_env env, FileAccessHelperReleaseCB *releaseCB) +{ + HILOG_INFO("tag dsa %{public}s, promise.", __func__); + if (releaseCB == nullptr) { + HILOG_ERROR("tag dsa %{public}s, param == nullptr.", __func__); + return nullptr; + } + napi_value resourceName; + NAPI_CALL(env, napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName)); + napi_deferred deferred; + napi_value promise = 0; + NAPI_CALL(env, napi_create_promise(env, &deferred, &promise)); + releaseCB->cbBase.deferred = deferred; + + NAPI_CALL(env, + napi_create_async_work(env, + nullptr, + resourceName, + ReleaseExecuteCB, + ReleasePromiseCompleteCB, + (void *)releaseCB, + &releaseCB->cbBase.asyncWork)); + NAPI_CALL(env, napi_queue_async_work(env, releaseCB->cbBase.asyncWork)); + HILOG_INFO("tag dsa %{public}s, promise end.", __func__); + return promise; +} + +void ReleaseExecuteCB(napi_env env, void *data) +{ + HILOG_INFO("tag dsa NAPI_Release, worker pool thread execute."); + FileAccessHelperReleaseCB *releaseCB = static_cast(data); + if (releaseCB->fileAccessHelper != nullptr) { + releaseCB->result = releaseCB->fileAccessHelper->Release(); + } else { + HILOG_ERROR("tag dsa NAPI_Release, fileAccessHelper == nullptr"); + } + HILOG_INFO("tag dsa NAPI_Release, worker pool thread execute end."); +} + +void ReleaseAsyncCompleteCB(napi_env env, napi_status status, void *data) +{ + HILOG_INFO("tag dsa NAPI_Release, main event thread complete."); + FileAccessHelperReleaseCB *releaseCB = static_cast(data); + napi_value callback = nullptr; + napi_value undefined = nullptr; + napi_value result[ARGS_TWO] = {nullptr}; + napi_value callResult = nullptr; + NAPI_CALL_RETURN_VOID(env, napi_get_undefined(env, &undefined)); + NAPI_CALL_RETURN_VOID(env, napi_get_reference_value(env, releaseCB->cbBase.cbInfo.callback, &callback)); + + result[PARAM0] = GetCallbackErrorValue(env, NO_ERROR); + napi_get_boolean(env, releaseCB->result, &result[PARAM1]); + NAPI_CALL_RETURN_VOID(env, napi_call_function(env, undefined, callback, ARGS_TWO, &result[PARAM0], &callResult)); + + if (releaseCB->cbBase.cbInfo.callback != nullptr) { + NAPI_CALL_RETURN_VOID(env, napi_delete_reference(env, releaseCB->cbBase.cbInfo.callback)); + } + NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, releaseCB->cbBase.asyncWork)); + delete releaseCB; + releaseCB = nullptr; + HILOG_INFO("tag dsa NAPI_Release, main event thread complete end."); +} + +void ReleasePromiseCompleteCB(napi_env env, napi_status status, void *data) +{ + HILOG_INFO("tag dsa NAPI_Release, main event thread complete."); + FileAccessHelperReleaseCB *releaseCB = static_cast(data); + napi_value result = nullptr; + napi_get_boolean(env, releaseCB->result, &result); + NAPI_CALL_RETURN_VOID(env, napi_resolve_deferred(env, releaseCB->cbBase.deferred, result)); + NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, releaseCB->cbBase.asyncWork)); + delete releaseCB; + releaseCB = nullptr; + HILOG_INFO("tag dsa NAPI_Release, main event thread complete end."); +} +} // namespace AppExecFwk +} // namespace OHOS \ 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..aa9348d7732e9cae386d8d59581dc128fa46de5a --- /dev/null +++ b/interfaces/kits/napi/file_access_module/napi_fileaccess_helper.h @@ -0,0 +1,90 @@ +/* + * 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_NAPI_H +#define FILE_ACCESS_NAPI_H + +#include "file_access_common.h" + +namespace OHOS { +namespace AppExecFwk { + 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_CloseFile(napi_env env, napi_callback_info info); + napi_value CloseFileWrap(napi_env env, napi_callback_info info, FileAccessHelperCloseFileCB *closeFileCB); + napi_value CloseFileAsync(napi_env env, napi_value *args, const size_t argCallback, FileAccessHelperCloseFileCB *closeFileCB); + napi_value CloseFilePromise(napi_env env, FileAccessHelperCloseFileCB *closeFileCB); + void CloseFileExecuteCB(napi_env env, void *data); + void CloseFileAsyncCompleteCB(napi_env env, napi_status status, void *data); + void CloseFilePromiseCompleteCB(napi_env env, napi_status status, void *data); + + napi_value NAPI_Release(napi_env env, napi_callback_info info); + napi_value ReleaseWrap(napi_env env, napi_callback_info info, FileAccessHelperReleaseCB *releaseCB); + napi_value ReleaseAsync(napi_env env, napi_value *args, const size_t argCallback, FileAccessHelperReleaseCB *releaseCB); + napi_value ReleasePromise(napi_env env, FileAccessHelperReleaseCB *releaseCB); + void ReleaseExecuteCB(napi_env env, void *data); + void ReleaseAsyncCompleteCB(napi_env env, napi_status status, void *data); + void ReleasePromiseCompleteCB(napi_env env, napi_status status, void *data); +} +} +#endif \ 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..22d41c9696717b7253a7aadebc89696d44e2aa3f --- /dev/null +++ b/interfaces/kits/napi/file_access_module/native_fileaccess_module.cpp @@ -0,0 +1,62 @@ +/* + * 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 "napi_fileaccess_helper.h" +#include "napi/native_api.h" +#include "napi/native_node_api.h" +#include "hilog_wrapper.h" +using namespace std; + +namespace OHOS { + +namespace AppExecFwk { +EXTERN_C_START +/* + * The module initialization. + */ +static napi_value Init(napi_env env, napi_value exports) +{ + HILOG_INFO("tag dsa %{public}s,called", __func__); + FileAccessHelperInit(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) +{ + HILOG_INFO("tag dsa %{public}s,called", __func__); + napi_module_register(&_module); +} +} +} // namespace OHOS \ No newline at end of file diff --git a/interfaces/kits/napi/file_ext_ability/BUILD.gn b/interfaces/kits/napi/file_ext_ability/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..b0e794e8343d5ca28a9d0a3a9f38d881b7a27f4c --- /dev/null +++ b/interfaces/kits/napi/file_ext_ability/BUILD.gn @@ -0,0 +1,50 @@ +# 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("//ark/ts2abc/ts2panda/ts2abc_config.gni") +import("//build/ohos.gni") + +ts2abc_gen_abc("gen_file_ext_ability_abc") { + src_js = rebase_path("file_ext_ability.js") + dst_file = rebase_path(target_out_dir + "/file_ext_ability.abc") + in_puts = [ "file_ext_ability.js" ] + out_puts = [ target_out_dir + "/file_ext_ability.abc" ] + extra_args = [ "--module" ] +} + +gen_js_obj("file_ext_ability_js") { + input = "file_ext_ability.js" + output = target_out_dir + "/file_ext_ability.o" +} + +gen_js_obj("file_ext_ability_abc") { + input = get_label_info(":gen_file_ext_ability_abc", "target_out_dir") + + "/file_ext_ability.abc" + output = target_out_dir + "/file_ext_ability_abc.o" + dep = ":gen_file_ext_ability_abc" +} + +ohos_shared_library("fileextensionability_napi") { + sources = [ "file_ext_ability_module.cpp" ] + + deps = [ + ":file_ext_ability_abc", + ":file_ext_ability_js", + ] + + external_deps = [ "napi:ace_napi" ] + + relative_install_dir = "module/application" + subsystem_name = "filemanagement" + part_name = "user_file_service" +} diff --git a/interfaces/kits/napi/file_ext_ability/file_ext_ability.js b/interfaces/kits/napi/file_ext_ability/file_ext_ability.js new file mode 100644 index 0000000000000000000000000000000000000000..7ecdc1bccb004dc2557b0d61b71ee7e455929e1c --- /dev/null +++ b/interfaces/kits/napi/file_ext_ability/file_ext_ability.js @@ -0,0 +1,52 @@ +/* + * 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. + */ + +class FileExtensionAbility { + onCreate(want) { + console.log('js c++ tag dsa onCreate, want:' + want.abilityName); + } + + openFile(uri, mode) { + console.log('js c++ tag dsa openFile, uri:' + uri + ',mode: ' + mode); + return 0; + } + + createFile(parentUri, displayName) { + console.log('js c++ tag dsa CreateFile, parentUri:' + parentUri + ',displayName:' + displayName ); + return "filetest://fileext.share/temp/test/CreateFile000.txt"; + } + + mkdir(parentUri, displayName) { + console.log('js c++ tag dsa mkdir, parentUri:' + parentUri + ',displayName:' + displayName); + return "filetest://fileext.share/temp/test/Mkdir000"; + } + + delete(sourceFileUri) { + console.log('js c++ tag dsa delete, sourceFileUri:' + sourceFileUri); + return 0; + } + + move(sourceFileUri, targetParentUri) { + console.log('js c++ tag dsa move, sourceFileUri:' + sourceFileUri + ',targetParentUri:' + targetParentUri); + return "filetest://fileext.share/temp/test/move000.xl"; + } + + rename(sourceFileUri, displayName) { + console.log('js c++ tag dsa rename, sourceFileUri:' + sourceFileUri + ',displayName:' + displayName); + return "filetest://fileext.share/temp/test/rename000.ttt"; + } +} + +export default FileExtensionAbility \ No newline at end of file diff --git a/interfaces/kits/napi/file_ext_ability/file_ext_ability_module.cpp b/interfaces/kits/napi/file_ext_ability/file_ext_ability_module.cpp new file mode 100644 index 0000000000000000000000000000000000000000..6dca96b582bb8bf7270b2888fb4b7b921b96d386 --- /dev/null +++ b/interfaces/kits/napi/file_ext_ability/file_ext_ability_module.cpp @@ -0,0 +1,57 @@ +/* + * 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 "native_engine/native_engine.h" + +extern const char _binary_file_ext_ability_js_start[]; +extern const char _binary_file_ext_ability_js_end[]; +extern const char _binary_file_ext_ability_abc_start[]; +extern const char _binary_file_ext_ability_abc_end[]; + +extern "C" __attribute__((constructor)) +void NAPI_application_FileExtensionAbility_AutoRegister() +{ + auto moduleManager = NativeModuleManager::GetInstance(); + NativeModule newModuleInfo = { + .name = "application.FileExtensionAbility", + .fileName = "application/libfileextensionability_napi.so/FileExtensionAbility.js", + }; + + moduleManager->Register(&newModuleInfo); +} + +extern "C" __attribute__((visibility("default"))) +void NAPI_application_FileExtensionAbility_GetJSCode(const char **buf, int *bufLen) +{ + if (buf != nullptr) { + *buf = _binary_file_ext_ability_js_start; + } + + if (bufLen != nullptr) { + *bufLen = _binary_file_ext_ability_js_end - _binary_file_ext_ability_js_start; + } +} + +// file extension ability JS register +extern "C" __attribute__((visibility("default"))) +void NAPI_application_FileExtensionAbility_GetABCCode(const char **buf, int *buflen) +{ + if (buf != nullptr) { + *buf = _binary_file_ext_ability_abc_start; + } + if (buflen != nullptr) { + *buflen = _binary_file_ext_ability_abc_end - _binary_file_ext_ability_abc_start; + } +} \ No newline at end of file diff --git a/utils/hilog_wrapper.h b/utils/hilog_wrapper.h new file mode 100644 index 0000000000000000000000000000000000000000..a070b12e42b608cc1d3b1e37a08ca5be599b899e --- /dev/null +++ b/utils/hilog_wrapper.h @@ -0,0 +1,83 @@ +/* + * 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 HILOG_WRAPPER_H +#define HILOG_WRAPPER_H + +#define CONFIG_HILOG +#ifdef CONFIG_HILOG +#include "hilog/log.h" + +#ifdef HILOG_FATAL +#undef HILOG_FATAL +#endif + +#ifdef HILOG_ERROR +#undef HILOG_ERROR +#endif + +#ifdef HILOG_WARN +#undef HILOG_WARN +#endif + +#ifdef HILOG_INFO +#undef HILOG_INFO +#endif + +#ifdef HILOG_DEBUG +#undef HILOG_DEBUG +#endif + +#ifndef AMS_LOG_DOMAIN +#define AMS_LOG_DOMAIN 0xD00430A +#endif + +#ifndef AMS_LOG_TAG +#define AMS_LOG_TAG "FileAccessFrameworks" +#endif + +#ifdef LOG_LABEL +#undef LOG_LABEL +#endif + +static constexpr OHOS::HiviewDFX::HiLogLabel LOG_LABEL = {LOG_CORE, AMS_LOG_DOMAIN, AMS_LOG_TAG}; + +#define __FILENAME__ (__builtin_strrchr(__FILE__, '/') ? __builtin_strrchr(__FILE__, '/') + 1 : __FILE__) + +#define HILOG_FATAL(fmt, ...) \ + (void)OHOS::HiviewDFX::HiLog::Fatal( \ + LOG_LABEL, "[%{public}s(%{public}s:%{public}d)]" fmt, __FILENAME__, __FUNCTION__, __LINE__, ##__VA_ARGS__) +#define HILOG_ERROR(fmt, ...) \ + (void)OHOS::HiviewDFX::HiLog::Error( \ + LOG_LABEL, "[%{public}s(%{public}s:%{public}d)]" fmt, __FILENAME__, __FUNCTION__, __LINE__, ##__VA_ARGS__) +#define HILOG_WARN(fmt, ...) \ + (void)OHOS::HiviewDFX::HiLog::Warn( \ + LOG_LABEL, "[%{public}s(%{public}s:%{public}d)]" fmt, __FILENAME__, __FUNCTION__, __LINE__, ##__VA_ARGS__) +#define HILOG_INFO(fmt, ...) \ + (void)OHOS::HiviewDFX::HiLog::Info( \ + LOG_LABEL, "[%{public}s(%{public}s:%{public}d)]" fmt, __FILENAME__, __FUNCTION__, __LINE__, ##__VA_ARGS__) +#define HILOG_DEBUG(fmt, ...) \ + (void)OHOS::HiviewDFX::HiLog::Debug( \ + LOG_LABEL, "[%{public}s(%{public}s:%{public}d)]" fmt, __FILENAME__, __FUNCTION__, __LINE__, ##__VA_ARGS__) +#else + +#define HILOG_FATAL(...) +#define HILOG_ERROR(...) +#define HILOG_WARN(...) +#define HILOG_INFO(...) +#define HILOG_DEBUG(...) +#endif // CONFIG_HILOG + +#endif // HILOG_WRAPPER_H \ No newline at end of file