yhkylin-backup-tools/backup-daemon/myprocess/calcbackupsize.h

48 lines
1.0 KiB
C
Raw Permalink Normal View History

2022-11-01 10:40:05 +08:00
#ifndef CALCBACKUPSIZE_H
#define CALCBACKUPSIZE_H
#include <QStringList>
#include <QProcess>
#define GB (1024 * 1024 * 1024)
#define MB (1024 * 1024)
#define KB (1024)
class CalcBackupSize : public QObject
{
Q_OBJECT
public:
CalcBackupSize(QObject* parent = nullptr);
~CalcBackupSize();
/**
* @brief
* @param args rsync参数列表
* @param block true
* @return block为true时返回值为待备份数据大小block为false时0
*/
qint64 start(QStringList args, bool block = true);
void stop() { m_process->kill(); }
signals:
// 计算结束信号
void finished(qint64 size);
private slots:
// process结束槽
void processFinish(int exitCode, QProcess::ExitStatus);
private:
/**
* @brief process的输出结果
*/
void parseResult();
QProcess * m_process;
qint64 m_size = 0; // 备份大小,单位字节
};
#endif // CALCBACKUPSIZE_H