140f5d65dSopenharmony_ci/* 240f5d65dSopenharmony_ci * Copyright (c) 2023-2024 Huawei Device Co., Ltd. 340f5d65dSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 440f5d65dSopenharmony_ci * you may not use this file except in compliance with the License. 540f5d65dSopenharmony_ci * You may obtain a copy of the License at 640f5d65dSopenharmony_ci * 740f5d65dSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 840f5d65dSopenharmony_ci * 940f5d65dSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1040f5d65dSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1140f5d65dSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1240f5d65dSopenharmony_ci * See the License for the specific language governing permissions and 1340f5d65dSopenharmony_ci * limitations under the License. 1440f5d65dSopenharmony_ci */ 1540f5d65dSopenharmony_ci 1640f5d65dSopenharmony_ci#include <memory> 1740f5d65dSopenharmony_ci#include <vector> 1840f5d65dSopenharmony_ci 1940f5d65dSopenharmony_ci#include "filemgmt_libhilog.h" 2040f5d65dSopenharmony_ci#include "filemgmt_libn.h" 2140f5d65dSopenharmony_ci#include "prop_n_exporter.h" 2240f5d65dSopenharmony_ci#include "session_backup_n_exporter.h" 2340f5d65dSopenharmony_ci#include "session_incremental_backup_n_exporter.h" 2440f5d65dSopenharmony_ci#include "session_restore_n_exporter.h" 2540f5d65dSopenharmony_ci 2640f5d65dSopenharmony_cinamespace OHOS::FileManagement::Backup { 2740f5d65dSopenharmony_ciusing namespace std; 2840f5d65dSopenharmony_ciusing namespace LibN; 2940f5d65dSopenharmony_ci 3040f5d65dSopenharmony_cistatic napi_value Export(napi_env env, napi_value exports) 3140f5d65dSopenharmony_ci{ 3240f5d65dSopenharmony_ci std::vector<unique_ptr<NExporter>> products; 3340f5d65dSopenharmony_ci products.emplace_back(make_unique<PropNExporter>(env, exports)); 3440f5d65dSopenharmony_ci products.emplace_back(make_unique<SessionBackupNExporter>(env, exports)); 3540f5d65dSopenharmony_ci products.emplace_back(make_unique<SessionRestoreNExporter>(env, exports)); 3640f5d65dSopenharmony_ci products.emplace_back(make_unique<SessionIncrementalBackupNExporter>(env, exports)); 3740f5d65dSopenharmony_ci for (auto &&product : products) { 3840f5d65dSopenharmony_ci if (!product->Export()) { 3940f5d65dSopenharmony_ci HILOGE("INNER BUG. Failed to export class %{public}s for module file.backup", 4040f5d65dSopenharmony_ci product->GetClassName().c_str()); 4140f5d65dSopenharmony_ci return nullptr; 4240f5d65dSopenharmony_ci } else { 4340f5d65dSopenharmony_ci HILOGI("Class %{public}s for module file.backup has been exported", product->GetClassName().c_str()); 4440f5d65dSopenharmony_ci } 4540f5d65dSopenharmony_ci } 4640f5d65dSopenharmony_ci return exports; 4740f5d65dSopenharmony_ci} 4840f5d65dSopenharmony_ci 4940f5d65dSopenharmony_cistatic napi_module _module = { 5040f5d65dSopenharmony_ci .nm_version = 1, 5140f5d65dSopenharmony_ci .nm_flags = 0, 5240f5d65dSopenharmony_ci .nm_filename = nullptr, 5340f5d65dSopenharmony_ci .nm_register_func = Export, 5440f5d65dSopenharmony_ci .nm_modname = "file.backup", 5540f5d65dSopenharmony_ci .nm_priv = ((void *)0), 5640f5d65dSopenharmony_ci .reserved = {0} 5740f5d65dSopenharmony_ci}; 5840f5d65dSopenharmony_ci 5940f5d65dSopenharmony_ciextern "C" __attribute__((constructor)) void RegisterModule(void) 6040f5d65dSopenharmony_ci{ 6140f5d65dSopenharmony_ci napi_module_register(&_module); 6240f5d65dSopenharmony_ci} 6340f5d65dSopenharmony_ci} // namespace OHOS::FileManagement::Backup