yhkylin-backup-tools/common/utils.h

155 lines
4.2 KiB
C
Raw Normal View History

2021-08-06 10:20:03 +08:00
#ifndef UTILS_H
#define UTILS_H
#include <QString>
#include <QtDebug>
#include "mydefine.h"
/**
* @brief
* @author zhaominyong
* @since 2021/07/22
*/
class Utils
{
public:
/**
* @brief initSysRootPath,
* @param qsAppPath
*/
static void initSysRootPath(const QString& qsAppPath);
/**
* @brief getSysRootPath
* @return const QString&
* @note
* initSysRootPath/
*/
static const QString& getSysRootPath() { return m_sysRootPath; }
/**
* @brief customMessageHandler
* @param type debug等
* @param context
* @param msg
*/
static void customMessageHandler(QtMsgType type, const QMessageLogContext& context, const QString& msg);
/**
* @brief
* @param frontUidid
* @return
*/
static int lockProgram(int frontUid);
/**
* @brief
* @param lock_file_fd
* @return 01
*/
static int unLockProgram(int lock_file_fd);
/**
* @brief
* @return bool
*/
static bool rmLockFile();
/**
* @brief /etc/.bootinfo是否存在并可读UUID等信息
* @return bool
*/
static bool checkBootInfoExists();
/**
* @brief UUID
* @return UUID
*/
static QString getBackupPartitionUuid();
/**
* @brief
* @param path
*/
static void mkdir(const QString& path);
/**
* @brief
* @param path
* @return bool
*/
static bool mkpath(const QString& path);
/**
* @brief
* @param excludes
*/
static void excludeFstabBindPath(QStringList &excludes);
/**
2021-08-17 10:07:35 +08:00
* @brief rsync --exclude-from排除路径规则文件
2021-08-06 10:20:03 +08:00
* @return
*/
static bool generateExcludePathsFile();
2021-08-17 10:07:35 +08:00
/**
* @brief
* @return
*/
static QStringList getFromExcludePathsFile();
/**
* @brief
* @param
* @return true,false,
*/
static bool isDirExist(const QString& fullDirName);
2021-08-24 18:08:18 +08:00
/**
* @brief Uuid
* @return UUID
*/
static QString createUuid();
/**
* @brief
* @param fileName
* @param lines
* @return truefalse
*/
static bool writeFileByLines(const QString& fileName, const QStringList& lines);
/**
* @brief
* @param fileName
* @return booltrue-false-
* @author zhaominyong
* @since 2021/05/29
*/
static bool filsExists(const QString &fileName);
/**
* @brief
* @param line
* @return bool, true-false-
* @author zhaominyong
* @since 2021/05/29
* @note
* rebootfdatasync确保缓存落盘
*/
static bool writeBackupLog(QString line);
/**
* @brief GB等表示的字符串
* @param sizeqint64
* @return GB/MB/KB等表示的字符串型大小
*/
static QString StringBySize(qint64 size);
2021-08-06 10:20:03 +08:00
private:
// 系统根目录,默认"/"
static QString m_sysRootPath;
};
#endif // UTILS_H