On our RHEL6 server, our admin installed libarchive 4.8.3.
to get older 4.8.3
I am asked to write a C++ program using libarchive to produce a very limited Linux zip look-alike without spawning
The original zip command in a customer provided script looks something like:
$ zip bar.zip folder1/* folder2/* folder3/*
We don't need all the features of zip. In fact, they don't care if we even deal with compression. All that is necessary is that an archive of files is created and someone can use unzip to recreate the folder/file structure. (Since most of the files are already compressed, compression would actually waste time, but no biggie if the result uses compression as a default - whatever is the easiest route to take.)
The resultant zip file will have relative locations, not full absolute paths.
Does anyone have a simple example to do just this creating a zip file and filling it so that the result looks like the above zip command line.
I see examples on http://www.libarchive.org/
, which covers full capabilities of libarchive - mostly being able to autodetect existing archives and handling them. We have no need to read archives.
I was hoping that someone has a quick solution to create a zip file. The group received from the customer a script with the zip command, and told us to use their class that spawned the script using system(). That caused a crash when integrated into our program. The first work-around was to use posix_spawn but that has problems also. Basically, we learned that our program must not spawn anything due to program constraints.
Any simple program that illustrates, say, inserting three files with relative file paths into the created zip file would be appreciated. I know how to handle directory recursion if that becomes a requirement.