• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef OHOS_APPEXECFWK_LIBZIP_ZLIB_H
16 #define OHOS_APPEXECFWK_LIBZIP_ZLIB_H
17 #include <string>
18 
19 #include "napi_arg.h"
20 #include "napi/native_api.h"
21 #include "napi_zlib_common.h"
22 #include "zip_utils.h"
23 
24 namespace OHOS {
25 namespace AppExecFwk {
26 namespace LIBZIP {
27 
28 /**
29  * @brief FlushType data initialization.
30  *
31  * @param env The environment that the Node-API call is invoked under.
32  * @param exports An empty object via the exports parameter as a convenience.
33  *
34  * @return The return value from Init is treated as the exports object for the module.
35  */
36 napi_value FlushTypeInit(napi_env env, napi_value exports);
37 /**
38  * @brief CompressLevel data initialization.
39  *
40  * @param env The environment that the Node-API call is invoked under.
41  * @param exports An empty object via the exports parameter as a convenience.
42  *
43  * @return The return value from Init is treated as the exports object for the module.
44  */
45 napi_value CompressLevelInit(napi_env env, napi_value exports);
46 
47 /**
48  * @brief CompressStrategy data initialization.
49  *
50  * @param env The environment that the Node-API call is invoked under.
51  * @param exports An empty object via the exports parameter as a convenience.
52  *
53  * @return The return value from Init is treated as the exports object for the module.
54  */
55 napi_value CompressStrategyInit(napi_env env, napi_value exports);
56 
57 /**
58  * @brief MemLevel data initialization.
59  *
60  * @param env The environment that the Node-API call is invoked under.
61  * @param exports An empty object via the exports parameter as a convenience.
62  *
63  * @return The return value from Init is treated as the exports object for the module.
64  */
65 napi_value MemLevelInit(napi_env env, napi_value exports);
66 
67 /**
68  * @brief Errorcode data initialization.
69  *
70  * @param env The environment that the Node-API call is invoked under.
71  * @param exports An empty object via the exports parameter as a convenience.
72  *
73  * @return The return value from Init is treated as the exports object for the module.
74  */
75 napi_value ErrorCodeInit(napi_env env, napi_value exports);
76 /**
77  * @brief zlib NAPI module registration.
78  *
79  * @param env The environment that the Node-API call is invoked under.
80  * @param exports An empty object via the exports parameter as a convenience.
81  *
82  * @return The return value from Init is treated as the exports object for the module.
83  */
84 napi_value ZlibInit(napi_env env, napi_value exports);
85 
86 /**
87  * @brief Zlib NAPI method : zipFile.
88  *
89  * @param env The environment that the Node-API call is invoked under.
90  * @param info The callback info passed into the callback function.
91  *
92  * @return The return value from NAPI C++ to JS for the module.
93  *
94  * NAPI_Zipfile interface supports promise and callback calls.
95  *
96  * example No1
97  * var src ="/ziptest/zipdata/";
98  * var dest ="/ziptest/hapresult/hapfourfile.zip";
99  * var option = {
100  *           flush:0,
101  *           finishFlush:2,
102  *           chunkSize:68,
103  *           memLevel:8,
104  *           level:-1,
105  *           strategy:0
106  *         };
107  *
108  * example No2
109  * var src ="/ziptest/zipdata/zip1/zip1-1.cpp";
110  * var dest ="/ziptest/hapresult/single.zip";
111  * var option = {
112  *           flush:0,
113  *           finishFlush:2,
114  *           chunkSize:68,
115  *           memLevel:8,
116  *           level:-1,
117  *           strategy:0
118  *       };
119  *
120  */
121 napi_value NAPI_ZipFile(napi_env env, napi_callback_info info);
122 
123 /**
124  * @brief Zlib NAPI method : unzipFile.
125  *
126  * @param env The environment that the Node-API call is invoked under.
127  * @param info The callback info passed into the callback function.
128  *
129  * @return The return value from NAPI C++ to JS for the module.
130  *
131  * NAPI_UnzipFile interface supports promise and callback calls.
132  *
133  * example No1
134  * var src ="/ziptest/hapresult/hapfourfile.zip";
135  * var dest ="/ziptest/hapunzipdir/01";
136  * var option = {
137  *           flush:0,
138  *           finishFlush:2,
139  *           chunkSize:68,
140  *           memLevel:8,
141  *           level:-1,
142  *           strategy:0
143  *       };
144  *
145  * example No2
146  * var src ="/ziptest/hapresult/single.zip";
147  * var dest ="/ziptest/hapunzipdir/single";
148  * var option = {
149  *           flush:0,
150  *           finishFlush:2,
151  *           chunkSize:68,
152  *           memLevel:8,
153  *           level:-1,
154  *           strategy:0
155  *       };
156  */
157 napi_value NAPI_UnzipFile(napi_env env, napi_callback_info info);
158 
159 bool InitParam(CallZipUnzipParam &param, napi_env env, NapiArg &args, bool isZipFile);
160 
161 napi_value CompressFile(napi_env env, napi_callback_info info);
162 napi_value DecompressFile(napi_env env, napi_callback_info info);
163 
164 }  // namespace LIBZIP
165 }  // namespace AppExecFwk
166 }  // namespace OHOS
167 
168 #endif  // OHOS_APPEXECFWK_LIBZIP_ZLIB_H
169