如何使用C ++压缩文件目录? [英] How do I zip a directory of files using C++?

查看:410
本文介绍了如何使用C ++压缩文件目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个使用C ++,Boost和Qt的项目。我理解如何压缩单个文件和字节流,使用,例如,qCompress()函数在Qt。

I'm working on a project using C++, Boost, and Qt. I understand how to compress single files and bytestreams using, for example, the qCompress() function in Qt.

如何压缩包含子目录的多个文件的目录?我在寻找一个跨平台(Mac,Win,Linux)解决方案;我希望不要触发一系列新的进程。

How do I zip a directory of multiple files, including subdirectories? I am looking for a cross-platform (Mac, Win, Linux) solution; I'd prefer not to fire off a bunch of new processes.

有没有标准的方式将多个文件的字节流组合成一个压缩的档案,或者也有一个方便的功能或方法,将在Boost iostream库中可用?

Is there a standard way to combine bytestreams from multiple files into a zipped archive, or maybe there is a convenience function or method that would be available in the Boost iostream library?

非常感谢您的帮助。

更新:QuaZip库看起来真的大。在下载包中有一个例子(在tests目录中)非常清楚地显示了如何压缩文件目录。

Update: The QuaZip library looks really great. There is an example in the download package (in the "tests" dir) that shows very clearly how to zip up a directory of files.

更新2 :在我的Linux构建环境完成此任务后,我发现QuaZip不工作在所有与Visual Studio编译器。

Update 2: After completing this task on my Linux build environment, I discovered that QuaZip doesn't work at all with the Visual Studio compiler. It may be possible to tackle all those compiler errors, but a word of caution to anyone looking down this path.

推荐答案

我有一个可以解决所有这些编译错误的人,找到了以下两个库:

I have found the following two libraries:


  • ZipIOS ++ 。似乎是纯粹的C ++。它们不会将Windows明确列为受支持的平台。所以我想你应该试试你的运气自己。

  • QuaZIP 。基于Qt4。其实看起来不错。他们明确列出Windows(使用mingw)。显然,它是一个C ++包装器[this]库。

  • ZipIOS++. Seems to be "pure" C++. They don't list Windows explicitly as a supported platform. So i think you should try your luck yourself.
  • QuaZIP. Based on Qt4. Actually looks nice. They list Windows explicitly (Using mingw). Apparently, it is a C++ wrapper for [this] library.

Ah,当然,我已经从 this Qt Mailinglist问题关于压缩/解压目录:)

Ah, and of course, i have ripped those sites from this Qt Mailinglist question about Zipping/Unzipping of directories :)

这篇关于如何使用C ++压缩文件目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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