# cangjie-tpc-zlib4cj **Repository Path**: liyanqing14/cangjie-tpc-zlib4cj ## Basic Information - **Project Name**: cangjie-tpc-zlib4cj - **Description**: 该仓库提供对zlib、DEFLATE、gzip格式的压缩与解压缩支持。 - **Primary Language**: Unknown - **License**: Zlib - **Default Branch**: develop - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-07-11 - **Last Updated**: 2025-07-11 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README

zlib4cj

## 简介 本仓库支持zlib,DEFLATE,gzip格式压缩和解压缩 ### 特性 - 🚀 支持DEFLATE、zlib、gzip格式压缩方式 - 💪 支持DEFLATE、zlib、gzip流式压缩和解压 - 🚀 支持DEFLATE、zlib设置字典压缩和解压 - 🚀 支持解压时自动识别格式解压 ## 架构 ### 源码目录: ```shell . ├── README.md ├── doc │ ├── assets │ ├── cjcov │ ├── design.md │ ├── feature_api.md ├── src │ └── deflate.cj │ └── inflate.cj │ └── stream.cj │ └── zlib.cj │ └── zutil.cj └── test ├── HLT ├── LLT └── UT ``` - `doc` 存放库的设计文档、提案、库的使用文档、LLT 用例覆盖报告 - `src` 存放库源码的目录 - `test` 存放测试用例,包括 HLT 用例、LLT 用例和 UT 用例 ### 类和接口说明: 详情见 [API](./doc/feature_api.md) ## 使用说明 ### 编译 ```shell cjpm build ``` ### 功能示例 #### zlib 使用示例 ```cangjie import zlib4cj.* import std.collection.* import std.io.* import std.os.posix.* import std.fs.* main() { let in_ = File("10MB.txt", OpenMode.Read) let outFile = File("10MB.txt2", OpenMode.ReadWrite) let compress = ZlibInputStream(in_) let decompress = AutoDecompressOutputStream(outFile) let buffer = Array(1024, repeat: 0) // 1MB buffer while (true) { let bytesRead = compress.read(buffer) if (bytesRead <= 0) { break } decompress.write(buffer[0 .. bytesRead]) } decompress.flush() decompress.close() compress.close() in_.seek(SeekPosition.Begin(0)) outFile.seek(Begin(0)) println("in size: ${in_.length}, out size: ${outFile.length}") } ``` 运行结果如下: ```cangjie 0 ``` ## 约束与限制 1. 暂时不支持level等于0的压缩场景, 为0时可能存在未预期的错误 2. 在下述版本验证通过: Cangjie Version: 1.0.0 ## 开源协议 本项目基于 [个人:(C) 1995-2022 Jean-loup Gailly and Mark Adler](./LICENSE) ,请自由的享受和参与开源。 ## 参与贡献 欢迎给我们提交 PR,欢迎给我们提交 issue,欢迎参与任何形式的贡献。 ,