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

48 lines
1.0 KiB
C++
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#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