1 /*
2 * Copyright (c) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include <memory>
17 #include <vector>
18
19 #include "../common/log.h"
20 #include "class_file/file_n_exporter.h"
21 #include "class_stat_v9/stat_n_exporter_v9.h"
22 #include "common_func.h"
23 #include "properties/prop_n_exporter_v9.h"
24
25 using namespace std;
26
27 namespace OHOS {
28 namespace DistributedFS {
29 namespace ModuleFileIO {
Export(napi_env env,napi_value exports)30 static napi_value Export(napi_env env, napi_value exports)
31 {
32 InitOpenMode(env, exports);
33 std::vector<unique_ptr<NExporter>> products;
34 products.emplace_back(make_unique<PropNExporterV9>(env, exports));
35 products.emplace_back(make_unique<FileNExporter>(env, exports));
36 products.emplace_back(make_unique<StatNExporterV9>(env, exports));
37
38 for (auto &&product : products) {
39 if (!product->Export()) {
40 HILOGE("INNER BUG. Failed to export class %{public}s for module fileio", product->GetClassName().c_str());
41 return nullptr;
42 } else {
43 HILOGE("Class %{public}s for module fileio has been exported", product->GetClassName().c_str());
44 }
45 }
46 return exports;
47 }
48
49 NAPI_MODULE(fs, Export)
50 } // namespace ModuleFileIO
51 } // namespace DistributedFS
52 } // namespace OHOS