From 47b8bd054c52f66a865a013dce34d24d1f27d8f5 Mon Sep 17 00:00:00 2001 From: wusongqing Date: Tue, 5 Jul 2022 13:55:25 +0800 Subject: [PATCH] update docs against 5892 Signed-off-by: wusongqing --- .../reference/apis/js-apis-zlib.md | 102 ++++++++++-------- 1 file changed, 59 insertions(+), 43 deletions(-) diff --git a/en/application-dev/reference/apis/js-apis-zlib.md b/en/application-dev/reference/apis/js-apis-zlib.md index 939fc0d2db..cf3427a192 100644 --- a/en/application-dev/reference/apis/js-apis-zlib.md +++ b/en/application-dev/reference/apis/js-apis-zlib.md @@ -1,5 +1,12 @@ -# Zip Module (JavaScript SDK APIs) +# Zip +> **NOTE** +> +> The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. + +## Constraints + +None ## Modules to Import ```javascript @@ -7,8 +14,7 @@ import zlib from '@ohos.zlib'; ``` ## zlib.zipFile - -zipFile(inFile:string, outFile:string, options: Options): Promise\ +zipFile(inFile:string, outFile:string, options: Options): Promise<void> Zips a file. This API uses a promise to return the result. @@ -16,11 +22,11 @@ Zips a file. This API uses a promise to return the result. **Parameters** -| Name | Type | Mandatory| Description | -| ------- | ----------------------------------- | ---- | ------------------------------------------- | -| inFile | string | Yes | Path of the folder or file to zip. | -| outFile | string | Yes | Path of the zipped file. The file name extension is .zip.| -| options | [Options](#options)| No | Optional parameters for the zip operation. | +| Name | Type | Mandatory| Description | +| ------- | ------------------- | ---- | ------------------------------------------------------------ | +| inFile | string | Yes | Path of the folder or file to zip. For details about the path, see [FA Model](js-apis-Context.md) and [Stage Model](js-apis-application-context.md).| +| outFile | string | Yes | Path of the zipped file. The file name extension is .zip. | +| options | [Options](#options) | No | Optional parameters for the zip operation. | **Return value** @@ -72,7 +78,7 @@ zlib.zipFile(inFile , outFile, options).then((data) => { ## zlib.unzipFile -unzipFile(inFile:string, outFile:string, options: Options): Promise\ +unzipFile(inFile:string, outFile:string, options: Options): Promise<void> Unzips a file. This API uses a promise to return the result. @@ -80,11 +86,11 @@ Unzips a file. This API uses a promise to return the result. **Parameters** -| Name | Type | Mandatory| Description | -| ------- | ----------------------------------- | ---- | ----------------------------------- | -| inFile | string | Yes | Path of the .zip file to unzip.| -| outFile | string | Yes | Path of the unzipped file. | -| options | [Options](#options)| No | Optional parameters for the unzip operation. | +| Name | Type | Mandatory| Description | +| ------- | ------------------- | ---- | ------------------------------------------------------------ | +| inFile | string | Yes | Path of the folder or file to zip. For details about the path, see [FA Model](js-apis-Context.md) and [Stage Model](js-apis-application-context.md).| +| outFile | string | Yes | Path of the unzipped file. | +| options | [Options](#options) | No | Optional parameters for the unzip operation. | **Return value** @@ -115,42 +121,52 @@ zlib.unzipFile(inFile, outFile, options).then((data) => { ## Options -| Name | Description | -| --------------------------- | ------------------------------------------------------------ | -| level?: CompressLeve | See [zip.CompressLevel](#zipcompresslevel).| -| memLevel?: MemLevel | See [zip.MemLevel](#zipmemlevel). | -| strategy?: CompressStrategy | See [zip.CompressStrategy](#zipcompressstrategy).| +**System capability**: SystemCapability.BundleManager.Zlib + +| Name | Type | Mandatory| Description | +| -------- | ---------------- | ---- | --------------------------------------------------------- | +| level | CompressLeve | No | See [zip.CompressLevel](#zipcompresslevel). | +| memLevel | MemLevel | No | See [zip.MemLevel](#zipmemlevel). | +| strategy | CompressStrategy | No | See [zip.CompressStrategy](#zipcompressstrategy).| ## zip.MemLevel -| Name | Description | -| ----------------- | -------------------------------- | -| MEM_LEVEL_MIN | Minimum memory used by the **zip** API during compression.| -| MEM_LEVEL_MAX | Maximum memory used by the **zip** API during compression.| -| MEM_LEVEL_DEFAULT | Default memory used by the **zip** API during compression.| +**System capability**: SystemCapability.BundleManager.Zlib -## Zip.CompressLevel +| Name | Value | Description | +| ----------------- | ---- | -------------------------------- | +| MEM_LEVEL_MIN | 1 | Minimum memory used by the **zip** API during compression.| +| MEM_LEVEL_MIN | 9 | Maximum memory used by the **zip** API during compression.| +| MEM_LEVEL_DEFAULT | 8 | Default memory used by the **zip** API during compression.| -| Name | Description | -| --------------------------------------- | ----------------- | -| COMPRESS_LEVEL_NO_COMPRESSION: 0 | Compress level 0 that indicates uncompressed.| -| COMPRESS_LEVEL_BEST_SPEED: 1 | Compression level 1 that gives the best speed. | -| COMPRESS_LEVEL_BEST_COMPRESSION: 9 | Compression level 9 that gives the best compression. | -| COMPRESS_LEVEL_DEFAULT_COMPRESSION: -1| Default compression level. | +## zip.CompressLevel -## Zip.CompressStrategy +**System capability**: SystemCapability.BundleManager.Zlib -| Name | Description | -| -------------------------------------- | ------------------------ | -| COMPRESS_STRATEGY_DEFAULT_STRATEGY: 0 | Default compression strategy. | -| COMPRESS_STRATEGY_FILTERED: 1 | Filtered compression strategy.| -| COMPRESS_STRATEGY_HUFFMAN_ONLY: 2 | Huffman coding compression strategy. | -| COMPRESS_STRATEGY_RLE: 3 | RLE compression strategy. | -| COMPRESS_STRATEGY_FIXED: 4 | Fixed compression strategy. | +| Name | Value | Description | +| ---------------------------------- | ---- | ----------------- | +| COMPRESS_LEVEL_NO_COMPRESSION | 0 | Compress level 0 that indicates uncompressed.| +| COMPRESS_LEVEL_BEST_SPEED | 1 | Compression level 1 that gives the best speed. | +| COMPRESS_LEVEL_BEST_COMPRESSION | 9 | Compression level 9 that gives the best compression. | +| COMPRESS_LEVEL_DEFAULT_COMPRESSION | -1 | Default compression level. | + +## zip.CompressStrategy + +**System capability**: SystemCapability.BundleManager.Zlib + +| Name | Value | Description | +| ---------------------------------- | ---- | ------------------------ | +| COMPRESS_STRATEGY_DEFAULT_STRATEGY | 0 | Default compression strategy. | +| COMPRESS_STRATEGY_FILTERED | 1 | Filtered compression strategy.| +| COMPRESS_STRATEGY_HUFFMAN_ONLY | 2 | Huffman coding compression strategy. | +| COMPRESS_STRATEGY_RLE | 3 | RLE compression strategy. | +| COMPRESS_STRATEGY_FIXED | 4 | Fixed compression strategy. | ## zip.ErrorCode -| Name | Description | -| -------------------- | ------------ | -| ERROR_CODE_OK: 0 | The API is successfully called.| -| ERROR_CODE_ERRNO: -1| Failed to call the API.| +**System capability**: SystemCapability.BundleManager.Zlib + +| Name | Value | Description | +| ---------------- | ---- | ------------ | +| ERROR_CODE_OK | 0 | The API is successfully called.| +| ERROR_CODE_ERRNO | -1 | Failed to call the API.| -- GitLab