首页 > 解决方案 > .DAT 文件未在 qt 中使用 Quazip 库提取

问题描述

我正在尝试使用 Qt 5.14 中的 Quazip 库提取 .DAT 文件。我将这个 quazip 库集成到我的项目中,并尝试使用它来提取文件。.txt 文件被提取,但 .DAT 文件未被提取。.DAT 文件已创建,但不包含任何数据。这是我的源代码

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; }

请告诉我我做错了什么或任何其他额外的标志或需要它的东西。

标签: qtextractunzipzipfilequazip

解决方案


推荐阅读