• 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
16import { AsyncCallback } from './@ohos.base';
17
18declare namespace zlib {
19  /**
20   * ErrorCode
21   *
22   * @enum { number }
23   * @syscap SystemCapability.BundleManager.Zlib
24   * @since 7
25   * @deprecated since 9
26   */
27  export enum ErrorCode {
28    ERROR_CODE_OK = 0,
29    ERROR_CODE_ERRNO = -1
30  }
31
32  /**
33   * CompressLevel
34   *
35   * @enum { number }
36   * @syscap SystemCapability.BundleManager.Zlib
37   * @since 7
38   */
39  export enum CompressLevel {
40    COMPRESS_LEVEL_NO_COMPRESSION = 0,
41    COMPRESS_LEVEL_BEST_SPEED = 1,
42    COMPRESS_LEVEL_BEST_COMPRESSION = 9,
43    COMPRESS_LEVEL_DEFAULT_COMPRESSION = -1
44  }
45
46  /**
47   * CompressStrategy
48   *
49   * @enum { number }
50   * @syscap SystemCapability.BundleManager.Zlib
51   * @since 7
52   */
53  export enum CompressStrategy {
54    COMPRESS_STRATEGY_DEFAULT_STRATEGY = 0,
55    COMPRESS_STRATEGY_FILTERED = 1,
56    COMPRESS_STRATEGY_HUFFMAN_ONLY = 2,
57    COMPRESS_STRATEGY_RLE = 3,
58    COMPRESS_STRATEGY_FIXED = 4
59  }
60
61  /**
62   * MemLevel
63   *
64   * @enum { number }
65   * @syscap SystemCapability.BundleManager.Zlib
66   * @since 7
67   */
68  export enum MemLevel {
69    MEM_LEVEL_MIN = 1,
70    MEM_LEVEL_MAX = 9,
71    MEM_LEVEL_DEFAULT = 8
72  }
73
74  /**
75   * @typedef Options
76   * @syscap SystemCapability.BundleManager.Zlib
77   * @since 7
78   */
79  interface Options {
80    level?: CompressLevel;
81    memLevel?: MemLevel;
82    strategy?: CompressStrategy;
83  }
84
85  /**
86   * Compress the specified file.
87   *
88   * @param { string } inFile Indicates the path of the file to be compressed.
89   * @param { string } outFile Indicates the path of the output compressed file.
90   * @param { Options } options
91   * @returns { Promise<void> }
92   * @syscap SystemCapability.BundleManager.Zlib
93   * @since 7
94   * @deprecated since 9
95   * @useinstead ohos.zlib#compressFile
96   */
97  function zipFile(inFile: string, outFile: string, options: Options): Promise<void>;
98
99  /**
100   * Decompress the specified file.
101   *
102   * @param { string } inFile Indicates the path of the file to be decompressed.
103   * @param { string } outFile Indicates the path of the decompressed file.
104   * @param { Options } options
105   * @returns { Promise<void> }
106   * @syscap SystemCapability.BundleManager.Zlib
107   * @since 7
108   * @deprecated since 9
109   * @useinstead ohos.zlib#decompressFile
110   */
111  function unzipFile(inFile: string, outFile: string, options: Options): Promise<void>;
112
113  /**
114   * Compress the specified file.
115   *
116   * @param { string } inFile - Indicates the path of the file to be compressed.
117   * @param { string } outFile - Indicates the path of the output compressed file.
118   * @param { Options } options - Indicates the options of compressing file.
119   * @param { AsyncCallback<void> } callback - The callback of compressing file result.
120   * @throws { BusinessError } 401 - The parameter check failed.
121   * @throws { BusinessError } 900001 - The input source file is invalid.
122   * @throws { BusinessError } 900002 - The input destination file is invalid.
123   * @syscap SystemCapability.BundleManager.Zlib
124   * @since 9
125   */
126  function compressFile(inFile: string, outFile: string, options: Options, callback: AsyncCallback<void>): void;
127
128  /**
129   * Compress the specified file.
130   *
131   * @param { string } inFile - Indicates the path of the file to be compressed.
132   * @param { string } outFile - Indicates the path of the output compressed file.
133   * @param { Options } options - Indicates the options of compressing file.
134   * @returns { Promise<void> } Returns the result of compressFile file.
135   * @throws { BusinessError } 401 - The parameter check failed.
136   * @throws { BusinessError } 900001 - The input source file is invalid.
137   * @throws { BusinessError } 900002 - The input destination file is invalid.
138   * @syscap SystemCapability.BundleManager.Zlib
139   * @since 9
140   */
141  function compressFile(inFile: string, outFile: string, options: Options): Promise<void>;
142
143  /**
144   * Decompress the specified file.
145   *
146   * @param { string } inFile - Indicates the path of the file to be decompressed.
147   * @param { string } outFile - Indicates the path of the output decompressed file.
148   * @param { Options } options - Indicates the options of decompressing file.
149   * @param { AsyncCallback<void> } callback - The callback of decompressing file result.
150   * @throws { BusinessError } 401 - The parameter check failed.
151   * @throws { BusinessError } 900001 - The input source file is invalid.
152   * @throws { BusinessError } 900002 - The input destination file is invalid.
153   * @syscap SystemCapability.BundleManager.Zlib
154   * @since 9
155   */
156  /**
157   * Decompress the specified file.
158   *
159   * @param { string } inFile - Indicates the path of the file to be decompressed.
160   * @param { string } outFile - Indicates the path of the output decompressed file.
161   * @param { Options } options - Indicates the options of decompressing file.
162   * @param { AsyncCallback<void> } callback - The callback of decompressing file result.
163   * @throws { BusinessError } 401 - The parameter check failed.
164   * @throws { BusinessError } 900001 - The input source file is invalid.
165   * @throws { BusinessError } 900002 - The input destination file is invalid.
166   * @throws { BusinessError } 900003 - The input source file is not ZIP format or damaged.
167   * @syscap SystemCapability.BundleManager.Zlib
168   * @since 10
169   */
170  function decompressFile(inFile: string, outFile: string, options: Options, callback: AsyncCallback<void>): void;
171
172  /**
173   * Decompress the specified file.
174   *
175   * @param { string } inFile - Indicates the path of the file to be decompressed.
176   * @param { string } outFile - Indicates the path of the output decompressed file.
177   * @param { AsyncCallback<void> } callback - The callback of decompressing file result.
178   * @throws { BusinessError } 401 - The parameter check failed.
179   * @throws { BusinessError } 900001 - The input source file is invalid.
180   * @throws { BusinessError } 900002 - The input destination file is invalid.
181   * @throws { BusinessError } 900003 - The input source file is not ZIP format or damaged.
182   * @syscap SystemCapability.BundleManager.Zlib
183   * @since 10
184   */
185  function decompressFile(inFile: string, outFile: string, callback: AsyncCallback<void>): void;
186
187  /**
188   * Decompress the specified file.
189   *
190   * @param { string } inFile - Indicates the path of the file to be decompressed.
191   * @param { string } outFile - Indicates the path of the output decompressing file.
192   * @param { Options } options - Indicates the options of decompressing file.
193   * @returns { Promise<void> } Returns the result of decompressing file.
194   * @throws { BusinessError } 401 - The parameter check failed.
195   * @throws { BusinessError } 900001 - The input source file is invalid.
196   * @throws { BusinessError } 900002 - The input destination file is invalid.
197   * @syscap SystemCapability.BundleManager.Zlib
198   * @since 9
199   */
200  /**
201   * Decompress the specified file.
202   *
203   * @param { string } inFile - Indicates the path of the file to be decompressed.
204   * @param { string } outFile - Indicates the path of the output decompressing file.
205   * @param { Options } options - Indicates the options of decompressing file.
206   * @returns { Promise<void> } Returns the result of decompressing file.
207   * @throws { BusinessError } 401 - The parameter check failed.
208   * @throws { BusinessError } 900001 - The input source file is invalid.
209   * @throws { BusinessError } 900002 - The input destination file is invalid.
210   * @throws { BusinessError } 900003 - The input source file is not ZIP format or damaged.
211   * @syscap SystemCapability.BundleManager.Zlib
212   * @since 10
213   */
214  function decompressFile(inFile: string, outFile: string, options?: Options): Promise<void>;
215}
216export default zlib;
217