提交 47b8bd05 编写于 作者: W wusongqing

update docs against 5892

Signed-off-by: Nwusongqing <wusongqing@huawei.com>
上级 725123b5
# 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 ## Modules to Import
```javascript ```javascript
...@@ -7,8 +14,7 @@ import zlib from '@ohos.zlib'; ...@@ -7,8 +14,7 @@ import zlib from '@ohos.zlib';
``` ```
## zlib.zipFile ## zlib.zipFile
zipFile(inFile:string, outFile:string, options: Options): Promise&lt;void&gt;
zipFile(inFile:string, outFile:string, options: Options): Promise\<void>
Zips a file. This API uses a promise to return the result. 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. ...@@ -16,11 +22,11 @@ Zips a file. This API uses a promise to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | ----------------------------------- | ---- | ------------------------------------------- | | ------- | ------------------- | ---- | ------------------------------------------------------------ |
| inFile | string | Yes | Path of the folder or file to zip. | | 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.| | outFile | string | Yes | Path of the zipped file. The file name extension is .zip. |
| options | [Options](#options)| No | Optional parameters for the zip operation. | | options | [Options](#options) | No | Optional parameters for the zip operation. |
**Return value** **Return value**
...@@ -72,7 +78,7 @@ zlib.zipFile(inFile , outFile, options).then((data) => { ...@@ -72,7 +78,7 @@ zlib.zipFile(inFile , outFile, options).then((data) => {
## zlib.unzipFile ## zlib.unzipFile
unzipFile(inFile:string, outFile:string, options: Options): Promise\<void> unzipFile(inFile:string, outFile:string, options: Options): Promise&lt;void&gt;
Unzips a file. This API uses a promise to return the result. 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. ...@@ -80,11 +86,11 @@ Unzips a file. This API uses a promise to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | ----------------------------------- | ---- | ----------------------------------- | | ------- | ------------------- | ---- | ------------------------------------------------------------ |
| inFile | string | Yes | Path of the .zip file to unzip.| | 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. | | outFile | string | Yes | Path of the unzipped file. |
| options | [Options](#options)| No | Optional parameters for the unzip operation. | | options | [Options](#options) | No | Optional parameters for the unzip operation. |
**Return value** **Return value**
...@@ -115,42 +121,52 @@ zlib.unzipFile(inFile, outFile, options).then((data) => { ...@@ -115,42 +121,52 @@ zlib.unzipFile(inFile, outFile, options).then((data) => {
## Options ## Options
| Name | Description | **System capability**: SystemCapability.BundleManager.Zlib
| --------------------------- | ------------------------------------------------------------ |
| level?: CompressLeve | See [zip.CompressLevel](#zipcompresslevel).| | Name | Type | Mandatory| Description |
| memLevel?: MemLevel | See [zip.MemLevel](#zipmemlevel). | | -------- | ---------------- | ---- | --------------------------------------------------------- |
| strategy?: CompressStrategy | See [zip.CompressStrategy](#zipcompressstrategy).| | level | CompressLeve | No | See [zip.CompressLevel](#zipcompresslevel). |
| memLevel | MemLevel | No | See [zip.MemLevel](#zipmemlevel). |
| strategy | CompressStrategy | No | See [zip.CompressStrategy](#zipcompressstrategy).|
## zip.MemLevel ## zip.MemLevel
| Name | Description | **System capability**: SystemCapability.BundleManager.Zlib
| ----------------- | -------------------------------- |
| 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.|
## 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 | ## zip.CompressLevel
| --------------------------------------- | ----------------- |
| 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 | Description | | Name | Value | Description |
| -------------------------------------- | ------------------------ | | ---------------------------------- | ---- | ----------------- |
| COMPRESS_STRATEGY_DEFAULT_STRATEGY: 0 | Default compression strategy. | | COMPRESS_LEVEL_NO_COMPRESSION | 0 | Compress level 0 that indicates uncompressed.|
| COMPRESS_STRATEGY_FILTERED: 1 | Filtered compression strategy.| | COMPRESS_LEVEL_BEST_SPEED | 1 | Compression level 1 that gives the best speed. |
| COMPRESS_STRATEGY_HUFFMAN_ONLY: 2 | Huffman coding compression strategy. | | COMPRESS_LEVEL_BEST_COMPRESSION | 9 | Compression level 9 that gives the best compression. |
| COMPRESS_STRATEGY_RLE: 3 | RLE compression strategy. | | COMPRESS_LEVEL_DEFAULT_COMPRESSION | -1 | Default compression level. |
| COMPRESS_STRATEGY_FIXED: 4 | Fixed compression strategy. |
## 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 ## zip.ErrorCode
| Name | Description | **System capability**: SystemCapability.BundleManager.Zlib
| -------------------- | ------------ |
| ERROR_CODE_OK: 0 | The API is successfully called.| | Name | Value | Description |
| ERROR_CODE_ERRNO: -1| Failed to call the API.| | ---------------- | ---- | ------------ |
| ERROR_CODE_OK | 0 | The API is successfully called.|
| ERROR_CODE_ERRNO | -1 | Failed to call the API.|
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册