• 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 './basic';
17
18declare namespace zlib {
19/**
20 * @name ErrorCode
21 * @since 7
22 * @syscap SystemCapability.BundleManager.Zlib
23 * @import NA
24 * @permission NA
25 */
26  export enum ErrorCode {
27    ERROR_CODE_OK = 0,
28    ERROR_CODE_ERRNO = -1
29  }
30
31/**
32 * @name CompressLevel
33 * @since 7
34 * @syscap SystemCapability.BundleManager.Zlib
35 * @import NA
36 * @permission NA
37 */
38  export enum CompressLevel {
39    COMPRESS_LEVEL_NO_COMPRESSION = 0,
40    COMPRESS_LEVEL_BEST_SPEED = 1,
41    COMPRESS_LEVEL_BEST_COMPRESSION = 9,
42    COMPRESS_LEVEL_DEFAULT_COMPRESSION = -1
43  }
44
45/**
46 * @name CompressStrategy
47 * @since 7
48 * @syscap SystemCapability.BundleManager.Zlib
49 * @import NA
50 * @permission NA
51 */
52  export enum CompressStrategy {
53    COMPRESS_STRATEGY_DEFAULT_STRATEGY = 0,
54    COMPRESS_STRATEGY_FILTERED = 1,
55    COMPRESS_STRATEGY_HUFFMAN_ONLY = 2,
56    COMPRESS_STRATEGY_RLE = 3,
57    COMPRESS_STRATEGY_FIXED = 4
58  }
59
60/**
61 * @name MemLevel
62 * @since 7
63 * @syscap SystemCapability.BundleManager.Zlib
64 * @import NA
65 * @permission NA
66 */
67  export enum MemLevel {
68    MEM_LEVEL_MIN = 1,
69    MEM_LEVEL_MAX = 9,
70    MEM_LEVEL_DEFAULT = 8
71  }
72
73/**
74 * @name Options
75 * @since 7
76 * @syscap SystemCapability.BundleManager.Zlib
77 * @import NA
78 * @permission NA
79 */
80  interface Options {
81    level?: CompressLevel;
82    memLevel?: MemLevel;
83    strategy?: CompressStrategy;
84  }
85
86  /**
87   * Compress the specified file.
88   *
89   * @since 7
90   * @syscap SystemCapability.BundleManager.Zlib
91   * @param inFile Indicates the path of the file to be compressed.
92   * @param outFile Indicates the path of the output compressed file.
93   * @return Returns error code.
94   */
95  function zipFile(inFile:string, outFile:string, options: Options): Promise<void>;
96
97  /**
98   * Decompress the specified file.
99   *
100   * @since 7
101   * @syscap SystemCapability.BundleManager.Zlib
102   * @param inFile Indicates the path of the file to be decompressed.
103   * @param outFile Indicates the path of the decompressed file.
104   * @return Returns error code.
105   */
106  function unzipFile(inFile:string, outFile:string, options: Options): Promise<void>;
107}
108export default zlib;