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;
}
相关推荐
Cloud_Shy61828 分钟前
解读《Effective Python 3rd Edition》:从练气到老魔(第六章 Item 40 - 43)
android·开发语言·人工智能·笔记·python·学习方法
半只小闲鱼34 分钟前
配置计划模块通用办公设备家具批复数合计计算
开发语言·python
qq_422152571 小时前
Word 文件太大怎么压缩?2026 年文档瘦身方案对比
开发语言·c#·word
charliedev1 小时前
Jedi:Python 自动补全与静态分析的实用工具
开发语言·python·其他
ji198594431 小时前
MATLAB 求散点曲线斜率
开发语言·算法·matlab
kaikaile19951 小时前
MATLAB 实现:Koch & Zhao 图像水印算法(DCT域)
开发语言·算法·matlab
love_muming1 小时前
链表每日一练
java·开发语言·数据结构·链表·idea·每日一练
weixin_446260851 小时前
LLM智能体在社交模拟中的决策行为分析:有限状态与LLM-based策略对比研究
开发语言·php
牛肉在哪里1 小时前
ros2 从零开始28 监听广播C++
开发语言·c++·算法·机器人
techdashen2 小时前
Cargo 1.94 开发周期全解析
开发语言·后端·rust