quazip使用

quazip是一个QT下实现的压缩和解压库

下载地址:

Releases · stachenov/quazip · GitHub

quazip已经是带了内存中解压和压缩的功能,但是没有封装到JlCompress

在编译quazip时需要JlCompress类中的static bool compressFile(QuaZip* zip, QString fileName, QString fileDest);等几个private函数修改为protected,因为我是继承了JlCompress类,需要使用bool compressFile(QuaZip* zip, QString fileName, QString fileDest);函数。

下面是我实现的JlCompressEx类,

头文件内容

#pragma once
 
 
#include "quazip/JlCompress.h"
#include "quazip/quazip.h"
 
#include <QBuffer>
#include <QByteArray>
 
class JlCompressEx : public JlCompress
{
public:
    // 文件压缩到内存buffer,zipIoDevice可以使用QBuffer zipBuffer;
    static bool CompressToBuffer(QString file, const char *password, QIODevice& zipIoDevice);
    // 内存数据压缩到内存buffer
    static bool CompressToBuffer(QByteArray& sourceData, QString fileName, const char *password, QIODevice& zipIoDevice);
    // 文件压缩到内存buffer
    static bool CompressToBuffer(QStringList files, const char *password, QIODevice& zipIoDevice);
    /**
      \ 重写JlCompress::compressFile,添加密码参数
      \param zip Opened zip to compress the file to.
      \param fileName The full path to the source file.
      \param fileDest The full name of the file inside the archive.
      \return true if success, false otherwise.
    */
    static bool compressFileEx(QuaZip* zip, QString fileName, QString fileDest, const char *password);
public:
    // 压缩数据
    static bool CompressBuffer(QuaZip& zip, QByteArray& sourceData, QString fileName, const char *password);
    
public:
    // 解压,解压出来所有文件数据保存在filesList<文件名, 文件内容>
    static bool extractToBuffer(const QString& strZipFile, const char *password, QList<QPai

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

季截

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值