1 / 13

Gzip 简介 Gzip 命令行参数用法 Gzip 各文件的主要功能 Gzip 命令行参数处理导读

提纲. Gzip 简介 Gzip 命令行参数用法 Gzip 各文件的主要功能 Gzip 命令行参数处理导读. Gzip 简介. GZIP 最早由 Jean-loup Gailly 和 Mark Adler 创建,用于 UNIX 系统的文件压缩。我们在 Linux 中经常会用到后缀为 .gz 的文件,它们就是 GZIP 格式的。现今已经成为 Internet 上使用非常普遍的一种数据压缩格式,或者说一种文件格式。 HTTP 协议上的 GZIP 编码是一种用来改进 WEB 应用程序性能的技术。大流量的 WEB 站点常常使用 GZIP 压缩技术来让用户感受更快的速度。.

fred
Download Presentation

Gzip 简介 Gzip 命令行参数用法 Gzip 各文件的主要功能 Gzip 命令行参数处理导读

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 提纲 • Gzip简介 • Gzip命令行参数用法 • Gzip各文件的主要功能 • Gzip命令行参数处理导读

  2. Gzip简介 • GZIP最早由Jean-loup Gailly和Mark Adler创建,用于UNIX系统的文件压缩。我们在Linux中经常会用到后缀为.gz的文件,它们就是GZIP格式的。现今已经成为Internet上使用非常普遍的一种数据压缩格式,或者说一种文件格式。HTTP协议上的GZIP编码是一种用来改进WEB应用程序性能的技术。大流量的WEB站点常常使用GZIP压缩技术来让用户感受更快的速度。

  3. Gzip命令行参数用法 • CMD下的Gzip的参数说明

  4. Gzip命令行参数用法 • Gzip命令的基本用法: >gzip test.txt 生成test.txz的压缩文件,同时不再保留test.txt >gzip -d test.txz 解压test.txz,生成test.tx文件

  5. Gzip命令行参数用法 • -c: 不改变原文件,将压缩结果标准输出 • 不改变原文件,同时创建压缩文件

  6. Gzip命令行参数用法 • -n: 不保留原文件名和时间戳 • -N: 保留原文件名和时间戳 >gzip -dN test.txz 解压后的文件名为test.txt

  7. Gzip命令行参数用法 • -f: 覆盖已经存在的输出文件 • -l: 给出压缩文件大小及压缩率信息 • -L: Gzip的软件许可证信息 • -q: 忽略所有的警告提示 • -S: 指定压缩文件后缀,(MSDOS下默认后缀为.z) • -t: 测试压缩文件的完整性 • -v: 给出文件名和压缩率信息 • -V: 给出Gzip的版本信息 • -1: 快速压缩模式 • -9: 最佳压缩模式

  8. Gzip各文件的主要功能 • Gzip.c: 程序入口 • Deflate.c: 实现文件压缩功能的函数集合,提供对文件压缩的支持 • Inflate.c: 实现文件解压功能的函数集合,提供对文件解压的支持 • Zip.c: 将文件压缩成gzip格式 • Unzip: 解压gzip或pkzip格式的文件 • Unlzh.c:解压lzh格式的文件 • Unlzw.c:解压lzw格式的文件 • Unpack.c:解压pack格式的文件

  9. Gzip各文件的主要功能 • Bits.c: 提供对位操作的支持 • Getopt.c: 提供对参数解析的支持 • Trees.c: huffman树相关的操作集合,包括创建新树选择树的类型等 • Tailor.c、Tailor.h: 配置文件,用于支持多种编译环境 • Util.c: 工具函数集合,包括对缓冲区的操作,错误处理,文件名的处理等。

  10. Gzip各文件的主要功能 • Gzip的实现原理分析和文件中各函数的主要功能详解参见 ftp://ds0411:ds0411@202.38.79.124/resource/

  11. Gzip命令行参数处理导读 程序所在位置: Gzip.c的main函数中。 argc: 参数的个数 argv: 参数字符串数组 >gzip.exe –d –N test.txz 0 1 2 3 集成环境中输入的第一个参数是argv[1] int main (argc, argv) int argc; char **argv;

  12. Gzip命令行参数处理导读 progname = basename(argv[0]); proglen = strlen(progname); /* Suppress .exe for MSDOS, OS/2 and VMS: */ if (proglen > 4 && strequ(progname+proglen-4, ".exe")) { progname[proglen-4] = '\0'; } basename是util.c中的函数,用于取文件名 progname=basename(“d:\gzipproj\gzip.exe”); progname值为”gzip.exe”

  13. while ((optc = getopt_long (argc, argv, "ab:cdfhH?lLmMnNqrS:tvVZ123456789", longopts, (int *)0)) != EOF) { switch (optc) { case 'c': to_stdout = 1; break; case 'd': decompress = 1; break; case 'h': case 'H': case '?': help(); do_exit(OK); break; case 'l': list = decompress = to_stdout = 1; break; case 'L': license(); do_exit(OK); break; case 'N': no_name = no_time = 0; break; case 'q': quiet = 1; verbose = 0; break; …… } } 可选参数的提取: getopt_long() 可选参数对程序的影响:变量值的改变 >gzip.exe –d –N –q test.txz 解析命令行参数的具体细节可参Getopt.c中函数_getopt_internal()的注释部分

More Related