here a snippet from a library I wrote for my own purpose:
void extractAll( QuaZip& archive )
{
// extracts all files from the archive and saves
// them onto disk
//
// just a simple implementation for evaluation.
// error handling has not been implemented yet!
for( bool f = archive.goToFirstFile(); f; f = archive.goToNextFile() )
{
// set source file in archive
QString filePath
= archive.
getCurrentFileName();
QuaZipFile zFile( archive.getZipName(), filePath );
// open the source file
// create a bytes array and write the file data into it
// close the source file
zFile.close();
// set destination file
QFile dstFile
( filePath
);
// open the destination file
// write the data from the bytes array into the destination file
dstFile.write( ba.data() );
//close the destination file
dstFile.close();
}
}
void extractAll( QuaZip& archive )
{
// extracts all files from the archive and saves
// them onto disk
//
// just a simple implementation for evaluation.
// error handling has not been implemented yet!
for( bool f = archive.goToFirstFile(); f; f = archive.goToNextFile() )
{
// set source file in archive
QString filePath = archive.getCurrentFileName();
QuaZipFile zFile( archive.getZipName(), filePath );
// open the source file
zFile.open( QIODevice::ReadOnly );
// create a bytes array and write the file data into it
QByteArray ba = zFile.readAll();
// close the source file
zFile.close();
// set destination file
QFile dstFile( filePath );
// open the destination file
dstFile.open( QIODevice::WriteOnly | QIODevice::Text );
// write the data from the bytes array into the destination file
dstFile.write( ba.data() );
//close the destination file
dstFile.close();
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks