.DAT file not extracted using Quazip library in qt

113 views Asked by At

I am trying to extract .DAT file using Quazip library in Qt 5.14. I integrated this quazip library into my project and try to extract files using it. .txt file is get extracted but .DAT file is not get extracted. .DAT files are created but it does not contain any data. Here is my source code

bool fileHelper::extractAll( QString folderPath, QString filePath ) {
    QuaZip zip(filePath);
    zip.open(QuaZip::mdUnzip);
    bool isSuccess = false;
    for(bool f=zip.goToFirstFile(); f; f=zip.goToNextFile())
    {
        // set source file in archive
        QString filePath = zip.getCurrentFileName();
        QuaZipFile zFile( zip.getZipName(), filePath );
        // open the source file
        zFile.open( QIODevice::ReadOnly );
        // create a bytes array and write the file data into it
        //QByteArray ba = zFile.read()
        QByteArray ba = zFile.readAll();
        // close the source file
        zFile.close();
        // set destination file
        //QFile dstFile( getfileStoreRootDir()+filePath );
        QFile dstFile( folderPath+filePath );
        qDebug() << "dstFile :" << dstFile;
        // 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();
        //mark extraction sucess
        isSuccess = true;
    }
    zip.close();
    return isSuccess; }

Please tell me am I doing something wrong or any other extra flag or something is required for it.

0

There are 0 answers