问题
I'm looking for a good tutorial on zlib. I'm interested only in decompressing the archives. I also want to know how I can access a desired file inside an archive, preferably by filename alone, if that can be done in zlib at all.
回答1:
Well there are many zlib articles , tips and tutorials. Some of them are
1) Bobobobo's Blog
Website: http://bobobobo.wordpress.com/2008/02/23/how-to-use-zlib/
This article basically tells you how to use zlib, and there is a snippet of code that will get you going. This project shows you how to use zlib. Its a console project, because there's no need to create a window to demonstrate use of zlib.
2) zlib: Add Industrial Strength Compression to Your C/C++ Apps
Website: http://www.codeguru.com/cpp/cpp/algorithms/compression/article.php/c11735
For simplicity's sake, this tutorial covers only the basic C-style interface. All the concepts inherent there will be relevant to most other bindings. Since its in C language, it will be most beneficial to your requirements.
Last, you can use this too available in zlib ... Zlib contains them. Have a look in the manual under "Utility Functions".
ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen,
const Bytef *source, uLong sourceLen));
回答2:
See http://zlib.net/zlib_how.html
回答3:
http://www.boost.org/doc/libs/1_48_0/libs/iostreams/doc/classes/zlib.html
Another option worth mentioning here is boost. Note you must compile boost with special flags for zlib support.
回答4:
The simplest way to use zlib is in C++ with
https://github.com/rudi-cilibrasi/zlibcomplete
The zlibcomplete library makes it easy because you don't need to do any raw pointer manipulation whatsoever. It is based on RAII (Resource Allocation is Initialization) which means that all the dynamic allocation and deallocation stuff happens automatically in the constructors.
It is better than the Boost zlib wrapper because it supports flush (necessary for interactive network protocols) and is simpler to use. The zlibcomplete library uses only regular std::string to send and receive data so no advanced knowledge is required.
来源:https://stackoverflow.com/questions/5362250/what-easy-zlib-tutorials-are-there