PDA

View Full Version : Using quazip for extracting multiple files.



akshaysulakhe
25th July 2013, 10:20
Hello friends,
I am using QuaZip for extracting multiple files from a archive. I just need help on one small thing. As per the documentation of quazip says, amongst, JICompress, there is a method which can be used to extract multiple files at a given time. Link:- http://quazip.sourceforge.net/classJlCompress.html#a309e9ee366719a4d8aa28f837fab 73ae

QStringList JlCompress::extractFiles(QString fileCompressed,QSringList files,QString dir=QString() )[static]
Parameters:
fileCompressed The name of the archive.
files The file list to extract.
dir The directory to put the files to, the current directory if left empty.
Returns:
The list of the full paths of the files extracted, empty on failure.

My apologies for the redundancy. As of now, i have the object and all of JICompress. I want to extract all files from the archive. I dont understand 2 parameters here. The return parameter, I dont understand why its necessary, as we are specifying the path of extraction. And what should i put for the 2nd parameter where is says the file list to extract. How can i say all, there are a lot of files, i cant just go on specifying names for each, as their names might change. Sorry for the long thread. Thank you for your time.

alainstgt
25th July 2013, 15:07
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
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();
}
}

akshaysulakhe
27th July 2013, 09:59
Thanks, i mainly wanted extractDir, which i got from elsewhere.