• 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 CompressFlushModeInit 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 CompressFlushModeInit(napi_env env, napi_value exports);
56 
57 /**
58  * @brief CompressMethodInit 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 CompressMethodInit(napi_env env, napi_value exports);
66 
67 /**
68  * @brief CompressStrategy 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 CompressStrategyInit(napi_env env, napi_value exports);
76 
77 /**
78  * @brief ParallelStrategy data initialization.
79  *
80  * @param env The environment that the Node-API call is invoked under.
81  * @param exports An empty object via the exports parameter as a convenience.
82  *
83  * @return The return value from Init is treated as the exports object for the module.
84  */
85 napi_value ParallelStrategyInit(napi_env env, napi_value exports);
86 
87 /**
88  * @brief MemLevel data initialization.
89  *
90  * @param env The environment that the Node-API call is invoked under.
91  * @param exports An empty object via the exports parameter as a convenience.
92  *
93  * @return The return value from Init is treated as the exports object for the module.
94  */
95 napi_value MemLevelInit(napi_env env, napi_value exports);
96 
97 /**
98  * @brief OffsetReferencePointInit data initialization.
99  *
100  * @param env The environment that the Node-API call is invoked under.
101  * @param exports An empty object via the exports parameter as a convenience.
102  *
103  * @return The return value from Init is treated as the exports object for the module.
104  */
105 napi_value OffsetReferencePointInit(napi_env env, napi_value exports);
106 
107 /**
108  * @brief ReturnStatusInit data initialization.
109  *
110  * @param env The environment that the Node-API call is invoked under.
111  * @param exports An empty object via the exports parameter as a convenience.
112  *
113  * @return The return value from Init is treated as the exports object for the module.
114  */
115 napi_value ReturnStatusInit(napi_env env, napi_value exports);
116 
117 /**
118  * @brief Errorcode data initialization.
119  *
120  * @param env The environment that the Node-API call is invoked under.
121  * @param exports An empty object via the exports parameter as a convenience.
122  *
123  * @return The return value from Init is treated as the exports object for the module.
124  */
125 napi_value ErrorCodeInit(napi_env env, napi_value exports);
126 /**
127  * @brief zlib NAPI module registration.
128  *
129  * @param env The environment that the Node-API call is invoked under.
130  * @param exports An empty object via the exports parameter as a convenience.
131  *
132  * @return The return value from Init is treated as the exports object for the module.
133  */
134 napi_value ZlibInit(napi_env env, napi_value exports);
135 
136 /**
137  * @brief Zlib NAPI method : zipFile.
138  *
139  * @param env The environment that the Node-API call is invoked under.
140  * @param info The callback info passed into the callback function.
141  *
142  * @return The return value from NAPI C++ to JS for the module.
143  *
144  * NAPI_Zipfile interface supports promise and callback calls.
145  *
146  * example No1
147  * var src ="/ziptest/zipdata/";
148  * var dest ="/ziptest/hapresult/hapfourfile.zip";
149  * var option = {
150  *           flush:0,
151  *           finishFlush:2,
152  *           chunkSize:68,
153  *           memLevel:8,
154  *           level:-1,
155  *           strategy:0
156  *         };
157  *
158  * example No2
159  * var src ="/ziptest/zipdata/zip1/zip1-1.cpp";
160  * var dest ="/ziptest/hapresult/single.zip";
161  * var option = {
162  *           flush:0,
163  *           finishFlush:2,
164  *           chunkSize:68,
165  *           memLevel:8,
166  *           level:-1,
167  *           strategy:0
168  *       };
169  *
170  */
171 napi_value NAPI_ZipFile(napi_env env, napi_callback_info info);
172 
173 /**
174  * @brief Zlib NAPI method : unzipFile.
175  *
176  * @param env The environment that the Node-API call is invoked under.
177  * @param info The callback info passed into the callback function.
178  *
179  * @return The return value from NAPI C++ to JS for the module.
180  *
181  * NAPI_UnzipFile interface supports promise and callback calls.
182  *
183  * example No1
184  * var src ="/ziptest/hapresult/hapfourfile.zip";
185  * var dest ="/ziptest/hapunzipdir/01";
186  * var option = {
187  *           flush:0,
188  *           finishFlush:2,
189  *           chunkSize:68,
190  *           memLevel:8,
191  *           level:-1,
192  *           strategy:0
193  *       };
194  *
195  * example No2
196  * var src ="/ziptest/hapresult/single.zip";
197  * var dest ="/ziptest/hapunzipdir/single";
198  * var option = {
199  *           flush:0,
200  *           finishFlush:2,
201  *           chunkSize:68,
202  *           memLevel:8,
203  *           level:-1,
204  *           strategy:0
205  *       };
206  */
207 napi_value NAPI_UnzipFile(napi_env env, napi_callback_info info);
208 
209 bool InitParam(CallZipUnzipParam &param, napi_env env, NapiArg &args, bool isZipFile);
210 
211 napi_value CompressFile(napi_env env, napi_callback_info info);
212 napi_value CompressFiles(napi_env env, napi_callback_info info);
213 napi_value DecompressFile(napi_env env, napi_callback_info info);
214 napi_value GetOriginalSize(napi_env env, napi_callback_info info);
215 
216 }  // namespace LIBZIP
217 }  // namespace AppExecFwk
218 }  // namespace OHOS
219 
220 #endif  // OHOS_APPEXECFWK_LIBZIP_ZLIB_H
221