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;
}
相关推荐
君顾113 小时前
酒吧点餐小程序系统开发实战:从架构设计到上线全流程指南
java·开发语言·酒吧
Quz13 小时前
QML Loader:从文件加载组件、加载内联组件
qt
Quz13 小时前
QML Loader: 状态监听与动态标签页
qt
似水এ᭄往昔13 小时前
【Qt】--常用控件(显示类控件)
开发语言·qt
PHP实战开发录13 小时前
PHP文件上传成功为什么页面却找不到
开发语言·nginx·php·开发
云小逸15 小时前
C++ 第一阶段:对象、内存与生命周期
开发语言·c++
玖玥拾15 小时前
Lua 基础语法(二)
开发语言·unity·lua
王的宝库15 小时前
GO常用标准库包
开发语言·后端·golang
geovindu15 小时前
python: Face Recognition
开发语言·后端·python·人脸识别
平头哥技术团队15 小时前
Day 13 | 调 line-height 和 margin:三处间距让名片页脱离模板感
开发语言·前端·javascript·学习·html5