57 lines
1.5 KiB
C++
57 lines
1.5 KiB
C++
#ifndef RM_OVERWRITE_H
|
|
#define RM_OVERWRITE_H
|
|
|
|
#include <QWaitCondition>
|
|
#include <QObject>
|
|
#include <QMutex>
|
|
|
|
// 백업시 파일 존재할 경우 처리 방법
|
|
typedef enum
|
|
{
|
|
OVERWRITE_OPTION_ASK = 1 << 0, // 확인
|
|
OVERWRITE_OPTION_SKIP = 1 << 1, // 스킵
|
|
OVERWRITE_OPTION_WRITE = 1 << 2, // 덮어쓰기
|
|
OVERWRITE_OPTION_CANCEL = 1 << 3, // 취소
|
|
OVERWRITE_OPTION_ALL = 1 << 4, // 전체
|
|
} OVERWRITE_OPTION;
|
|
|
|
|
|
class RMOverwrite
|
|
{
|
|
private:
|
|
static QMutex _lock; // 프로세스 잠금/WAIT (백업 중 동일 파일 존재 ETC)
|
|
static QWaitCondition _wait; // 대기
|
|
|
|
public:
|
|
static void lock () {
|
|
RMOverwrite::_lock.lock();
|
|
}
|
|
static void unlock () {
|
|
RMOverwrite::_lock.unlock();
|
|
}
|
|
static void wait() {
|
|
RMOverwrite::_wait.wait(&RMOverwrite::_lock);
|
|
}
|
|
static void unwait() {
|
|
RMOverwrite::_wait.wakeAll();
|
|
}
|
|
|
|
static void reset() {
|
|
RMOverwrite::gCurrent = OVERWRITE_OPTION_ASK;
|
|
RMOverwrite::currentFileName = "";
|
|
RMOverwrite::currentCount = 0;
|
|
}
|
|
|
|
static QString currentFileName; // 중복된 파일명
|
|
static int currentCount; // 남은 파일 개수
|
|
|
|
//static OVERWRITE_OPTION gGlobal; // 전체 옵션 (eg. 모두 skip, etc)
|
|
static int gCurrent; // 현재 옵션 (다이얼로그 선택)
|
|
|
|
static bool check(OVERWRITE_OPTION with) {
|
|
return ((RMOverwrite::gCurrent & with) == with);
|
|
}
|
|
};
|
|
|
|
#endif // RM_OVERWRITE_H
|