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;
}
相关推荐
着迷不白6 分钟前
Linux系统故障修复、日志管理与安全加固实战指南
开发语言·php
贺国亚16 分钟前
A2A协议与Agent互操作-Task生命周期
开发语言·qt
炸薯条!34 分钟前
从零开始学C++(4) --类和对象
开发语言·c++·算法
渡我白衣35 分钟前
打印宏与socket模块设计
java·linux·开发语言·c++·ide·人工智能·eclipse
Wang's Blog44 分钟前
Go-Zero框架上手前奏2: 微服务核心要素 —— 拆分、通信与无状态设计
开发语言·微服务·golang
luoyayun3619 小时前
Qt + FFmpeg 视频工具:视频一键压缩功能实现
qt·ffmpeg·音视频·视频压缩
blueman88889 小时前
Qt5通过vcpkg中调用时,在debug模式下调试时总是调用release的plugins文件夹中的dll
c++·qt·cmake
我是坏垠11 小时前
Crypto、Cipher与Password:Java加密开发的三个核心概念
java·开发语言·python
white_ant11 小时前
JDK LTS 版本升级迁移注意事项大全
java·开发语言