Re: Self-extracting archive
qCompress() and qUncompress() work on data, they do not create any files.
Re: Self-extracting archive
Apparently my question was not clear.
I have function which compresses file using qCompress , QFile and QByteArray
Code:
{
QFile file( sourceFile
);
QFile outfile
( compressFile
);
outfile.write( compressedData );
file.close();
outfile.close();
}
And now I would like to create self-extracting option for this file and I think about Qt Installer framework. Maybe you know if I can use it for this purpose?
Re: Self-extracting archive
How would an installer framework create a self-extracting archive? It's an installer framework and not a self-extracting archiver, it creates installers and not self-extracting archives.
And I have no idea how your code snippet is related to the question.
Re: Self-extracting archive
Quote:
And I have no idea how your code snippet is related to the question.
For a compressFile which I use in this code I need create a self-extracting archive.
And I saw that Qt Installer Framework can be customizable so I ask if I can use it for this purpose but ok I understood that not.
So how I can write this tool using Qt and C++?
Re: Self-extracting archive
You can write a program that will uncompress a file embedded into a Qt resource to disk. You don't need to qCompress() the file as resources are already compressed.
Code:
#include <QApplication>
#include <QFileDialog>
#include <QFile>
#include <QString>
int main(int main, char **argv) {
if(path.isEmpty()) return 0;
outfile.
open(QFile::WriteOnly);
while(!f.atEnd()) {
outfile.write(data);
}
return 0;
}
Re: Self-extracting archive
Thanks for thats, cool idea.
But I need create application which allow users to create compress / self-extracting archive. I have some idea but I do not know if I can run script like bash / python or my external program to uncompress when Qt Installer finished instalation( when user click 'finish' button )?
Re: Self-extracting archive
Assuming you want a generic solution, i.e. One that can make a self-extracting compressed file of an arbitrary input file, then you need to write two applications and do some platform-dependent work.
The first application you need is a self-contained, small program that uncompress a stream of data embedded within its own executable. This cannot easily depend on any external library other than those absolutely standard on the target platform; ruling out Qt most likely.
The second application is one that takes an arbitrary file, compresses it and writes a copy of the first program executable, the compressed data, and probably some metadata like original file name and a checksum into a combined file.
The platform-specific part is how you take a complete executable (program 1) and append or insert the compressed data into it so that it will still run and can find the embedded data within itself to uncompress. This can be anything from reasonably easy to quite difficult depending the nature of executables on the platform and things like maintaining exe signatures or avoiding anti-virus defences. A quick Google for "append data to executable" And variations on that theme will get you most of the way fairly quickly for Windows.