How to compress file(s) in C++

Apr 21, 2013 at 8:00am
I would like to compress a file and have C++ hold it such as a folder, images, and videos. Is this possible? If so, is there any links or tuts that show how to do this, or even a open source code? Basically I want to contain my folders, etc and then when ever I want to get a hold of my files, I'll have to dump it out with a special password access... I hope it is not to difficult to do... but i'll still try.
Apr 21, 2013 at 8:04am
Here's 7zip, an open-source software that does exactly this:
http://sourceforge.net/projects/sevenzip/files/?source=navbar
Apr 21, 2013 at 8:15am
I remember downloading a file for something... and it opened as a Console, and extracted everything in my C:\, I do not know what language the person created it in, but after that I wanted to have my own console version do this with all my files. I downloaded 7zip, it seems like almost a .rar type of software.

I have the software 7-zip, but where is the Source code?
Last edited on Apr 21, 2013 at 8:21am
Apr 21, 2013 at 8:45am
Oh, you can find the source code here (my mistake):
http://www.7-zip.org/download.html

It CAN be done in C++. Use something like boost::filesystem to iterate through all folders and files in a file system. Then use your own algorithm to compress them into a binary file. Some algorithms take consecutive zeros and replace them with a shorter symbol (that's an easy algorithm). In the compressed format, you also need to define the folder structure, this will let you restore the same format later.



Apr 21, 2013 at 9:59am
I strongly recommend reading about data compression before you jump into coding:

http://mattmahoney.net/dc/dce.html
http://www.cs.duke.edu/csed/curious/compression/
Apr 21, 2013 at 10:08am
Topic archived. No new replies allowed.