Unzip split Zip or/and multi zip in c++ or c or Objective-C - c++

I want to Unzip a multi zip files or a split files directly in my application in iPad.
For this i have minizip a framework in langage C (thats work for a simple .zip file).
So my question is how Unzip a file like .z01, .z02 or/and a file .zip.001, .zip.002 in one of this language C, C++ or/and Objective-C (if possible an example of how make this)?
I try (in Objective-C) too take data of all files and assemble in one file that doesn't worked, so an other response possible is to explain how a split of zip is made (just data cut or somethings else)?
Thanks in advance for your consideration

Finally,
when you split a zip file in multi files like zip.001 zip.002 etc... you just cut the data of source file.
So for unzip this type of files just take data of all files and concat in one file, after this just unzip this new file with framework minizip and in Objective-C use the code project ZipArchive (that use minizip) in google source code.
P.S : Thanks to David H for his help.

Related

Combining two cpp files into one cpp file

I am working on an assignment where I have main.cpp,lego.cpp, and lego.h. My program currently runs fine and gives out the desired output. My issue is that to submit, I must have everything in a single cpp file. Would appreciate if someone could give a simple example. (I want everything in main.cpp)
Merge C++ files into a single source file
i found this link that is similar but I cant grasp the example
if anyone has this problem I just fixed it by doing this
class lego {things in class};
lego::functionA(){}
lego::functionB(){}
int main(){};
make sure that you delete any other cpp files that are in your source folder and remove any header files from main. Was what was causing my issue.
Combining two cpp files into one cpp file
On a POSIX system, you can use the following command:
cat main.cpp lego.cpp > combined.cpp
On windows, use type instead of cat.
This trivial approach works for most programs, and very likely for a simple assignment. But this can have problems with more complicated programs in particular those that rely heavily on pre-processor.
using the command prompt by combining the files. you need to put the files that you need to combine in a single folder and using the command line (windows + r, on windows 10) run commands that access the directory in which the files are.
Enter the command copy/b *.cpp combined.cpp That will save the two cpp files into one file combined.cpp.
Then access the combined file combined.cpp in the same directory.
This might help you too https://www.youtube.com/watch?v=0atEx7EngoE

How to add and use .zip (or .pak) files to c++ project?

I'm compiling CEF (Chromium Embedded Framework) for our local html5 presentation.
I should say I'm very new for all this (CEF and C++).
I've already optimized cefclient project for the presentation, but I need to embed all html/js/css/etc files into project (reading from local storage is not an option).
As I understood, I should use .zip or .pak (renamed zip) files to embed. But how can I use them inside the project?
Should I use some lib for unzipping (zlib?) or there is another popular way? And how can I be sure that files will be compiled into project?
Sorry for such basic questions but there are very few information about this (or google hates me today).
Thank you for any help!
UPD: found great tool - WBEA (http://asterclick.drclue.net/WBEA.html), it looks like exactly what I want to, but works pretty slow (with JS).
UPD 2: It turns out that there are many ways to make HTML5 desktop application, for example Node-Webkit.
Here is an article that compares some of them http://clintberry.com/2013/html5-apps-desktop-2013/
You need:
Create zip file whitin your resources.
Embed it as win32 resource (after this step you will get correct executable with .zip file inside).
Create custom scheme handler to access this zip file.
CefZipReader class will be handly to implement handler from step 3.
Look around, may be something like what you want already exist somewhere.
This sounds very similar to self extracting installers.
No need to compile anything, just concatenate the zip to the end of the executable. All you need to do is find the offset at runtime from the start of the executable. This can be done easily by writing a large magic number and looking for it later.
Example Linux:
cat app magic_number data > new_app
Example Windows:
copy app.exe /B + magic.dat /B + data.dat /B new_app.exe

Open a zip file and move the file in another zip in c++?

I wanted to open a zip file (mod.zip) and move the file inside, to another zip file (minecraft.zip) and owerwrite the file with same names.I hope you understand because im not english.
I dont know if i can open zip files or i need libraries
I would recommend 7zip SDK, it lets you zip and unzip things in .7z and .zip and many other formats

Good free lib for compression

I need compress library for following needs:
1) Packing directory in one file with extension of my choice ( .pack for example )
2) Work with content in this file (directory) without unpaking it
3) Mechanism for encrypting
I already know about zlib, but for me it is ugly documented and not written anywhere what features are support from it
Packing directory in one file with extension of my choice ( .pack for example )
Most archivers don't require you to use a particular file extension. Regardless, one can still invoke file on a file to guess its content type.
Work with content in this file (directory) without unpaking it
It's possible to create a file list manually and prepend any archive file with that. Often, .sh installers for Linux contain a shell script in the beginning, followed by some magic line like __ARCHIVE_START__ followed by a binary archive. Hence it is possible to read lines from a file until __ARCHIVE_START__ line has been read. The rest of the file is an archive file.
Mechanism for encrypting
One easy way is to use different libraries for archiving and encrypting:
Bundle the files into one .tar.
Archive .tar into say .tar.xz.
Prepend the .tar.xz with file list followed by __ARCHIVE_START__ line.
Encrypt the file with any encryption library you please.
What you want is not a compression library. You want a compression, archiving, and encryption library or libraries. You need archiving to put a directory of files into a single file.
You can use zlib to do the compress part, but not archive or encrypt. zlib is documented in zlib.h and you can see a usage example there, as well as many examples in the source distribution package.
You can construct your own archiving format, or you can use existing ones for which there are libraries such as zip or tar, both of which use or can be directed to use zlib.
You can use OpenSSL for strong encryption.

Zip directory in C++

How can I zip directory in C++. I read this question: How do I zip a directory of files using C++? But I'd prefer a way that uses something like gzip, zlib and boost(because I do not want to add new libs to the project). Winapi-way is also acceptable (if it exists). And I do not want to start new process.
I would like a code sample. Thanks in advance
You want zip but you don't want to use any libraires?
Do you want to be bound by a particular licence - if so then simply copy all the code from zlib and the zip add-on into your own code.
If you can't use their licence then get the specs and write your own clean room implementation - make sure that you haven't seen the zlib or zip code base though.
The other alternative is to bundle a freely available zip command line client and call it with a system() call
edit: if you mean you are already using zlib then minizip does the directory stuff - it's usually included with zlib in the contrib directory
You can use boost iostream which includes compression functionalities. Have a look at the documentation here: http://www.boost.org/doc/libs/1_46_1/libs/iostreams/doc/index.html
It seems that in fact in this case that won't work for a directory of files.