gzip部分修改和重新压缩 [英] gzip partial modification and re-compression

查看:341
本文介绍了gzip部分修改和重新压缩的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不熟悉压缩算法. zlib或其他库是否可以仅对gzip流的开头进行解压缩,修改和重新压缩,然后将其与流的其余压缩内容连接起来?例如,在我需要修改10GB gzip文件的用户数据(而非标头)的前几个字节的情况下,可以避免对整个文件进行解压缩和重新压缩.

I am unfamiliar with compression algorithms. Is it possible with zlib or some other library to decompress, modify and recompress only the beginning of a gzip stream and then concatenate it with the compressed remainder of the stream? This would be done in a case where, for example, I need to modify the first bytes of user data (not headers) of a 10GB gzip file so as to avoid decompressing and recompressing the entire file.

推荐答案

否.压缩通常会在压缩后续数据时利用先前的数据.因此,如果不重新压缩其余数据,就无法更改先前的数据.

No. Compression will generally make use of the preceding data in compressing the subsequent data. So you can't change the preceding data without recompressing the remaining data.

如果原始放置在压缩数据中的断点会重置每个断点的历史记录,则将是一个例外.在zlib中,这是通过Z_FULL_FLUSH在压缩过程中完成的.

An exception would be if there were breakpoints put in the compressed data originally that reset the history at each breakpoint. In zlib this is accomplished with Z_FULL_FLUSH during compression.

这篇关于gzip部分修改和重新压缩的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆