• Home
Name Date Size #Lines LOC

..--

entry/12-May-2024-1,081978

screenshots/device/12-May-2024-

.gitignoreD12-May-2024121 88

README.mdD12-May-20241.3 KiB3618

README_zh.mdD12-May-20241.4 KiB3518

build-profile.json5D12-May-20241 KiB4341

hvigorfile.jsD12-May-2024174 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.0 Beta4 (Build Version: 3.0.0.992, built on July 14, 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![](screenshots/device/main.png)
8
9### 相关概念
10
11压缩:通过传入的压缩文件路径与压缩后生成文件路径来对文件或目录进行压缩。
12
13解压:通过传入的待解压文件路径与解压后生成文件路径来对文件或目录进行解压。
14
15### 相关权限
16
17不涉及。
18
19### 使用说明
20
211.点击屏幕右上角 **+** 按钮,弹出创建文件窗口。
22
232.输入文件名称、文件内容,并点击 **确定** 按钮来创建文件。
24
253.文件创建成功后,文件名称自动追加.txt后缀并在主页面列表会显示,同时文件的物理地址为/data/app/el2/100/base/ohos.samples.ziplib/haps/entry/files/,点击 **压缩** 按钮,提示“文件压缩成功”,并会在文件列表创建一个相同名称的.zip文件。
26
274.点击压缩文件后的 **解压** 按钮,提示“文件解压成功”,并会再次在文件列表创建一个同名文件夹。
28
29### 约束与限制
30
311.本示例仅支持在标准系统上运行。
32
332.本示例需要使用DevEco Studio 3.0 Beta4 (Build Version: 3.0.0.992, built on July 14, 2022)才可编译运行。
34
353.解压与压缩相关接口的入参路径必须为context相关接口获取的相对路径,目前该接口仅支持操作应用目录下的文件。