• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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_dir/dir_n_exporter.h"
21 #include "class_dirent/dirent_n_exporter.h"
22 #include "class_stat/stat_n_exporter.h"
23 #include "class_stream/stream_n_exporter.h"
24 #include "properties/prop_n_exporter.h"
25 
26 using namespace std;
27 
28 namespace OHOS {
29 namespace DistributedFS {
30 namespace ModuleFileIO {
Export(napi_env env,napi_value exports)31 static napi_value Export(napi_env env, napi_value exports)
32 {
33     std::vector<unique_ptr<NExporter>> products;
34     products.emplace_back(make_unique<PropNExporter>(env, exports));
35     products.emplace_back(make_unique<DirentNExporter>(env, exports));
36     products.emplace_back(make_unique<DirNExporter>(env, exports));
37     products.emplace_back(make_unique<StatNExporter>(env, exports));
38     products.emplace_back(make_unique<StreamNExporter>(env, exports));
39 
40     for (auto &&product : products) {
41         if (!product->Export()) {
42             HILOGE("INNER BUG. Failed to export class %{public}s for module fileio", product->GetClassName().c_str());
43             return nullptr;
44         } else {
45             HILOGE("Class %{public}s for module fileio has been exported", product->GetClassName().c_str());
46         }
47     }
48     return exports;
49 }
50 
51 NAPI_MODULE(fileio, Export)
52 } // namespace ModuleFileIO
53 } // namespace DistributedFS
54 } // namespace OHOS