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