我需要 ungzip/regzip 文件以便在我的 c++ 中编辑在窗口中

发布于 2024-10-07 11:35:50 字数 207 浏览 0 评论 0原文

我正在开发一个小型应用程序,用于解析某个文件、取消加密、进行更改、重新加密和保存。它工作得很好,但为了让它工作,我需要手动解压缩它,在输出上运行应用程序,然后 gzip 来自其中的内容。我只是想知道是否有人知道一个优雅的解决方案/库,我可以使用它来自动化将在 Windows 上运行的 C++ 应用程序中的两个阶段。如果它能够检测到文件是否首先被 gzip 压缩,那就加分了。

多谢!

I'm working on a small application that parses a certain file, un-encrypts, makes changes, re-encrypts, and saves. It works well, but for it to work I need to manually ungzip it, run the application on the output, then gzip what comes from that. I'm just wondering if someone knows of an elegant solution/library I can use to automate both stages within the C++ application that will run on windows. Bonus points if it can detect if the file is gzipped in the first place.

Thanks a lot!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

半透明的墙 2024-10-14 11:35:50

Zlib 就是这样做的。 CGZip 为其实现了一个 C++ 包装器。 这里是如何检测给定文件是否被 gzip 压缩的示例。

测试 GZIP 文件

首先,我们应该参考“RFC 1952 GZIP 文件格式规范版本 4.3”。这是屏幕截图中显示的文档。它包含有关 GZIP 文件的文件结构的有用信息。它指出前两个字节包含固定值:

ID1(身份识别1)

ID2(身份识别2)

这些具有固定值 ID1 = 31 (0x1f, \037), ID2 = 139 (0x8b, \213),
识别该文件为 gzip 格式。

Zlib does that. And CGZip implements a C++ wrapper for it. And here is an example of how to detect if a given file is gzipped.

Testing GZIP files

First, we should reference the "RFC 1952 GZIP File Format Specification Version 4.3". This is the document shown in the screenshot. It contains useful information about the file structure of GZIP files. It states that the first two bytes contain fixed values:

ID1 (IDentification 1)

ID2 (IDentification 2)

These have the fixed values ID1 = 31 (0x1f, \037), ID2 = 139 (0x8b, \213),
to identify the file as being in gzip format.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文