I need help for reading the number of files in the archive and their properties (weight, date etc). SDK can not be used. Only binary reading.
Read the source code for 7-Zip and implement the parts you need. Here's the link: http://sourceforge.net/projects/sevenzip/files/
Related
We need to store some data as c++ header file, so that we can then include it in the build bundle and shipped with any applications that use it.
To do that we use
xxd -i data.png > data.h
This works well, but the data.h files is now as 6X large as the data.png file. That means, if the data.png is 4MB, the data.h would be 24MB.
May I ask if there is a way to compress the data.h file to a smaller size?
Thanks!
--- update ---
Thank you all for the suggestions! I think I could clarify the need here to provide more context!
the ideal way for us to consume the file is we can open it as input stream like
std::ifstream is;
infile.open("data.png");
somefunc(is) // a api function that takes std::istream as input
p.s. the file is not png file but a scripted model, I use png as example because I find it as a more generic problem of "xxd -i"
we didn't find a way to make it available as a file to be read, as the file system the codes actually searching would be in Android/iOS. (only files on the mobile system are available and the source codes would be zipped in the .so file)
with the header file we can do something like
std::stringstream is;
is.write((char*)data_byte_array, data_byte_array_len)
somefunc(is)
The source codes would end up built as a lib.so. In our tests, A 70KB data.h would end up adding 45KB to the lib.so.
May I ask if there is a way to compress the data.h file to a smaller size?
You can use any lossless compression algorithm. The gzip program is a common default choice on POSIX systems.
You can compile any binary file into an object file using objcopy -I binary. See C/C++ with GCC: Statically add resource files to executable/library for more details
I like to think of myself as reasonably computer and google literate (I'm OK ar searching the web). However I've recently had the need to compress into .ngz format and for the life of me I can't find a program that will allow me to compress into that format. I can open the files with 7zip, but it wont allow me to create an ngz archive. Any help appreciated.
It is likely a gzipped cpio file. Try cpio -i < whatever.ngz. It will automatically recognize the gzip compression and decompress it, as well as extract the archive. cpio -oz < list > archive.ngz will make a new archive given the list of files in list.
Is there a way to create a zip archive with the full folder content or multi-files.
I actually looked the example on the web but each time it's a compression of file only based on a buffer like for example : gzip_compressor() or gzwrite()
I can't give a full path in input but only a file buffer.
=> Then no folder compression nor multi-file compression ???
Please note that I would like to use zlib/gzip or boost (the only library i can link)
I think I missed something there...
Can you please help me ?
Marc.
There are several libraries out there to handle zip files. They use zlib for the compression, decompression, and crc32 operations. You should look at libzip and DotNetZip.
It looks like this will work. If you are on a Unix environment you may have to run the Java version:
http://www.7-zip.org/sdk.html
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.
I need to compress my data folder using 7zip (compression mode store) from my nant script. If I compressed from command prompt its not working properly. It taking some other compression mode.
This is my code
7zip.exe a mydatafolder.7z -ptest -mx0 mytarget
Please help me.
Thanks
Which version of 7zip.exe?
Which compression mode is used in the existing 7z file?
Can you attach\link to a sample 7z archive that you have tried and behaves unexpectedly when trying to add another file without compression?
I am not sure if you can use mixed compression mode in a 7z archive or not.