• Home
Name Date Size #Lines LOC

..--

AppScope/12-May-2024-3633

entry/12-May-2024-1,2481,131

screenshots/device/12-May-2024-

.gitignoreD12-May-2024121 1010

README.mdD12-May-20241.3 KiB3618

README_zh.mdD12-May-20241.2 KiB3719

build-profile.json5D12-May-20241 KiB4241

hvigorfile.tsD12-May-2024158 21

package.jsonD12-May-2024370 1918

README.md

1# Zip and Unzip
2
3### Introduction
4
5This sample demonstrates the use of @ohos.zlib. Below shows the sample app.
6
7![](screenshots/device/main.png)
8
9### Concepts
10
11Zip: compresses a file or folder based on the passed file path to zip and the path of the zipped file.
12
13Unzip: decompresses a file or folder based on the passed file path to unzip and the path of the unzipped file.
14
15### Required Permissions
16
17N/A
18
19### Usage
20
211. Touch **+** in the upper right corner of the sample app.
22
232. In the **Create file** dialog box displayed, enter the file name and content, and touch **OK**.
24
253. The file created is displayed on the home page. Touch **Zip**. A message is displayed, indicating that the file is compressed, and a **.zip** file with the same name is created in the file list.
26
274. Touch **Unzip** next to the zipped file. A message is displayed, indicating that the file is decompressed, and a folder with the same name is created in the file list.
28
29### Constraints
30
311. This sample can only be run on standard-system devices.
32
332. This sample requires DevEco Studio 3.1 Canary1 (Build Version: 3.1.0.100, built on November 3, 2022) to compile and run.
34
353. The paths passed in the `Zip` and `Unzip` APIs must be the relative paths obtained by the context API. Currently, `Zip` and `Unzip` support operations only on files in the app directory.
36

README_zh.md

1# 压缩与解压
2
3### 介绍
4
5本示例通过@ohos.zlib接口,实现解压,压缩文件场景。
6
7使用说明
8
91.点击屏幕右上角 **+** 按钮,弹出创建文件窗口。
10
112.输入文件名称、文件内容,并点击 **确定** 按钮来创建文件。
12
133.文件创建成功后,文件名称自动追加.txt后缀并在主页面列表会显示,同时文件的物理地址为/data/app/el2/100/base/ohos.samples.ziplib/haps/entry/files/,点击 **压缩** 按钮,提示“文件压缩成功”,并会在文件列表创建一个相同名称的.zip文件。
14
154.点击压缩文件后的 **解压** 按钮,提示“文件解压成功”,并会再次在文件列表创建一个同名文件夹。
16
17### 效果预览
18
19![](screenshots/device/main.png)
20
21### 相关权限
22
23不涉及。
24
25### 依赖
26
27不涉及。
28
29### 约束与限制
30
311.本示例仅支持在标准系统上运行。
32
332.本示例需要使用DevEco Studio 3.1 Canary1 (Build Version: 3.1.0.100, built on November 3, 2022)才可编译运行。
34
353.解压与压缩相关接口的入参路径必须为context相关接口获取的相对路径,目前该接口仅支持操作应用目录下的文件。
36
374.本示例仅支持API9版本SDK,版本号:3.2.9.2。