hello how do i open zip and rar files with c ? which lib do u recommend ? is there any one lib that does both zip n rar ?

im basically trying to open zip and rar files which contain pics and retrieve a string array of all the names of the pics ignoring any folder names

some example source code would be greatly appreciated too thanks in advance

Recommended Answers

All 14 Replies

You could have a look over zlib, I think it's your best bet.

commented: nice link +0

zip and rar files are compressed files which can not be easily read by any program other than the one that wrote them. If you want them uncompressed you would be better off just calling winzip to decompress them for you. WinZip is not free -- only trial version is free for a little while.

Why WinZIP? WinRAR si free for non-commercial use and reads ZIP, RAR, 7-zip, and so on.

Never heard of it -- but it's not free either, which makes it just a competitor of WinZip

From their download site

You can try WinRAR before buy, its trial version is available

Well... most everyone I know has heard of and uses WinRAR on Windows. It is free, for non-commercial use. You do get a message asking you to buy it after a period of time if you use it commercially. Otherwise, you just click Cancel and it still works, fully-featured.

It's just like TeamViewer for iPhone, for example. There's a commercial version for $100 and a free version for non-commercial use.

Ancient dragon ur way off the point...i dont want to have to install winzip or whatever along with my application...and neither am i running the app on a pc or mac

"zip and rar files are compressed files which can not be easily read by any program other than the one that wrote them"

the author of zlib is actually the author of zip so ur wrong there and i knw its not easily read which is why im here asking for help lol


i was looking for something more like what creeps mentioned in his initial post and perhaps something like that for rar files too...altho most of those libs seems really really old so i was wondering if anyone knew of something better

If you have not already seen this wiki article then you might want to read it and follow some of the links it contains. Might be useful to you.

>>and neither am i running the app on a pc or mac

Oh I see. In that case Winzip or any other Windows program prbably will not help you.

> and neither am i running the app on a pc or mac

I love embedded programming! Its like crispy bacon in the morning for me. If you are running a unix/linux based OS, you could use system calls to embed the functionality of existing free or open source command line parameters. You can also pick any free open source decompressor and look at its publicly available source code.

If you are looking to embed functionality, zlib is a good one (i've used it), also look at this for RAR:

http://www.unrarlib.org/features.html

There are a ton of decompression code out there, just do some searches for "zip library" or "rar library" on google.

As for "which is best", it really depends on your application. If your program's objective is to manage zip's and rar's, you don't need to worry much about how modern it is. You only need to worry about it if you are accepting random files provided by the user on a software intended to be used by the public. And in these cases, using libraries for specific formats, such as zip or rar, would be better independent instead of "all in one".

Either way, there is a million of options for you. You are living in an era where these kinds of questions are nearly irrelevant. So have fun!

By the way, I find the arguments about "which is better, WinZIP and WinRAR?" kinda funny and totally out of place on this specific forum. Its like kids arguing about their favorite toy. Personally I use tar.

>>By the way, I find the arguments about "which is better, WinZIP and WinRAR?"

I don't think we were debating that -- just whether WinRAR was free or not. As for which of the two is best, I haven't the slightest idea because I never used WinRAR. All I care about is getting the *.zip files decompressed and could care less which program does a better job of it.

The way I see it, any program written for Windows is inherently not free since it was written on top of a not-free Windows API. Open source code for Windows is just a pay-ware flavored build. Gotta admire how Microsoft's model makes profits on software without anyone really knowing it.

>>any program written for Windows is inherently not free
Commercial software yes, otherwise there are thousands of freeware programs for MS-Windows. OpenGL and OpenOffice are just two of them.

Thats not exactly what I meant but ok :D

thanks N1GHTS for the input, i am basically developing a homebrew app for the PSP and included within the psp sdk is zzlib which works great for just zip files....unrarlib i checked out but was uncertain as to use it or not because it says it doesnt support v3.0...i will give it a go anyway :)

would be really useful having just one lib that did both zip n rar tho

thanks again

Development of unrarlib has been halted like 3 years ago. Although it is stable, it can read up to the old RAR2 archives. It's not recommended.

Your other option is to use official UnRAR.dll. You may not have the source code for it but you can get the work done.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.