RK3588开发板中使用Qt对zip文件进行解压

操作步骤:

  1. 下载源码quazip-0.7.3.zip ,在网上找找下载地址
  2. 上传源码进行解压,然后使用命令
    cd quazip-0.7.3
    qmake
    make
  3. 主要用的是quazip-0.7.3/quazip这个里面的源码,然后把源码加入到自己创建的qt项目pro中,导入方式选中项目鼠标右键Add Libary,并导入quazip源码和对应的so库文件
  4. 解压文件代码
cpp 复制代码
 /**文件解压
 * @brief extractFolder
 * @param zipFilePath 解压文件的路径
 * @param extractPath  解压到哪个目录下
 */
bool  extractFolder(const QString& zipFilePath, const QString& extractPath) {
    // 打开 ZIP 文件
    QuaZip zip(zipFilePath);
    if (!zip.open(QuaZip::mdUnzip)) {
        qDebug() << "Failed to open ZIP file";
        return false;
    }
    QDir().mkpath(extractPath);
    // 枚举 ZIP 文件中的所有条目
    QuaZipFileInfo info;
    QuaZipFile zipFile(&zip);
    for (bool more = zip.goToFirstFile(); more; more = zip.goToNextFile()) {
        if (!zip.getCurrentFileInfo(&info)) {
            qDebug() << "Failed to get file info";
            return false;
        }
        // 提取文件
        if (!zipFile.open(QIODevice::ReadOnly)) {
            qDebug() << "Failed to open file inside ZIP";
            return false;
        }
        QString filePath = extractPath + "/" + info.name;
        QDir().mkpath(QFileInfo(filePath).absolutePath());
        QFile outFile(filePath);
        if (!outFile.open(QIODevice::WriteOnly)) {
            qDebug() << "Failed to create output file" << filePath;
            return false;
        }
        outFile.write(zipFile.readAll());
        outFile.close();
        zipFile.close();
    }
    // 关闭 ZIP 文件
    zip.close();
    return true;
}
相关推荐
杨充30 分钟前
1.3 浮点型数据设计灵魂
开发语言·python·算法
噜噜噜阿鲁~33 分钟前
python学习笔记 | 11.3、面向对象高级编程-多重继承
java·开发语言
basketball6161 小时前
Go 语言从入门到进阶:4. 数组和MAP使用方法总结
开发语言·后端·golang
春生野草1 小时前
反射、Tomcat执行
java·开发语言
雪的季节2 小时前
企业级 Qt 全功能项目
开发语言·数据库·qt
代龙涛3 小时前
WordPress page.php 页面模板与自定义模板使用方法
android·开发语言·php
bigfootyazi3 小时前
python爬虫-基本库-urllib库(常用速查)
开发语言·爬虫·python
belong_my_offer3 小时前
认识到精通函数
开发语言·python
guygg883 小时前
最大相关-最小冗余(mRMR)特征选择 MATLAB 实现
开发语言·matlab
郭涤生4 小时前
C++ 高性能编程最佳实践清单
开发语言·c++