Index: src/ch/MainWnd.cpp =================================================================== diff -u -r4cd45795025411a82006a94d9c7f7f2d9ecda421 -r4e2c8f5d6eb146c14025a2f26cbdbef3910976f9 --- src/ch/MainWnd.cpp (.../MainWnd.cpp) (revision 4cd45795025411a82006a94d9c7f7f2d9ecda421) +++ src/ch/MainWnd.cpp (.../MainWnd.cpp) (revision 4e2c8f5d6eb146c14025a2f26cbdbef3910976f9) @@ -520,7 +520,12 @@ spTask->SetOperationType(bMove ? eOperation_Move : eOperation_Copy); // special status - spTask->SetStatus((bOnlyCreate ? ST_IGNORE_CONTENT : 0) | (bIgnoreDirs ? ST_IGNORE_DIRS : 0) | (bForceDirectories ? ST_FORCE_DIRS : 0), ST_SPECIAL_MASK); + TTaskConfiguration tTaskConfig; + tTaskConfig.SetCreateEmptyFiles(bOnlyCreate != FALSE); + tTaskConfig.SetCreateOnlyDirectories(bForceDirectories != FALSE); + tTaskConfig.SetIgnoreDirectories(bIgnoreDirs != FALSE); + + spTask->SetTaskConfiguration(tTaskConfig); // set some stuff related with task spTask->SetBufferSizes(&bsSizes); @@ -600,8 +605,12 @@ spTask->SetOperationType((dlg.m_ccData.m_iOperation == 1) ? eOperation_Move : eOperation_Copy); // special status - spTask->SetStatus((dlg.m_ccData.m_bCreateStructure ? ST_IGNORE_CONTENT : 0) | (dlg.m_ccData.m_bIgnoreFolders ? ST_IGNORE_DIRS : 0) - | (dlg.m_ccData.m_bForceDirectories ? ST_FORCE_DIRS : 0), ST_SPECIAL_MASK); + TTaskConfiguration tTaskConfig; + tTaskConfig.SetCreateEmptyFiles(dlg.m_ccData.m_bCreateStructure); + tTaskConfig.SetCreateOnlyDirectories(dlg.m_ccData.m_bForceDirectories); + tTaskConfig.SetIgnoreDirectories(dlg.m_ccData.m_bIgnoreFolders); + + spTask->SetTaskConfiguration(tTaskConfig); spTask->SetBufferSizes(&dlg.m_ccData.m_bsSizes); spTask->SetPriority(dlg.m_ccData.m_iPriority); Index: src/ch/task.cpp =================================================================== diff -u -r79b981925588ba300cae07d965e12aa590aa7a91 -r4e2c8f5d6eb146c14025a2f26cbdbef3910976f9 --- src/ch/task.cpp (.../task.cpp) (revision 79b981925588ba300cae07d965e12aa590aa7a91) +++ src/ch/task.cpp (.../task.cpp) (revision 4e2c8f5d6eb146c14025a2f26cbdbef3910976f9) @@ -487,12 +487,62 @@ } //////////////////////////////////////////////////////////////////////////// +// class TTaskConfiguration + +TTaskConfiguration::TTaskConfiguration() : + m_iConfigFlags(eFlag_None) +{ +} + +TTaskConfiguration::~TTaskConfiguration() +{ +} + +bool TTaskConfiguration::GetIgnoreDirectories() const +{ + return m_iConfigFlags & eFlag_IgnoreDirectories; +} + +void TTaskConfiguration::SetIgnoreDirectories(bool bIgnoreDirectories) +{ + if(bIgnoreDirectories) + m_iConfigFlags |= eFlag_IgnoreDirectories; + else + m_iConfigFlags &= ~eFlag_IgnoreDirectories; +} + +bool TTaskConfiguration::GetCreateEmptyFiles() const +{ + return m_iConfigFlags & eFlag_CreateEmptyFiles; +} + +void TTaskConfiguration::SetCreateEmptyFiles(bool bCreateEmptyFiles) +{ + if(bCreateEmptyFiles) + m_iConfigFlags |= eFlag_CreateEmptyFiles; + else + m_iConfigFlags &= ~eFlag_CreateEmptyFiles; +} + +bool TTaskConfiguration::GetCreateOnlyDirectories() const +{ + return m_iConfigFlags & eFlag_CreateOnlyDirectories; +} + +void TTaskConfiguration::SetCreateOnlyDirectories(bool bCreateOnlyDirectories) +{ + if(bCreateOnlyDirectories) + m_iConfigFlags |= eFlag_CreateOnlyDirectories; + else + m_iConfigFlags &= ~eFlag_CreateOnlyDirectories; +} + +//////////////////////////////////////////////////////////////////////////// // CTask members CTask::CTask(chcore::IFeedbackHandler* piFeedbackHandler, size_t stSessionUniqueID) : m_log(), m_piFeedbackHandler(piFeedbackHandler), m_files(m_clipboard), - m_nStatus(ST_NULL_STATUS), m_nPriority(THREAD_PRIORITY_NORMAL), m_bForce(false), m_bContinue(false), @@ -627,20 +677,6 @@ return m_dpDestPath.GetDriveNumber(); } -// m_nStatus -void CTask::SetStatus(UINT nStatus, UINT nMask) -{ - boost::unique_lock lock(m_lock); - m_nStatus &= ~nMask; - m_nStatus |= nStatus; -} - -UINT CTask::GetStatus(UINT nMask) -{ - boost::shared_lock lock(m_lock); - return m_nStatus & nMask; -} - void CTask::SetTaskState(ETaskCurrentState eTaskState) { // NOTE: we could check some transition rules here @@ -664,6 +700,16 @@ return m_tOperation.GetOperationType(); } +void CTask::SetTaskConfiguration(const TTaskConfiguration& tTaskConfiguration) +{ + m_tTaskConfig = tTaskConfiguration; +} + +const TTaskConfiguration& CTask::GetTaskConfiguration() const +{ + return m_tTaskConfig; +} + // m_nBufferSize void CTask::SetBufferSizes(const BUFFERSIZES* bsSizes) { @@ -741,6 +787,7 @@ { m_clipboard.Load(ar, 0, bData); ar >> m_tOperation; + ar >> m_tTaskConfig; m_files.Load(ar, 0, false); @@ -753,16 +800,12 @@ } else { - UINT uiData = 0; int iState = eTaskState_None; ar >> m_tTaskProgressInfo; CalculateProcessedSizeNL(); - ar >> uiData; - m_nStatus = uiData; - // load task state, convert "waiting" state to "processing" ar >> iState; if(iState >= eTaskState_None && iState < eTaskState_Max) @@ -801,7 +844,7 @@ if(!bData && m_bSaved) return; - if(!bData && !m_bSaved && (m_eCurrentState == eTaskState_Finished || m_eCurrentState == eTaskState_Cancelled || m_nStatus == eTaskState_Paused)) + if(!bData && !m_bSaved && (m_eCurrentState == eTaskState_Finished || m_eCurrentState == eTaskState_Cancelled || m_eCurrentState == eTaskState_Paused)) { m_bSaved = true; } @@ -816,6 +859,7 @@ m_clipboard.Store(ar, 0, bData); ar << m_tOperation; + ar << m_tTaskConfig; ESubOperationType eSubOperation = m_tOperation.GetSubOperationAt(m_tTaskProgressInfo.GetSubOperationIndex()); if(eSubOperation != eSubOperation_Scanning) @@ -834,9 +878,6 @@ { ar << m_tTaskProgressInfo; - UINT uiStatus = m_nStatus; - ar << uiStatus; - // store current state (convert from waiting to processing state before storing) int iState = m_eCurrentState; if(iState == eTaskState_Waiting) @@ -1070,12 +1111,12 @@ _tcscat(pData->m_szStatusText, GetResManager().LoadString(IDS_STATUS0_STRING+7)); // third part - if( (m_nStatus & ST_SPECIAL_MASK) & ST_IGNORE_DIRS ) + if(m_tTaskConfig.GetIgnoreDirectories()) { _tcscat(pData->m_szStatusText, _T("/")); _tcscat(pData->m_szStatusText, GetResManager().LoadString(IDS_STATUS0_STRING+10)); } - if( (m_nStatus & ST_SPECIAL_MASK) & ST_IGNORE_CONTENT ) + if(m_tTaskConfig.GetCreateEmptyFiles()) { _tcscat(pData->m_szStatusText, _T("/")); _tcscat(pData->m_szStatusText, GetResManager().LoadString(IDS_STATUS0_STRING+11)); @@ -1194,18 +1235,6 @@ return bResult != 0; } -// m_nStatus -void CTask::SetStatusNL(UINT nStatus, UINT nMask) -{ - m_nStatus &= ~nMask; - m_nStatus |= nStatus; -} - -UINT CTask::GetStatusNL(UINT nMask) -{ - return m_nStatus & nMask; -} - // m_nBufferSize void CTask::SetBufferSizesNL(const BUFFERSIZES* bsSizes) { @@ -1277,8 +1306,8 @@ // enter some data to m_files int iDestDrvNumber = GetDestDriveNumber(); - bool bIgnoreDirs = (GetStatus(ST_SPECIAL_MASK) & ST_IGNORE_DIRS) != 0; - bool bForceDirectories = (GetStatus(ST_SPECIAL_MASK) & ST_FORCE_DIRS) != 0; + bool bIgnoreDirs = m_tTaskConfig.GetIgnoreDirectories(); + bool bForceDirectories = m_tTaskConfig.GetCreateOnlyDirectories(); bool bMove = GetOperationType() == eOperation_Move; // add everything @@ -2269,14 +2298,14 @@ // begin at index which wasn't processed previously size_t stSize = m_files.GetSize(); - bool bIgnoreFolders = (GetStatus(ST_SPECIAL_MASK) & ST_IGNORE_DIRS) != 0; - bool bForceDirectories = (GetStatus(ST_SPECIAL_MASK) & ST_FORCE_DIRS) != 0; + bool bIgnoreFolders = m_tTaskConfig.GetIgnoreDirectories(); + bool bForceDirectories = m_tTaskConfig.GetCreateOnlyDirectories(); const CDestPath& dpDestPath = GetDestPath(); // create a buffer of size m_nBufferSize CUSTOM_COPY_PARAMS ccp; ccp.bProcessed = false; - ccp.bOnlyCreate=(GetStatus(ST_SPECIAL_MASK) & ST_IGNORE_CONTENT) != 0; + ccp.bOnlyCreate = m_tTaskConfig.GetCreateEmptyFiles(); ccp.dbBuffer.Create(GetBufferSizes()); ccp.pDestPath = &dpDestPath; Index: src/ch/task.h =================================================================== diff -u -r79b981925588ba300cae07d965e12aa590aa7a91 -r4e2c8f5d6eb146c14025a2f26cbdbef3910976f9 --- src/ch/task.h (.../task.h) (revision 79b981925588ba300cae07d965e12aa590aa7a91) +++ src/ch/task.h (.../task.h) (revision 4e2c8f5d6eb146c14025a2f26cbdbef3910976f9) @@ -26,17 +26,6 @@ #include "FileFilter.h" #include "DestPath.h" -class CDestPath; - -#define ST_NULL_STATUS 0x00000000 - -//------------------------------------ -#define ST_SPECIAL_MASK 0x0000f000 -// simultaneous flags -#define ST_IGNORE_DIRS 0x00001000 -#define ST_IGNORE_CONTENT 0x00002000 -#define ST_FORCE_DIRS 0x00004000 - // enum representing current processing state of the task enum ETaskCurrentState { @@ -314,7 +303,7 @@ }; /////////////////////////////////////////////////////////////////////////// -// CTask +// TTaskProgressInfo class TTaskProgressInfo { @@ -418,6 +407,40 @@ mutable boost::shared_mutex m_lock; }; +class TTaskConfiguration +{ +public: + enum EFlags + { + eFlag_None = 0, + eFlag_IgnoreDirectories = 0x0001, + eFlag_CreateEmptyFiles = 0x0002, + eFlag_CreateOnlyDirectories = 0x0004 + }; + +public: + TTaskConfiguration(); + ~TTaskConfiguration(); + + bool GetIgnoreDirectories() const; + void SetIgnoreDirectories(bool bIgnoreDirectories); + + bool GetCreateEmptyFiles() const; + void SetCreateEmptyFiles(bool bCreateEmptyFiles); + + bool GetCreateOnlyDirectories() const; + void SetCreateOnlyDirectories(bool bCreateOnlyDirectories); + + template + void serialize(Archive& ar, unsigned int /*uiVersion*/) + { + ar & m_iConfigFlags; + } + +private: + int m_iConfigFlags; +}; + /////////////////////////////////////////////////////////////////////////// // CTask @@ -450,16 +473,15 @@ void SetFilters(const CFiltersArray* pFilters); - // m_nStatus - void SetStatus(UINT nStatus, UINT nMask); - UINT GetStatus(UINT nMask = 0xffffffff); - void SetTaskState(ETaskCurrentState eTaskState); ETaskCurrentState GetTaskState() const; void SetOperationType(EOperationType eOperationType); EOperationType GetOperationType() const; + void SetTaskConfiguration(const TTaskConfiguration& tTaskConfiguration); + const TTaskConfiguration& GetTaskConfiguration() const; + // m_nBufferSize void SetBufferSizes(const BUFFERSIZES* bsSizes); const BUFFERSIZES* GetBufferSizes(); @@ -601,7 +623,7 @@ TOperationDescription m_tOperation; // manages the operation and its suboperations - volatile UINT m_nStatus; // what phase of the operation is this task in + TTaskConfiguration m_tTaskConfig; // task configuration options TTaskProgressInfo m_tTaskProgressInfo; // task progress information