I’m trying to create zip files on the fly in C++, I’m using 7-zip to try and accomplish this, specifically I want to use the 7-zip commandline (I’m willing to try and modify its source to accomplish this).
Is this possible and if so how should I go about doing it?
7-zip can compress from
STDIN, so you start 7z process with certain command line arguments, then put your data into itsSTDIN. For example following:will create
arc.7zfile with two files inside:foo.txtandbar.txt(containing textfooandbarrespectively).Of course from your program you don’t need to call
echo, only7zredirectingSTDINwith pipes or some other means your OS provides. And you’ll have to start7zseveral times if you need to add more than one file.