Index: src/ch/CfgProperties.h =================================================================== diff -u -N -rad9bc5d98b91dc9f680742afbf4990b2b6dcda30 -rfb4c4006dee5aaf815d08bc3e89312445b994307 --- src/ch/CfgProperties.h (.../CfgProperties.h) (revision ad9bc5d98b91dc9f680742afbf4990b2b6dcda30) +++ src/ch/CfgProperties.h (.../CfgProperties.h) (revision fb4c4006dee5aaf815d08bc3e89312445b994307) @@ -21,7 +21,7 @@ #pragma once -#include "TTaskConfiguration.h" +#include "../libchcore/TTaskConfiguration.h" namespace chcore { class TConfig; } @@ -148,9 +148,9 @@ #define ADAPT_TASK_PROPERTY(enum_id, task_enum_id)\ template<> struct PropData\ {\ - typedef TaskPropData::value_type value_type;\ - static value_type GetDefaultValue() { return TaskPropData::GetDefaultValue(); }\ - static const wchar_t* GetPropertyName() { return TaskPropData::GetPropertyName(); }\ + typedef chcore::TaskPropData::value_type value_type;\ + static value_type GetDefaultValue() { return chcore::TaskPropData::GetDefaultValue(); }\ + static const wchar_t* GetPropertyName() { return chcore::TaskPropData::GetPropertyName(); }\ static const wchar_t* GetPropertyNamePrefix() { return BRANCH_TASK_SETTINGS _T("."); }\ } @@ -211,22 +211,22 @@ PROPERTY(PP_CMLIMITMAXOPERATIONS, unsigned int, _T("CHConfig.Core.Operation.LimitMaxOperations"), 1); // Task default settings (see TTaskConfiguration.h) -ADAPT_TASK_PROPERTY(PP_BFUSEONLYDEFAULT, eTO_UseOnlyDefaultBuffer); -ADAPT_TASK_PROPERTY(PP_BFDEFAULT, eTO_DefaultBufferSize); -ADAPT_TASK_PROPERTY(PP_BFONEDISK, eTO_OneDiskBufferSize); -ADAPT_TASK_PROPERTY(PP_BFTWODISKS, eTO_TwoDisksBufferSize); -ADAPT_TASK_PROPERTY(PP_BFCD, eTO_CDBufferSize); -ADAPT_TASK_PROPERTY(PP_BFLAN, eTO_LANBufferSize); -ADAPT_TASK_PROPERTY(PP_BFUSENOBUFFERING, eTO_DisableBuffering); -ADAPT_TASK_PROPERTY(PP_BFBOUNDARYLIMIT, eTO_DisableBufferingMinSize); +ADAPT_TASK_PROPERTY(PP_BFUSEONLYDEFAULT, chcore::eTO_UseOnlyDefaultBuffer); +ADAPT_TASK_PROPERTY(PP_BFDEFAULT, chcore::eTO_DefaultBufferSize); +ADAPT_TASK_PROPERTY(PP_BFONEDISK, chcore::eTO_OneDiskBufferSize); +ADAPT_TASK_PROPERTY(PP_BFTWODISKS, chcore::eTO_TwoDisksBufferSize); +ADAPT_TASK_PROPERTY(PP_BFCD, chcore::eTO_CDBufferSize); +ADAPT_TASK_PROPERTY(PP_BFLAN, chcore::eTO_LANBufferSize); +ADAPT_TASK_PROPERTY(PP_BFUSENOBUFFERING, chcore::eTO_DisableBuffering); +ADAPT_TASK_PROPERTY(PP_BFBOUNDARYLIMIT, chcore::eTO_DisableBufferingMinSize); -ADAPT_TASK_PROPERTY(PP_CMSETDESTATTRIBUTES, eTO_SetDestinationAttributes); -ADAPT_TASK_PROPERTY(PP_CMSETDESTDATE, eTO_SetDestinationDateTime); -ADAPT_TASK_PROPERTY(PP_CMPROTECTROFILES, eTO_ProtectReadOnlyFiles); -ADAPT_TASK_PROPERTY(PP_CMREADSIZEBEFOREBLOCKING, eTO_ScanDirectoriesBeforeBlocking); -ADAPT_TASK_PROPERTY(PP_CMDEFAULTPRIORITY, eTO_ThreadPriority); -ADAPT_TASK_PROPERTY(PP_CMDISABLEPRIORITYBOOST, eTO_DisablePriorityBoost); -ADAPT_TASK_PROPERTY(PP_CMDELETEAFTERFINISHED, eTO_DeleteInSeparateSubTask); +ADAPT_TASK_PROPERTY(PP_CMSETDESTATTRIBUTES, chcore::eTO_SetDestinationAttributes); +ADAPT_TASK_PROPERTY(PP_CMSETDESTDATE, chcore::eTO_SetDestinationDateTime); +ADAPT_TASK_PROPERTY(PP_CMPROTECTROFILES, chcore::eTO_ProtectReadOnlyFiles); +ADAPT_TASK_PROPERTY(PP_CMREADSIZEBEFOREBLOCKING, chcore::eTO_ScanDirectoriesBeforeBlocking); +ADAPT_TASK_PROPERTY(PP_CMDEFAULTPRIORITY, chcore::eTO_ThreadPriority); +ADAPT_TASK_PROPERTY(PP_CMDISABLEPRIORITYBOOST, chcore::eTO_DisablePriorityBoost); +ADAPT_TASK_PROPERTY(PP_CMDELETEAFTERFINISHED, chcore::eTO_DeleteInSeparateSubTask); // Shell extension PROPERTY(PP_SHSHOWCOPY, bool, _T("CHConfig.ShellExtension.ShowCommands.Copy"), true); Index: src/ch/ClipboardMonitor.cpp =================================================================== diff -u -N -rab32897e61cc637a1e28d9dc3f0489b8d16a429c -rfb4c4006dee5aaf815d08bc3e89312445b994307 --- src/ch/ClipboardMonitor.cpp (.../ClipboardMonitor.cpp) (revision ab32897e61cc637a1e28d9dc3f0489b8d16a429c) +++ src/ch/ClipboardMonitor.cpp (.../ClipboardMonitor.cpp) (revision fb4c4006dee5aaf815d08bc3e89312445b994307) @@ -178,8 +178,8 @@ tTaskDefinition.SetDestinationPath(chcore::PathFromString(strData)); // load resource strings - SetTaskPropValue(tTaskDefinition.GetConfiguration(), GetResManager().LoadString(IDS_FIRSTCOPY_STRING)); - SetTaskPropValue(tTaskDefinition.GetConfiguration(), GetResManager().LoadString(IDS_NEXTCOPY_STRING)); + chcore::SetTaskPropValue(tTaskDefinition.GetConfiguration(), GetResManager().LoadString(IDS_FIRSTCOPY_STRING)); + chcore::SetTaskPropValue(tTaskDefinition.GetConfiguration(), GetResManager().LoadString(IDS_NEXTCOPY_STRING)); CTaskPtr spTask = pData->m_pTasks->CreateTask(tTaskDefinition); Index: src/ch/CustomCopyDlg.cpp =================================================================== diff -u -N -ra795c6fee89a6f17d437d7030a54d8d5ecf1ae17 -rfb4c4006dee5aaf815d08bc3e89312445b994307 --- src/ch/CustomCopyDlg.cpp (.../CustomCopyDlg.cpp) (revision a795c6fee89a6f17d437d7030a54d8d5ecf1ae17) +++ src/ch/CustomCopyDlg.cpp (.../CustomCopyDlg.cpp) (revision fb4c4006dee5aaf815d08bc3e89312445b994307) @@ -223,7 +223,7 @@ m_ctlPriority.AddString(GetResManager().LoadString(IDS_PRIORITY0_STRING+stIndex)); } - m_ctlPriority.SetCurSel(PriorityToIndex(GetTaskPropValue(m_tTaskDefinition.GetConfiguration()))); + m_ctlPriority.SetCurSel(PriorityToIndex(chcore::GetTaskPropValue(m_tTaskDefinition.GetConfiguration()))); // fill buffer sizes listbox SetBuffersizesString(); @@ -279,14 +279,14 @@ m_ctlFilters.InsertColumn(6, &lvc); chcore::TFiltersArray afFilters; - GetTaskPropValue(m_tTaskDefinition.GetConfiguration(), afFilters); + chcore::GetTaskPropValue(m_tTaskDefinition.GetConfiguration(), afFilters); m_bFilters = !afFilters.IsEmpty(); // other custom flags - m_bIgnoreFolders = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); - m_bForceDirectories = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); - m_bOnlyCreate = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); + m_bIgnoreFolders = chcore::GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); + m_bForceDirectories = chcore::GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); + m_bOnlyCreate = chcore::GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); m_bAdvanced = (m_bIgnoreFolders | m_bForceDirectories | m_bOnlyCreate); UpdateData(FALSE); @@ -379,7 +379,7 @@ m_ctlFilters.InsertColumn(6, &lvc); // refresh the entries in filters' list - chcore::TFiltersArray afFilters = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); + chcore::TFiltersArray afFilters = chcore::GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); m_ctlFilters.DeleteAllItems(); for(size_t stIndex = 0; stIndex < afFilters.GetSize(); ++stIndex) { @@ -487,11 +487,11 @@ m_tTaskDefinition.SetOperationType(m_ctlOperation.GetCurSel() == 0 ? chcore::eOperation_Copy: chcore::eOperation_Move); // priority - SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), IndexToPriority(m_ctlPriority.GetCurSel())); + chcore::SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), IndexToPriority(m_ctlPriority.GetCurSel())); - SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), (m_bIgnoreFolders != 0)); - SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), (m_bForceDirectories != 0)); - SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), (m_bOnlyCreate != 0)); + chcore::SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), (m_bIgnoreFolders != 0)); + chcore::SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), (m_bForceDirectories != 0)); + chcore::SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), (m_bOnlyCreate != 0)); CLanguageDialog::OnOK(); } @@ -512,12 +512,12 @@ ictranslate::CFormat fmt; chcore::TBufferSizes bsSizes; - bsSizes.SetOnlyDefault(GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); - bsSizes.SetDefaultSize(GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); - bsSizes.SetOneDiskSize(GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); - bsSizes.SetTwoDisksSize(GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); - bsSizes.SetCDSize(GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); - bsSizes.SetLANSize(GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); + bsSizes.SetOnlyDefault(chcore::GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); + bsSizes.SetDefaultSize(chcore::GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); + bsSizes.SetOneDiskSize(chcore::GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); + bsSizes.SetTwoDisksSize(chcore::GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); + bsSizes.SetCDSize(chcore::GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); + bsSizes.SetLANSize(chcore::GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); fmt.SetFormat(GetResManager().LoadString(IDS_BSEDEFAULT_STRING)); fmt.SetParam(_t("%size"), GetSizeString(bsSizes.GetDefaultSize(), szSize, 64, true)); @@ -547,21 +547,21 @@ { CBufferSizeDlg dlg; - dlg.m_bsSizes.SetOnlyDefault(GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); - dlg.m_bsSizes.SetDefaultSize(GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); - dlg.m_bsSizes.SetOneDiskSize(GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); - dlg.m_bsSizes.SetTwoDisksSize(GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); - dlg.m_bsSizes.SetCDSize(GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); - dlg.m_bsSizes.SetLANSize(GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); + dlg.m_bsSizes.SetOnlyDefault(chcore::GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); + dlg.m_bsSizes.SetDefaultSize(chcore::GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); + dlg.m_bsSizes.SetOneDiskSize(chcore::GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); + dlg.m_bsSizes.SetTwoDisksSize(chcore::GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); + dlg.m_bsSizes.SetCDSize(chcore::GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); + dlg.m_bsSizes.SetLANSize(chcore::GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); if(dlg.DoModal() == IDOK) { - SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), dlg.m_bsSizes.IsOnlyDefault()); - SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), dlg.m_bsSizes.GetDefaultSize()); - SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), dlg.m_bsSizes.GetOneDiskSize()); - SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), dlg.m_bsSizes.GetTwoDisksSize()); - SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), dlg.m_bsSizes.GetCDSize()); - SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), dlg.m_bsSizes.GetLANSize()); + chcore::SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), dlg.m_bsSizes.IsOnlyDefault()); + chcore::SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), dlg.m_bsSizes.GetDefaultSize()); + chcore::SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), dlg.m_bsSizes.GetOneDiskSize()); + chcore::SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), dlg.m_bsSizes.GetTwoDisksSize()); + chcore::SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), dlg.m_bsSizes.GetCDSize()); + chcore::SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), dlg.m_bsSizes.GetLANSize()); SetBuffersizesString(); } @@ -593,7 +593,7 @@ CFilterDlg dlg; chcore::TString strData; - chcore::TFiltersArray afFilters = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); + chcore::TFiltersArray afFilters = chcore::GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); for (size_t i = 0; i < afFilters.GetSize(); i++) { const chcore::TFileFilter* pFilter = afFilters.GetAt(i); @@ -612,7 +612,7 @@ if(dlg.m_ffFilter.GetUseMask() || dlg.m_ffFilter.GetUseExcludeMask() || dlg.m_ffFilter.GetUseSize1() || dlg.m_ffFilter.GetUseDateTime1() || dlg.m_ffFilter.GetUseAttributes()) { afFilters.Add(dlg.m_ffFilter); - SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), afFilters); + chcore::SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), afFilters); AddFilter(dlg.m_ffFilter); } else @@ -760,7 +760,7 @@ void CCustomCopyDlg::OnRemovefilterButton() { - chcore::TFiltersArray afFilters = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); + chcore::TFiltersArray afFilters = chcore::GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); POSITION pos; int iItem; @@ -775,7 +775,7 @@ m_ctlFilters.DeleteItem(iItem); afFilters.RemoveAt(iItem); - SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), afFilters); + chcore::SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), afFilters); } } } @@ -821,7 +821,7 @@ POSITION pos = m_ctlFilters.GetFirstSelectedItemPosition(); if(pos != NULL) { - chcore::TFiltersArray afFilters = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); + chcore::TFiltersArray afFilters = chcore::GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); int iItem = m_ctlFilters.GetNextSelectedItem(pos); CFilterDlg dlg; @@ -855,7 +855,7 @@ || dlg.m_ffFilter.GetUseDateTime1() || dlg.m_ffFilter.GetUseAttributes()) { afFilters.SetAt(iItem, dlg.m_ffFilter); - SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), afFilters); + chcore::SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), afFilters); AddFilter(dlg.m_ffFilter, iItem); } } @@ -871,22 +871,22 @@ { CBufferSizeDlg dlg; - dlg.m_bsSizes.SetOnlyDefault(GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); - dlg.m_bsSizes.SetDefaultSize(GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); - dlg.m_bsSizes.SetOneDiskSize(GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); - dlg.m_bsSizes.SetTwoDisksSize(GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); - dlg.m_bsSizes.SetCDSize(GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); - dlg.m_bsSizes.SetLANSize(GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); + dlg.m_bsSizes.SetOnlyDefault(chcore::GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); + dlg.m_bsSizes.SetDefaultSize(chcore::GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); + dlg.m_bsSizes.SetOneDiskSize(chcore::GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); + dlg.m_bsSizes.SetTwoDisksSize(chcore::GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); + dlg.m_bsSizes.SetCDSize(chcore::GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); + dlg.m_bsSizes.SetLANSize(chcore::GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); dlg.m_iActiveIndex = iItem; if(dlg.DoModal() == IDOK) { - SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), dlg.m_bsSizes.IsOnlyDefault()); - SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), dlg.m_bsSizes.GetDefaultSize()); - SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), dlg.m_bsSizes.GetOneDiskSize()); - SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), dlg.m_bsSizes.GetTwoDisksSize()); - SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), dlg.m_bsSizes.GetCDSize()); - SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), dlg.m_bsSizes.GetLANSize()); + chcore::SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), dlg.m_bsSizes.IsOnlyDefault()); + chcore::SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), dlg.m_bsSizes.GetDefaultSize()); + chcore::SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), dlg.m_bsSizes.GetOneDiskSize()); + chcore::SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), dlg.m_bsSizes.GetTwoDisksSize()); + chcore::SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), dlg.m_bsSizes.GetCDSize()); + chcore::SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), dlg.m_bsSizes.GetLANSize()); SetBuffersizesString(); } Index: src/ch/MainWnd.cpp =================================================================== diff -u -N -rf2eab440135dd8052881aa3e9af83ec85e9bf1bf -rfb4c4006dee5aaf815d08bc3e89312445b994307 --- src/ch/MainWnd.cpp (.../MainWnd.cpp) (revision f2eab440135dd8052881aa3e9af83ec85e9bf1bf) +++ src/ch/MainWnd.cpp (.../MainWnd.cpp) (revision fb4c4006dee5aaf815d08bc3e89312445b994307) @@ -497,8 +497,8 @@ } // load resource strings - SetTaskPropValue(tTaskDefinition.GetConfiguration(), GetResManager().LoadString(IDS_FIRSTCOPY_STRING)); - SetTaskPropValue(tTaskDefinition.GetConfiguration(), GetResManager().LoadString(IDS_NEXTCOPY_STRING)); + chcore::SetTaskPropValue(tTaskDefinition.GetConfiguration(), GetResManager().LoadString(IDS_FIRSTCOPY_STRING)); + chcore::SetTaskPropValue(tTaskDefinition.GetConfiguration(), GetResManager().LoadString(IDS_NEXTCOPY_STRING)); // create task with the above definition CTaskPtr spTask = m_tasks.CreateTask(tTaskDefinition); @@ -607,8 +607,8 @@ chcore::TTaskDefinition tTaskDefinition = dlg.m_tTaskDefinition; // load resource strings - SetTaskPropValue(tTaskDefinition.GetConfiguration(), GetResManager().LoadString(IDS_FIRSTCOPY_STRING)); - SetTaskPropValue(tTaskDefinition.GetConfiguration(), GetResManager().LoadString(IDS_NEXTCOPY_STRING)); + chcore::SetTaskPropValue(tTaskDefinition.GetConfiguration(), GetResManager().LoadString(IDS_FIRSTCOPY_STRING)); + chcore::SetTaskPropValue(tTaskDefinition.GetConfiguration(), GetResManager().LoadString(IDS_NEXTCOPY_STRING)); // new task CTaskPtr spTask = m_tasks.CreateTask(tTaskDefinition); Index: src/ch/TSubTaskBase.cpp =================================================================== diff -u -N -r2aea3ad6f3c68be709ac65c70d9646eafe3b034c -rfb4c4006dee5aaf815d08bc3e89312445b994307 --- src/ch/TSubTaskBase.cpp (.../TSubTaskBase.cpp) (revision 2aea3ad6f3c68be709ac65c70d9646eafe3b034c) +++ src/ch/TSubTaskBase.cpp (.../TSubTaskBase.cpp) (revision fb4c4006dee5aaf815d08bc3e89312445b994307) @@ -23,10 +23,10 @@ #include "stdafx.h" #include "TSubTaskBase.h" #include "../libchcore/TBasePathData.h" -#include "TLocalFilesystem.h" +#include "../libchcore/TLocalFilesystem.h" #include "TSubTaskContext.h" #include "../libchcore/TTaskDefinition.h" -#include "TTaskConfiguration.h" +#include "../libchcore/TTaskConfiguration.h" /////////////////////////////////////////////////////////////////////////// // TSubTaskBase @@ -54,7 +54,7 @@ chcore::TSmartPath pathCombined = pathDst + spFileInfo->GetFullFilePath().GetFileDir(); // force create directory - TLocalFilesystem::CreateDirectory(pathCombined, true); + chcore::TLocalFilesystem::CreateDirectory(pathCombined, true); return pathCombined + spFileInfo->GetFullFilePath().GetFileName(); } @@ -91,14 +91,14 @@ // set the dest path CString strCheckPath; - ictranslate::CFormat fmt(GetTaskPropValue(rTaskDefinition.GetConfiguration())); + ictranslate::CFormat fmt(chcore::GetTaskPropValue(rTaskDefinition.GetConfiguration())); fmt.SetParam(_t("%name"), pathFilename.ToString()); chcore::TSmartPath pathCheckPath(chcore::PathFromString((PCTSTR)fmt)); // when adding to strDstPath check if the path already exists - if so - try again int iCounter = 1; - CString strFmt = GetTaskPropValue(rTaskDefinition.GetConfiguration()); - while(TLocalFilesystem::PathExist(pathDstPath + pathCheckPath)) + CString strFmt = chcore::GetTaskPropValue(rTaskDefinition.GetConfiguration()); + while(chcore::TLocalFilesystem::PathExist(pathDstPath + pathCheckPath)) { fmt.SetFormat(strFmt); fmt.SetParam(_t("%name"), pathFilename.ToString()); Index: src/ch/TSubTaskContext.cpp =================================================================== diff -u -N -r2aea3ad6f3c68be709ac65c70d9646eafe3b034c -rfb4c4006dee5aaf815d08bc3e89312445b994307 --- src/ch/TSubTaskContext.cpp (.../TSubTaskContext.cpp) (revision 2aea3ad6f3c68be709ac65c70d9646eafe3b034c) +++ src/ch/TSubTaskContext.cpp (.../TSubTaskContext.cpp) (revision fb4c4006dee5aaf815d08bc3e89312445b994307) @@ -23,9 +23,9 @@ #include "stdafx.h" #include "TSubTaskContext.h" -TSubTaskContext::TSubTaskContext(chcore::TTaskDefinition& rTaskDefinition, chcore::TBasePathDataContainer& rBasePathDataContainer, chcore::TFileInfoArray& rFilesCache, TTaskLocalStats& rTaskLocalStats, - TTaskBasicProgressInfo& rTaskBasicProgressInfo, TTaskConfigTracker& rCfgTracker, icpf::log_file& rLog, chcore::IFeedbackHandler* piFeedbackHandler, - chcore::TWorkerThreadController& rThreadController, TLocalFilesystem& rfsLocal) : +TSubTaskContext::TSubTaskContext(chcore::TTaskDefinition& rTaskDefinition, chcore::TBasePathDataContainer& rBasePathDataContainer, chcore::TFileInfoArray& rFilesCache, chcore::TTaskLocalStats& rTaskLocalStats, + chcore::TTaskBasicProgressInfo& rTaskBasicProgressInfo, chcore::TTaskConfigTracker& rCfgTracker, icpf::log_file& rLog, chcore::IFeedbackHandler* piFeedbackHandler, + chcore::TWorkerThreadController& rThreadController, chcore::TLocalFilesystem& rfsLocal) : m_rTaskDefinition(rTaskDefinition), m_rBasePathDataContainer(rBasePathDataContainer), m_rFilesCache(rFilesCache), Index: src/ch/TSubTaskContext.h =================================================================== diff -u -N -r2aea3ad6f3c68be709ac65c70d9646eafe3b034c -rfb4c4006dee5aaf815d08bc3e89312445b994307 --- src/ch/TSubTaskContext.h (.../TSubTaskContext.h) (revision 2aea3ad6f3c68be709ac65c70d9646eafe3b034c) +++ src/ch/TSubTaskContext.h (.../TSubTaskContext.h) (revision fb4c4006dee5aaf815d08bc3e89312445b994307) @@ -31,22 +31,21 @@ class TTaskDefinition; class TWorkerThreadController; class TBasePathDataContainer; + class TTaskConfigTracker; + class TLocalFilesystem; + class TTaskLocalStats; + class TTaskBasicProgressInfo; } -class TTaskLocalStats; -class TTaskConfigTracker; -class TTaskBasicProgressInfo; -class TLocalFilesystem; - /////////////////////////////////////////////////////////////////////////// // TSubTaskContext class TSubTaskContext { public: - TSubTaskContext(chcore::TTaskDefinition& rTaskDefinition, chcore::TBasePathDataContainer& rBasePathDataContainer, chcore::TFileInfoArray& rFilesCache, TTaskLocalStats& rTaskLocalStats, - TTaskBasicProgressInfo& rTaskBasicProgressInfo, TTaskConfigTracker& rCfgTracker, icpf::log_file& rLog, - chcore::IFeedbackHandler* piFeedbackHandler, chcore::TWorkerThreadController& rThreadController, TLocalFilesystem& rfsLocal); + TSubTaskContext(chcore::TTaskDefinition& rTaskDefinition, chcore::TBasePathDataContainer& rBasePathDataContainer, chcore::TFileInfoArray& rFilesCache, chcore::TTaskLocalStats& rTaskLocalStats, + chcore::TTaskBasicProgressInfo& rTaskBasicProgressInfo, chcore::TTaskConfigTracker& rCfgTracker, icpf::log_file& rLog, + chcore::IFeedbackHandler* piFeedbackHandler, chcore::TWorkerThreadController& rThreadController, chcore::TLocalFilesystem& rfsLocal); ~TSubTaskContext(); chcore::TTaskDefinition& GetTaskDefinition() { return m_rTaskDefinition; } @@ -58,14 +57,14 @@ chcore::TFileInfoArray& GetFilesCache() { return m_rFilesCache; } const chcore::TFileInfoArray& GetFilesCache() const { return m_rFilesCache; } - TTaskLocalStats& GetTaskLocalStats() { return m_rTaskLocalStats; } - const TTaskLocalStats& GetTaskLocalStats() const { return m_rTaskLocalStats; } + chcore::TTaskLocalStats& GetTaskLocalStats() { return m_rTaskLocalStats; } + const chcore::TTaskLocalStats& GetTaskLocalStats() const { return m_rTaskLocalStats; } - TTaskBasicProgressInfo& GetTaskBasicProgressInfo() { return m_rTaskBasicProgressInfo; } - const TTaskBasicProgressInfo& GetTaskBasicProgressInfo() const { return m_rTaskBasicProgressInfo; } + chcore::TTaskBasicProgressInfo& GetTaskBasicProgressInfo() { return m_rTaskBasicProgressInfo; } + const chcore::TTaskBasicProgressInfo& GetTaskBasicProgressInfo() const { return m_rTaskBasicProgressInfo; } - TTaskConfigTracker& GetCfgTracker() { return m_rCfgTracker; } - const TTaskConfigTracker& GetCfgTracker() const { return m_rCfgTracker; } + chcore::TTaskConfigTracker& GetCfgTracker() { return m_rCfgTracker; } + const chcore::TTaskConfigTracker& GetCfgTracker() const { return m_rCfgTracker; } icpf::log_file& GetLog() { return m_rLog; } const icpf::log_file& GetLog() const { return m_rLog; } @@ -76,8 +75,8 @@ chcore::TWorkerThreadController& GetThreadController() { return m_rThreadController; } const chcore::TWorkerThreadController& GetThreadController() const { return m_rThreadController; } - TLocalFilesystem& GetLocalFilesystem() { return m_rfsLocal; } - const TLocalFilesystem& GetLocalFilesystem() const { return m_rfsLocal; } + chcore::TLocalFilesystem& GetLocalFilesystem() { return m_rfsLocal; } + const chcore::TLocalFilesystem& GetLocalFilesystem() const { return m_rfsLocal; } private: chcore::TTaskDefinition& m_rTaskDefinition; @@ -89,14 +88,14 @@ chcore::TFileInfoArray& m_rFilesCache; // local stats for task - TTaskLocalStats& m_rTaskLocalStats; - TTaskBasicProgressInfo& m_rTaskBasicProgressInfo; + chcore::TTaskLocalStats& m_rTaskLocalStats; + chcore::TTaskBasicProgressInfo& m_rTaskBasicProgressInfo; // configuration changes tracking - TTaskConfigTracker& m_rCfgTracker; + chcore::TTaskConfigTracker& m_rCfgTracker; // local filesystem access functions - TLocalFilesystem& m_rfsLocal; + chcore::TLocalFilesystem& m_rfsLocal; // additional data icpf::log_file& m_rLog; @@ -108,4 +107,4 @@ chcore::TWorkerThreadController& m_rThreadController; }; -#endif // __TSUBTASKCONTEXT_H__ \ No newline at end of file +#endif // __TSUBTASKCONTEXT_H__ Index: src/ch/TSubTaskCopyMove.cpp =================================================================== diff -u -N -r2aea3ad6f3c68be709ac65c70d9646eafe3b034c -rfb4c4006dee5aaf815d08bc3e89312445b994307 --- src/ch/TSubTaskCopyMove.cpp (.../TSubTaskCopyMove.cpp) (revision 2aea3ad6f3c68be709ac65c70d9646eafe3b034c) +++ src/ch/TSubTaskCopyMove.cpp (.../TSubTaskCopyMove.cpp) (revision fb4c4006dee5aaf815d08bc3e89312445b994307) @@ -23,10 +23,10 @@ #include "stdafx.h" #include "TSubTaskCopyMove.h" #include "TSubTaskContext.h" -#include "TTaskConfiguration.h" +#include "../libchcore/TTaskConfiguration.h" #include "../libchcore/TTaskDefinition.h" #include "task.h" -#include "TLocalFilesystem.h" +#include "../libchcore/TLocalFilesystem.h" #include "FeedbackHandler.h" // assume max sectors of 4kB (for rounding) @@ -52,11 +52,11 @@ icpf::log_file& rLog = GetContext().GetLog(); chcore::TFileInfoArray& rFilesCache = GetContext().GetFilesCache(); chcore::TTaskDefinition& rTaskDefinition = GetContext().GetTaskDefinition(); - TTaskConfigTracker& rCfgTracker = GetContext().GetCfgTracker(); - TTaskBasicProgressInfo& rBasicProgressInfo = GetContext().GetTaskBasicProgressInfo(); + chcore::TTaskConfigTracker& rCfgTracker = GetContext().GetCfgTracker(); + chcore::TTaskBasicProgressInfo& rBasicProgressInfo = GetContext().GetTaskBasicProgressInfo(); chcore::TWorkerThreadController& rThreadController = GetContext().GetThreadController(); chcore::IFeedbackHandler* piFeedbackHandler = GetContext().GetFeedbackHandler(); - TTaskLocalStats& rLocalStats = GetContext().GetTaskLocalStats(); + chcore::TTaskLocalStats& rLocalStats = GetContext().GetTaskLocalStats(); BOOST_ASSERT(piFeedbackHandler != NULL); if(piFeedbackHandler == NULL) @@ -75,24 +75,24 @@ // begin at index which wasn't processed previously size_t stSize = rFilesCache.GetSize(); - bool bIgnoreFolders = GetTaskPropValue(rTaskDefinition.GetConfiguration()); - bool bForceDirectories = GetTaskPropValue(rTaskDefinition.GetConfiguration()); + bool bIgnoreFolders = chcore::GetTaskPropValue(rTaskDefinition.GetConfiguration()); + bool bForceDirectories = chcore::GetTaskPropValue(rTaskDefinition.GetConfiguration()); // create a buffer of size m_nBufferSize CUSTOM_COPY_PARAMS ccp; ccp.bProcessed = false; - ccp.bOnlyCreate = GetTaskPropValue(rTaskDefinition.GetConfiguration()); + ccp.bOnlyCreate = chcore::GetTaskPropValue(rTaskDefinition.GetConfiguration()); // remove changes in buffer sizes to avoid re-creation later - rCfgTracker.RemoveModificationSet(TOptionsSet() % eTO_DefaultBufferSize % eTO_OneDiskBufferSize % eTO_TwoDisksBufferSize % eTO_CDBufferSize % eTO_LANBufferSize % eTO_UseOnlyDefaultBuffer); + rCfgTracker.RemoveModificationSet(chcore::TOptionsSet() % chcore::eTO_DefaultBufferSize % chcore::eTO_OneDiskBufferSize % chcore::eTO_TwoDisksBufferSize % chcore::eTO_CDBufferSize % chcore::eTO_LANBufferSize % chcore::eTO_UseOnlyDefaultBuffer); chcore::TBufferSizes bs; - bs.SetOnlyDefault(GetTaskPropValue(rTaskDefinition.GetConfiguration())); - bs.SetDefaultSize(GetTaskPropValue(rTaskDefinition.GetConfiguration())); - bs.SetOneDiskSize(GetTaskPropValue(rTaskDefinition.GetConfiguration())); - bs.SetTwoDisksSize(GetTaskPropValue(rTaskDefinition.GetConfiguration())); - bs.SetCDSize(GetTaskPropValue(rTaskDefinition.GetConfiguration())); - bs.SetLANSize(GetTaskPropValue(rTaskDefinition.GetConfiguration())); + bs.SetOnlyDefault(chcore::GetTaskPropValue(rTaskDefinition.GetConfiguration())); + bs.SetDefaultSize(chcore::GetTaskPropValue(rTaskDefinition.GetConfiguration())); + bs.SetOneDiskSize(chcore::GetTaskPropValue(rTaskDefinition.GetConfiguration())); + bs.SetTwoDisksSize(chcore::GetTaskPropValue(rTaskDefinition.GetConfiguration())); + bs.SetCDSize(chcore::GetTaskPropValue(rTaskDefinition.GetConfiguration())); + bs.SetLANSize(chcore::GetTaskPropValue(rTaskDefinition.GetConfiguration())); ccp.dbBuffer.Create(bs); @@ -140,7 +140,7 @@ if(bMove && wchDestinationDrive != L'\0' && wchDestinationDrive == pathCurrent.GetDriveLetter() && GetMove(spFileInfo)) { bool bRetry = true; - if(bRetry && !TLocalFilesystem::FastMove(pathCurrent, ccp.pathDstFile)) + if(bRetry && !chcore::TLocalFilesystem::FastMove(pathCurrent, ccp.pathDstFile)) { dwLastError=GetLastError(); //log @@ -180,7 +180,7 @@ if(spFileInfo->IsDirectory()) { bool bRetry = true; - if(bRetry && !TLocalFilesystem::CreateDirectory(ccp.pathDstFile, false) && (dwLastError=GetLastError()) != ERROR_ALREADY_EXISTS ) + if(bRetry && !chcore::TLocalFilesystem::CreateDirectory(ccp.pathDstFile, false) && (dwLastError=GetLastError()) != ERROR_ALREADY_EXISTS ) { // log fmt.SetFormat(_T("Error %errno while calling CreateDirectory %path (ProcessFiles)")); @@ -227,22 +227,22 @@ spFileInfo->SetFlags(ccp.bProcessed ? FIF_PROCESSED : 0, FIF_PROCESSED); // if moving - delete file (only if config flag is set) - if(bMove && spFileInfo->GetFlags() & FIF_PROCESSED && !GetTaskPropValue(rTaskDefinition.GetConfiguration())) + if(bMove && spFileInfo->GetFlags() & FIF_PROCESSED && !chcore::GetTaskPropValue(rTaskDefinition.GetConfiguration())) { - if(!GetTaskPropValue(rTaskDefinition.GetConfiguration())) - TLocalFilesystem::SetAttributes(spFileInfo->GetFullFilePath(), FILE_ATTRIBUTE_NORMAL); - TLocalFilesystem::DeleteFile(spFileInfo->GetFullFilePath()); // there will be another try later, so I don't check + if(!chcore::GetTaskPropValue(rTaskDefinition.GetConfiguration())) + chcore::TLocalFilesystem::SetAttributes(spFileInfo->GetFullFilePath(), FILE_ATTRIBUTE_NORMAL); + chcore::TLocalFilesystem::DeleteFile(spFileInfo->GetFullFilePath()); // there will be another try later, so I don't check // if succeeded } } // set a time - if(GetTaskPropValue(rTaskDefinition.GetConfiguration())) - TLocalFilesystem::SetFileDirectoryTime(ccp.pathDstFile, spFileInfo->GetCreationTime(), spFileInfo->GetLastAccessTime(), spFileInfo->GetLastWriteTime()); // no error checking (but most probably it should be checked) + if(chcore::GetTaskPropValue(rTaskDefinition.GetConfiguration())) + chcore::TLocalFilesystem::SetFileDirectoryTime(ccp.pathDstFile, spFileInfo->GetCreationTime(), spFileInfo->GetLastAccessTime(), spFileInfo->GetLastWriteTime()); // no error checking (but most probably it should be checked) // attributes - if(GetTaskPropValue(rTaskDefinition.GetConfiguration())) - TLocalFilesystem::SetAttributes(ccp.pathDstFile, spFileInfo->GetAttributes()); // as above + if(chcore::GetTaskPropValue(rTaskDefinition.GetConfiguration())) + chcore::TLocalFilesystem::SetAttributes(ccp.pathDstFile, spFileInfo->GetAttributes()); // as above } rBasicProgressInfo.SetCurrentIndex(stIndex + 1); @@ -284,19 +284,19 @@ chcore::TSmartPath pathSource = spFileInfo->GetFullFilePath(); chcore::TSmartPath pathDestination = GetContext().GetTaskDefinition().GetDestinationPath(); - TLocalFilesystem::EPathsRelation eRelation = GetContext().GetLocalFilesystem().GetPathsRelation(pathSource, pathDestination); + chcore::TLocalFilesystem::EPathsRelation eRelation = GetContext().GetLocalFilesystem().GetPathsRelation(pathSource, pathDestination); switch(eRelation) { - case TLocalFilesystem::eRelation_Network: + case chcore::TLocalFilesystem::eRelation_Network: return chcore::TBufferSizes::eBuffer_LAN; - case TLocalFilesystem::eRelation_CDRom: + case chcore::TLocalFilesystem::eRelation_CDRom: return chcore::TBufferSizes::eBuffer_CD; - case TLocalFilesystem::eRelation_TwoPhysicalDisks: + case chcore::TLocalFilesystem::eRelation_TwoPhysicalDisks: return chcore::TBufferSizes::eBuffer_TwoDisks; - case TLocalFilesystem::eRelation_SinglePhysicalDisk: + case chcore::TLocalFilesystem::eRelation_SinglePhysicalDisk: return chcore::TBufferSizes::eBuffer_OneDisk; //case eRelation_Other: @@ -308,14 +308,14 @@ TSubTaskBase::ESubOperationResult TSubTaskCopyMove::CustomCopyFileFB(CUSTOM_COPY_PARAMS* pData) { chcore::TTaskDefinition& rTaskDefinition = GetContext().GetTaskDefinition(); - TTaskBasicProgressInfo& rBasicProgressInfo = GetContext().GetTaskBasicProgressInfo(); + chcore::TTaskBasicProgressInfo& rBasicProgressInfo = GetContext().GetTaskBasicProgressInfo(); chcore::TWorkerThreadController& rThreadController = GetContext().GetThreadController(); - TTaskLocalStats& rLocalStats = GetContext().GetTaskLocalStats(); + chcore::TTaskLocalStats& rLocalStats = GetContext().GetTaskLocalStats(); icpf::log_file& rLog = GetContext().GetLog(); - TTaskConfigTracker& rCfgTracker = GetContext().GetCfgTracker(); + chcore::TTaskConfigTracker& rCfgTracker = GetContext().GetCfgTracker(); - TLocalFilesystemFile fileSrc = TLocalFilesystem::CreateFileObject(); - TLocalFilesystemFile fileDst = TLocalFilesystem::CreateFileObject(); + chcore::TLocalFilesystemFile fileSrc = chcore::TLocalFilesystem::CreateFileObject(); + chcore::TLocalFilesystemFile fileDst = chcore::TLocalFilesystem::CreateFileObject(); ictranslate::CFormat fmt; TSubTaskBase::ESubOperationResult eResult = TSubTaskBase::eSubResult_Continue; @@ -325,8 +325,8 @@ // NOTE: we are using here the file size read when scanning directories for files; it might be // outdated at this point, but at present we don't want to re-read file size since it // will cost additional disk access - bool bNoBuffer = (GetTaskPropValue(rTaskDefinition.GetConfiguration()) && - pData->spSrcFile->GetLength64() >= GetTaskPropValue(rTaskDefinition.GetConfiguration())); + bool bNoBuffer = (chcore::GetTaskPropValue(rTaskDefinition.GetConfiguration()) && + pData->spSrcFile->GetLength64() >= chcore::GetTaskPropValue(rTaskDefinition.GetConfiguration())); // first open the source file and handle any failures eResult = OpenSourceFileFB(fileSrc, pData->spSrcFile->GetFullFilePath(), bNoBuffer); @@ -343,7 +343,7 @@ // change attributes of a dest file // NOTE: probably should be removed from here and report problems with read-only files // directly to the user (as feedback request) - if(!GetTaskPropValue(rTaskDefinition.GetConfiguration())) + if(!chcore::GetTaskPropValue(rTaskDefinition.GetConfiguration())) SetFileAttributes(pData->pathDstFile.ToString(), FILE_ATTRIBUTE_NORMAL); // open destination file, handle the failures and possibly existence of the destination file @@ -448,15 +448,15 @@ } // recreate buffer if needed - if(rCfgTracker.IsModified() && rCfgTracker.IsModified(TOptionsSet() % eTO_DefaultBufferSize % eTO_OneDiskBufferSize % eTO_TwoDisksBufferSize % eTO_CDBufferSize % eTO_LANBufferSize % eTO_UseOnlyDefaultBuffer, true)) + if(rCfgTracker.IsModified() && rCfgTracker.IsModified(chcore::TOptionsSet() % chcore::eTO_DefaultBufferSize % chcore::eTO_OneDiskBufferSize % chcore::eTO_TwoDisksBufferSize % chcore::eTO_CDBufferSize % chcore::eTO_LANBufferSize % chcore::eTO_UseOnlyDefaultBuffer, true)) { chcore::TBufferSizes bs; - bs.SetOnlyDefault(GetTaskPropValue(rTaskDefinition.GetConfiguration())); - bs.SetDefaultSize(GetTaskPropValue(rTaskDefinition.GetConfiguration())); - bs.SetOneDiskSize(GetTaskPropValue(rTaskDefinition.GetConfiguration())); - bs.SetTwoDisksSize(GetTaskPropValue(rTaskDefinition.GetConfiguration())); - bs.SetCDSize(GetTaskPropValue(rTaskDefinition.GetConfiguration())); - bs.SetLANSize(GetTaskPropValue(rTaskDefinition.GetConfiguration())); + bs.SetOnlyDefault(chcore::GetTaskPropValue(rTaskDefinition.GetConfiguration())); + bs.SetDefaultSize(chcore::GetTaskPropValue(rTaskDefinition.GetConfiguration())); + bs.SetOneDiskSize(chcore::GetTaskPropValue(rTaskDefinition.GetConfiguration())); + bs.SetTwoDisksSize(chcore::GetTaskPropValue(rTaskDefinition.GetConfiguration())); + bs.SetCDSize(chcore::GetTaskPropValue(rTaskDefinition.GetConfiguration())); + bs.SetLANSize(chcore::GetTaskPropValue(rTaskDefinition.GetConfiguration())); // log const chcore::TBufferSizes& rbs1 = pData->dbBuffer.GetSizes(); @@ -481,7 +481,7 @@ } // establish count of data to read - if(GetTaskPropValue(rTaskDefinition.GetConfiguration())) + if(chcore::GetTaskPropValue(rTaskDefinition.GetConfiguration())) iBufferIndex = chcore::TBufferSizes::eBuffer_Default; else iBufferIndex = GetBufferIndex(pData->spSrcFile); @@ -602,7 +602,7 @@ } -TSubTaskBase::ESubOperationResult TSubTaskCopyMove::OpenSourceFileFB(TLocalFilesystemFile& fileSrc, const chcore::TSmartPath& spPathToOpen, bool bNoBuffering) +TSubTaskBase::ESubOperationResult TSubTaskCopyMove::OpenSourceFileFB(chcore::TLocalFilesystemFile& fileSrc, const chcore::TSmartPath& spPathToOpen, bool bNoBuffering) { chcore::IFeedbackHandler* piFeedbackHandler = GetContext().GetFeedbackHandler(); icpf::log_file& rLog = GetContext().GetLog(); @@ -670,7 +670,7 @@ return TSubTaskBase::eSubResult_Continue; } -TSubTaskBase::ESubOperationResult TSubTaskCopyMove::OpenDestinationFileFB(TLocalFilesystemFile& fileDst, const chcore::TSmartPath& pathDstFile, bool bNoBuffering, const chcore::TFileInfoPtr& spSrcFileInfo, unsigned long long& ullSeekTo, bool& bFreshlyCreated) +TSubTaskBase::ESubOperationResult TSubTaskCopyMove::OpenDestinationFileFB(chcore::TLocalFilesystemFile& fileDst, const chcore::TSmartPath& pathDstFile, bool bNoBuffering, const chcore::TFileInfoPtr& spSrcFileInfo, unsigned long long& ullSeekTo, bool& bFreshlyCreated) { chcore::IFeedbackHandler* piFeedbackHandler = GetContext().GetFeedbackHandler(); icpf::log_file& rLog = GetContext().GetLog(); @@ -705,7 +705,7 @@ // reading parameters using opened handle; need to be tested in the future chcore::TFileInfoPtr spDstFileInfo(boost::make_shared()); - if(!TLocalFilesystem::GetFileInfo(pathDstFile, spDstFileInfo)) + if(!chcore::TLocalFilesystem::GetFileInfo(pathDstFile, spDstFileInfo)) THROW(_T("Cannot get information about file which has already been opened!"), 0, GetLastError(), 0); // src and dst files are the same @@ -793,7 +793,7 @@ return TSubTaskBase::eSubResult_Continue; } -TSubTaskBase::ESubOperationResult TSubTaskCopyMove::OpenExistingDestinationFileFB(TLocalFilesystemFile& fileDst, const chcore::TSmartPath& pathDstFile, bool bNoBuffering) +TSubTaskBase::ESubOperationResult TSubTaskCopyMove::OpenExistingDestinationFileFB(chcore::TLocalFilesystemFile& fileDst, const chcore::TSmartPath& pathDstFile, bool bNoBuffering) { chcore::IFeedbackHandler* piFeedbackHandler = GetContext().GetFeedbackHandler(); icpf::log_file& rLog = GetContext().GetLog(); @@ -856,7 +856,7 @@ return TSubTaskBase::eSubResult_Continue; } -TSubTaskBase::ESubOperationResult TSubTaskCopyMove::SetFilePointerFB(TLocalFilesystemFile& file, long long llDistance, const chcore::TSmartPath& pathFile, bool& bSkip) +TSubTaskBase::ESubOperationResult TSubTaskCopyMove::SetFilePointerFB(chcore::TLocalFilesystemFile& file, long long llDistance, const chcore::TSmartPath& pathFile, bool& bSkip) { chcore::IFeedbackHandler* piFeedbackHandler = GetContext().GetFeedbackHandler(); icpf::log_file& rLog = GetContext().GetLog(); @@ -909,7 +909,7 @@ return TSubTaskBase::eSubResult_Continue; } -TSubTaskBase::ESubOperationResult TSubTaskCopyMove::SetEndOfFileFB(TLocalFilesystemFile& file, const chcore::TSmartPath& pathFile, bool& bSkip) +TSubTaskBase::ESubOperationResult TSubTaskCopyMove::SetEndOfFileFB(chcore::TLocalFilesystemFile& file, const chcore::TSmartPath& pathFile, bool& bSkip) { chcore::IFeedbackHandler* piFeedbackHandler = GetContext().GetFeedbackHandler(); icpf::log_file& rLog = GetContext().GetLog(); @@ -958,7 +958,7 @@ return TSubTaskBase::eSubResult_Continue; } -TSubTaskBase::ESubOperationResult TSubTaskCopyMove::ReadFileFB(TLocalFilesystemFile& file, chcore::TDataBuffer& rBuffer, DWORD dwToRead, DWORD& rdwBytesRead, const chcore::TSmartPath& pathFile, bool& bSkip) +TSubTaskBase::ESubOperationResult TSubTaskCopyMove::ReadFileFB(chcore::TLocalFilesystemFile& file, chcore::TDataBuffer& rBuffer, DWORD dwToRead, DWORD& rdwBytesRead, const chcore::TSmartPath& pathFile, bool& bSkip) { chcore::IFeedbackHandler* piFeedbackHandler = GetContext().GetFeedbackHandler(); icpf::log_file& rLog = GetContext().GetLog(); @@ -1010,7 +1010,7 @@ return TSubTaskBase::eSubResult_Continue; } -TSubTaskBase::ESubOperationResult TSubTaskCopyMove::WriteFileFB(TLocalFilesystemFile& file, chcore::TDataBuffer& rBuffer, DWORD dwToWrite, DWORD& rdwBytesWritten, const chcore::TSmartPath& pathFile, bool& bSkip) +TSubTaskBase::ESubOperationResult TSubTaskCopyMove::WriteFileFB(chcore::TLocalFilesystemFile& file, chcore::TDataBuffer& rBuffer, DWORD dwToWrite, DWORD& rdwBytesWritten, const chcore::TSmartPath& pathFile, bool& bSkip) { chcore::IFeedbackHandler* piFeedbackHandler = GetContext().GetFeedbackHandler(); icpf::log_file& rLog = GetContext().GetLog(); @@ -1068,8 +1068,8 @@ icpf::log_file& rLog = GetContext().GetLog(); chcore::TTaskDefinition& rTaskDefinition = GetContext().GetTaskDefinition(); chcore::IFeedbackHandler* piFeedbackHandler = GetContext().GetFeedbackHandler(); - TTaskLocalStats& rLocalStats = GetContext().GetTaskLocalStats(); - TLocalFilesystem& rLocalFilesystem = GetContext().GetLocalFilesystem(); + chcore::TTaskLocalStats& rLocalStats = GetContext().GetTaskLocalStats(); + chcore::TLocalFilesystem& rLocalFilesystem = GetContext().GetLocalFilesystem(); ull_t ullNeededSize = 0, ullAvailableSize = 0; bool bRetry = false; Index: src/ch/TSubTaskCopyMove.h =================================================================== diff -u -N -r2aea3ad6f3c68be709ac65c70d9646eafe3b034c -rfb4c4006dee5aaf815d08bc3e89312445b994307 --- src/ch/TSubTaskCopyMove.h (.../TSubTaskCopyMove.h) (revision 2aea3ad6f3c68be709ac65c70d9646eafe3b034c) +++ src/ch/TSubTaskCopyMove.h (.../TSubTaskCopyMove.h) (revision fb4c4006dee5aaf815d08bc3e89312445b994307) @@ -32,7 +32,10 @@ } struct CUSTOM_COPY_PARAMS; -class TLocalFilesystemFile; +namespace chcore +{ + class TLocalFilesystemFile; +} class TSubTaskCopyMove : public TSubTaskBase { @@ -47,15 +50,15 @@ ESubOperationResult CustomCopyFileFB(CUSTOM_COPY_PARAMS* pData); - ESubOperationResult OpenSourceFileFB(TLocalFilesystemFile& fileSrc, const chcore::TSmartPath& spPathToOpen, bool bNoBuffering); - ESubOperationResult OpenDestinationFileFB(TLocalFilesystemFile& fileDst, const chcore::TSmartPath& pathDstFile, bool bNoBuffering, const chcore::TFileInfoPtr& spSrcFileInfo, unsigned long long& ullSeekTo, bool& bFreshlyCreated); - ESubOperationResult OpenExistingDestinationFileFB(TLocalFilesystemFile& fileDst, const chcore::TSmartPath& pathDstFilePath, bool bNoBuffering); + ESubOperationResult OpenSourceFileFB(chcore::TLocalFilesystemFile& fileSrc, const chcore::TSmartPath& spPathToOpen, bool bNoBuffering); + ESubOperationResult OpenDestinationFileFB(chcore::TLocalFilesystemFile& fileDst, const chcore::TSmartPath& pathDstFile, bool bNoBuffering, const chcore::TFileInfoPtr& spSrcFileInfo, unsigned long long& ullSeekTo, bool& bFreshlyCreated); + ESubOperationResult OpenExistingDestinationFileFB(chcore::TLocalFilesystemFile& fileDst, const chcore::TSmartPath& pathDstFilePath, bool bNoBuffering); - ESubOperationResult SetFilePointerFB(TLocalFilesystemFile& file, long long llDistance, const chcore::TSmartPath& pathFile, bool& bSkip); - ESubOperationResult SetEndOfFileFB(TLocalFilesystemFile& file, const chcore::TSmartPath& pathFile, bool& bSkip); + ESubOperationResult SetFilePointerFB(chcore::TLocalFilesystemFile& file, long long llDistance, const chcore::TSmartPath& pathFile, bool& bSkip); + ESubOperationResult SetEndOfFileFB(chcore::TLocalFilesystemFile& file, const chcore::TSmartPath& pathFile, bool& bSkip); - ESubOperationResult ReadFileFB(TLocalFilesystemFile& file, chcore::TDataBuffer& rBuffer, DWORD dwToRead, DWORD& rdwBytesRead, const chcore::TSmartPath& pathFile, bool& bSkip); - ESubOperationResult WriteFileFB(TLocalFilesystemFile& file, chcore::TDataBuffer& rBuffer, DWORD dwToWrite, DWORD& rdwBytesWritten, const chcore::TSmartPath& pathFile, bool& bSkip); + ESubOperationResult ReadFileFB(chcore::TLocalFilesystemFile& file, chcore::TDataBuffer& rBuffer, DWORD dwToRead, DWORD& rdwBytesRead, const chcore::TSmartPath& pathFile, bool& bSkip); + ESubOperationResult WriteFileFB(chcore::TLocalFilesystemFile& file, chcore::TDataBuffer& rBuffer, DWORD dwToWrite, DWORD& rdwBytesWritten, const chcore::TSmartPath& pathFile, bool& bSkip); ESubOperationResult CreateDirectoryFB(const chcore::TSmartPath& pathDirectory); ESubOperationResult CheckForFreeSpaceFB(); Index: src/ch/TSubTaskDelete.cpp =================================================================== diff -u -N -r2aea3ad6f3c68be709ac65c70d9646eafe3b034c -rfb4c4006dee5aaf815d08bc3e89312445b994307 --- src/ch/TSubTaskDelete.cpp (.../TSubTaskDelete.cpp) (revision 2aea3ad6f3c68be709ac65c70d9646eafe3b034c) +++ src/ch/TSubTaskDelete.cpp (.../TSubTaskDelete.cpp) (revision fb4c4006dee5aaf815d08bc3e89312445b994307) @@ -23,12 +23,12 @@ #include "stdafx.h" #include "TSubTaskDelete.h" #include "TSubTaskContext.h" -#include "TBasicProgressInfo.h" +#include "../libchcore/TBasicProgressInfo.h" #include "../libchcore/TWorkerThreadController.h" -#include "TTaskConfiguration.h" +#include "../libchcore/TTaskConfiguration.h" #include "../libchcore/TTaskDefinition.h" #include "FeedbackHandler.h" -#include "TLocalFilesystem.h" +#include "../libchcore/TLocalFilesystem.h" TSubTaskDelete::TSubTaskDelete(TSubTaskContext& rContext) : TSubTaskBase(rContext) @@ -41,7 +41,7 @@ icpf::log_file& rLog = GetContext().GetLog(); chcore::TFileInfoArray& rFilesCache = GetContext().GetFilesCache(); chcore::TTaskDefinition& rTaskDefinition = GetContext().GetTaskDefinition(); - TTaskBasicProgressInfo& rBasicProgressInfo = GetContext().GetTaskBasicProgressInfo(); + chcore::TTaskBasicProgressInfo& rBasicProgressInfo = GetContext().GetTaskBasicProgressInfo(); chcore::TWorkerThreadController& rThreadController = GetContext().GetThreadController(); chcore::IFeedbackHandler* piFeedbackHandler = GetContext().GetFeedbackHandler(); @@ -79,16 +79,16 @@ // delete data if(spFileInfo->IsDirectory()) { - if(!GetTaskPropValue(rTaskDefinition.GetConfiguration())) - TLocalFilesystem::SetAttributes(spFileInfo->GetFullFilePath(), FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_DIRECTORY); - bSuccess = TLocalFilesystem::RemoveDirectory(spFileInfo->GetFullFilePath()); + if(!chcore::GetTaskPropValue(rTaskDefinition.GetConfiguration())) + chcore::TLocalFilesystem::SetAttributes(spFileInfo->GetFullFilePath(), FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_DIRECTORY); + bSuccess = chcore::TLocalFilesystem::RemoveDirectory(spFileInfo->GetFullFilePath()); } else { // set files attributes to normal - it'd slow processing a bit, but it's better. - if(!GetTaskPropValue(rTaskDefinition.GetConfiguration())) - TLocalFilesystem::SetAttributes(spFileInfo->GetFullFilePath(), FILE_ATTRIBUTE_NORMAL); - bSuccess = TLocalFilesystem::DeleteFile(spFileInfo->GetFullFilePath()); + if(!chcore::GetTaskPropValue(rTaskDefinition.GetConfiguration())) + chcore::TLocalFilesystem::SetAttributes(spFileInfo->GetFullFilePath(), FILE_ATTRIBUTE_NORMAL); + bSuccess = chcore::TLocalFilesystem::DeleteFile(spFileInfo->GetFullFilePath()); } // operation failed Index: src/ch/TSubTaskScanDirectory.cpp =================================================================== diff -u -N -r2aea3ad6f3c68be709ac65c70d9646eafe3b034c -rfb4c4006dee5aaf815d08bc3e89312445b994307 --- src/ch/TSubTaskScanDirectory.cpp (.../TSubTaskScanDirectory.cpp) (revision 2aea3ad6f3c68be709ac65c70d9646eafe3b034c) +++ src/ch/TSubTaskScanDirectory.cpp (.../TSubTaskScanDirectory.cpp) (revision fb4c4006dee5aaf815d08bc3e89312445b994307) @@ -23,14 +23,14 @@ #include "stdafx.h" #include "TSubTaskScanDirectory.h" #include "TSubTaskContext.h" -#include "TTaskConfiguration.h" +#include "../libchcore/TTaskConfiguration.h" #include "../libchcore/TTaskDefinition.h" #include "FeedbackHandler.h" -#include "TLocalFilesystem.h" +#include "../libchcore/TLocalFilesystem.h" #include "../libchcore/FeedbackHandlerBase.h" #include "../libchcore/TBasePathData.h" #include "../libchcore/TWorkerThreadController.h" -#include "TTaskLocalStats.h" +#include "../libchcore/TTaskLocalStats.h" TSubTaskScanDirectories::TSubTaskScanDirectories(TSubTaskContext& rContext) : TSubTaskBase(rContext) @@ -50,7 +50,7 @@ chcore::IFeedbackHandler* piFeedbackHandler = GetContext().GetFeedbackHandler(); const chcore::TBasePathDataContainer& rarrSourcePathsInfo = GetContext().GetBasePathDataContainer(); chcore::TWorkerThreadController& rThreadController = GetContext().GetThreadController(); - TTaskLocalStats& rTaskLocalStats = GetContext().GetTaskLocalStats(); + chcore::TTaskLocalStats& rTaskLocalStats = GetContext().GetTaskLocalStats(); rLog.logi(_T("Searching for files...")); @@ -63,13 +63,13 @@ // read filtering options chcore::TFiltersArray afFilters; - GetTaskPropValue(rTaskDefinition.GetConfiguration(), afFilters); + chcore::GetTaskPropValue(rTaskDefinition.GetConfiguration(), afFilters); // enter some data to rFilesCache wchar_t wchDestinationDriveLetter = rTaskDefinition.GetDestinationPath().GetDriveLetter(); - bool bIgnoreDirs = GetTaskPropValue(rTaskDefinition.GetConfiguration()); - bool bForceDirectories = GetTaskPropValue(rTaskDefinition.GetConfiguration()); + bool bIgnoreDirs = chcore::GetTaskPropValue(rTaskDefinition.GetConfiguration()); + bool bForceDirectories = chcore::GetTaskPropValue(rTaskDefinition.GetConfiguration()); bool bMove = rTaskDefinition.GetOperationType() == chcore::eOperation_Move; // add everything @@ -92,7 +92,7 @@ bRetry = false; // read attributes of src file/folder - bool bExists = TLocalFilesystem::GetFileInfo(rTaskDefinition.GetSourcePathAt(stIndex), spFileInfo, stIndex, &rTaskDefinition.GetSourcePaths()); + bool bExists = chcore::TLocalFilesystem::GetFileInfo(rTaskDefinition.GetSourcePathAt(stIndex), spFileInfo, stIndex, &rTaskDefinition.GetSourcePaths()); if(!bExists) { FEEDBACK_FILEERROR ferr = { rTaskDefinition.GetSourcePathAt(stIndex).ToString(), NULL, eFastMoveError, ERROR_FILE_NOT_FOUND }; @@ -164,7 +164,7 @@ // don't add folder contents when moving inside one disk boundary if(bIgnoreDirs || !bMove || wchDestinationDriveLetter == L'\0' || wchDestinationDriveLetter != wchSourceDriveLetter || - TLocalFilesystem::PathExist(CalculateDestinationPath(spFileInfo, rTaskDefinition.GetDestinationPath(), ((int)bForceDirectories) << 1)) ) + chcore::TLocalFilesystem::PathExist(CalculateDestinationPath(spFileInfo, rTaskDefinition.GetDestinationPath(), ((int)bForceDirectories) << 1)) ) { // log fmt.SetFormat(_T("Recursing folder %path")); @@ -189,7 +189,7 @@ else { if(bMove && wchDestinationDriveLetter != L'\0' && wchDestinationDriveLetter == wchSourceDriveLetter && - !TLocalFilesystem::PathExist(CalculateDestinationPath(spFileInfo, rTaskDefinition.GetDestinationPath(), ((int)bForceDirectories) << 1)) ) + !chcore::TLocalFilesystem::PathExist(CalculateDestinationPath(spFileInfo, rTaskDefinition.GetDestinationPath(), ((int)bForceDirectories) << 1)) ) { // if moving within one partition boundary set the file size to 0 so the overall size will // be ok @@ -224,7 +224,7 @@ chcore::TTaskDefinition& rTaskDefinition = GetContext().GetTaskDefinition(); chcore::TWorkerThreadController& rThreadController = GetContext().GetThreadController(); - TLocalFilesystemFind finder = TLocalFilesystem::CreateFinderObject(pathDirName, chcore::PathFromString(_T("*"))); + chcore::TLocalFilesystemFind finder = chcore::TLocalFilesystem::CreateFinderObject(pathDirName, chcore::PathFromString(_T("*"))); chcore::TFileInfoPtr spFileInfo(boost::make_shared()); while(finder.FindNext(spFileInfo)) Index: src/ch/ch.vc90.vcproj =================================================================== diff -u -N -rd12e49decb8a3df3e28f6786d38542390484ac07 -rfb4c4006dee5aaf815d08bc3e89312445b994307 --- src/ch/ch.vc90.vcproj (.../ch.vc90.vcproj) (revision d12e49decb8a3df3e28f6786d38542390484ac07) +++ src/ch/ch.vc90.vcproj (.../ch.vc90.vcproj) (revision fb4c4006dee5aaf815d08bc3e89312445b994307) @@ -435,45 +435,13 @@ > - - - - - - - - - - - - - - - - @@ -530,26 +498,6 @@ > - - - - - - - - - - (m_tTaskDefinition.GetConfiguration(), bsSizes.GetDefaultSize()); - SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), bsSizes.GetOneDiskSize()); - SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), bsSizes.GetTwoDisksSize()); - SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), bsSizes.GetCDSize()); - SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), bsSizes.GetLANSize()); - SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), bsSizes.IsOnlyDefault()); + chcore::SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), bsSizes.GetDefaultSize()); + chcore::SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), bsSizes.GetOneDiskSize()); + chcore::SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), bsSizes.GetTwoDisksSize()); + chcore::SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), bsSizes.GetCDSize()); + chcore::SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), bsSizes.GetLANSize()); + chcore::SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), bsSizes.IsOnlyDefault()); m_tTaskDefinition.GetConfiguration().ResumeNotifications(); } void CTask::GetBufferSizes(chcore::TBufferSizes& bsSizes) { - bsSizes.SetDefaultSize(GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); - bsSizes.SetOneDiskSize(GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); - bsSizes.SetTwoDisksSize(GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); - bsSizes.SetCDSize(GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); - bsSizes.SetLANSize(GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); - bsSizes.SetOnlyDefault(GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); + bsSizes.SetDefaultSize(chcore::GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); + bsSizes.SetOneDiskSize(chcore::GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); + bsSizes.SetTwoDisksSize(chcore::GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); + bsSizes.SetCDSize(chcore::GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); + bsSizes.SetLANSize(chcore::GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); + bsSizes.SetOnlyDefault(chcore::GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); } int CTask::GetCurrentBufferIndex() @@ -125,7 +125,7 @@ // thread void CTask::SetPriority(int nPriority) { - SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), nPriority); + chcore::SetTaskPropValue(m_tTaskDefinition.GetConfiguration(), nPriority); } void CTask::CalculateProcessedSize() @@ -153,7 +153,7 @@ // update members according to the task definition // make sure to resize paths info array size to match source paths count m_arrSourcePathsInfo.SetCount(m_tTaskDefinition.GetSourcePathCount()); - GetTaskPropValue(m_tTaskDefinition.GetConfiguration(), m_afFilters); + chcore::GetTaskPropValue(m_tTaskDefinition.GetConfiguration(), m_afFilters); //////////////////////////////// // now rarely changing task progress data @@ -278,7 +278,7 @@ m_bRareStateModified = true; m_bOftenStateModified = true; - m_workerThread.StartThread(DelegateThreadProc, this, GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); + m_workerThread.StartThread(DelegateThreadProc, this, chcore::GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); } void CTask::ResumeProcessing() @@ -394,7 +394,7 @@ } } - pData->m_nPriority = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); + pData->m_nPriority = chcore::GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); pData->m_pathDstPath = m_tTaskDefinition.GetDestinationPath(); pData->m_pafFilters = &m_afFilters; pData->m_eTaskState = m_eCurrentState; @@ -406,8 +406,8 @@ pData->m_eOperationType = m_tTaskDefinition.GetOperationType(); pData->m_eSubOperationType = m_tTaskDefinition.GetOperationPlan().GetSubOperationAt(m_tTaskBasicProgressInfo.GetSubOperationIndex()); - pData->m_bIgnoreDirectories = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); - pData->m_bCreateEmptyFiles = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); + pData->m_bIgnoreDirectories = chcore::GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); + pData->m_bCreateEmptyFiles = chcore::GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); if(m_files.GetSize() > 0) pData->m_iCurrentBufferIndex = m_localStats.GetCurrentBufferIndex(); @@ -417,19 +417,19 @@ switch(pData->m_iCurrentBufferIndex) { case chcore::TBufferSizes::eBuffer_Default: - pData->m_iCurrentBufferSize = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); + pData->m_iCurrentBufferSize = chcore::GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); break; case chcore::TBufferSizes::eBuffer_OneDisk: - pData->m_iCurrentBufferSize = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); + pData->m_iCurrentBufferSize = chcore::GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); break; case chcore::TBufferSizes::eBuffer_TwoDisks: - pData->m_iCurrentBufferSize = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); + pData->m_iCurrentBufferSize = chcore::GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); break; case chcore::TBufferSizes::eBuffer_CD: - pData->m_iCurrentBufferSize = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); + pData->m_iCurrentBufferSize = chcore::GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); break; case chcore::TBufferSizes::eBuffer_LAN: - pData->m_iCurrentBufferSize = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); + pData->m_iCurrentBufferSize = chcore::GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); break; default: THROW(_T("Unhandled case"), 0, 0, 0); @@ -611,15 +611,15 @@ OnBeginOperation(); // enable configuration changes tracking - m_tTaskDefinition.GetConfiguration().ConnectToNotifier(TTaskConfigTracker::NotificationProc, &m_cfgTracker); + m_tTaskDefinition.GetConfiguration().ConnectToNotifier(chcore::TTaskConfigTracker::NotificationProc, &m_cfgTracker); m_tTaskDefinition.GetConfiguration().ConnectToNotifier(CTask::OnCfgOptionChanged, this); // set thread options HANDLE hThread = GetCurrentThread(); - ::SetThreadPriorityBoost(hThread, GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); + ::SetThreadPriorityBoost(hThread, chcore::GetTaskPropValue(m_tTaskDefinition.GetConfiguration())); // determine when to scan directories - bool bReadTasksSize = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); + bool bReadTasksSize = chcore::GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); // wait for permission to really start (but only if search for files is not allowed to start regardless of the lock) size_t stSubOperationIndex = m_tTaskBasicProgressInfo.GetSubOperationIndex(); @@ -741,15 +741,15 @@ // mark this task as dead, so other can start m_localStats.MarkTaskAsNotRunning(); - m_tTaskDefinition.GetConfiguration().DisconnectFromNotifier(TTaskConfigTracker::NotificationProc); + m_tTaskDefinition.GetConfiguration().DisconnectFromNotifier(chcore::TTaskConfigTracker::NotificationProc); m_tTaskDefinition.GetConfiguration().DisconnectFromNotifier(CTask::OnCfgOptionChanged); // and the real end OnEndOperation(); } catch(...) { - m_tTaskDefinition.GetConfiguration().DisconnectFromNotifier(TTaskConfigTracker::NotificationProc); + m_tTaskDefinition.GetConfiguration().DisconnectFromNotifier(chcore::TTaskConfigTracker::NotificationProc); m_tTaskDefinition.GetConfiguration().DisconnectFromNotifier(CTask::OnCfgOptionChanged); // refresh time @@ -855,9 +855,9 @@ if(!pTask) THROW(_T("Invalid pointer"), 0, 0, 0); - if(rsetChanges.HasValue(TaskPropData::GetPropertyName())) + if(rsetChanges.HasValue(chcore::TaskPropData::GetPropertyName())) { - pTask->m_workerThread.ChangePriority(GetTaskPropValue(pTask->GetTaskDefinition().GetConfiguration())); + pTask->m_workerThread.ChangePriority(chcore::GetTaskPropValue(pTask->GetTaskDefinition().GetConfiguration())); } } Index: src/ch/task.h =================================================================== diff -u -N -r2aea3ad6f3c68be709ac65c70d9646eafe3b034c -rfb4c4006dee5aaf815d08bc3e89312445b994307 --- src/ch/task.h (.../task.h) (revision 2aea3ad6f3c68be709ac65c70d9646eafe3b034c) +++ src/ch/task.h (.../task.h) (revision fb4c4006dee5aaf815d08bc3e89312445b994307) @@ -19,20 +19,20 @@ #ifndef __TASK_H__ #define __TASK_H__ -#include "TAutoHandles.h" +#include "../libchcore/TAutoHandles.h" #include "../libchcore/TWorkerThreadController.h" #include "../libchcore/FileInfo.h" #include "../libchcore/DataBuffer.h" #include "../libchcore/FeedbackHandlerBase.h" #include "../libchcore/FileFilter.h" #include "../libchcore/TTaskDefinition.h" -#include "TTaskConfigTracker.h" +#include "../libchcore/TTaskConfigTracker.h" #include "../libchcore/TBasePathData.h" #include "TSubTaskBase.h" -#include "TTaskLocalStats.h" -#include "TTaskGlobalStats.h" -#include "TBasicProgressInfo.h" -#include "TLocalFilesystem.h" +#include "../libchcore/TTaskLocalStats.h" +#include "../libchcore/TTaskGlobalStats.h" +#include "../libchcore/TBasicProgressInfo.h" +#include "../libchcore/TLocalFilesystem.h" // enum representing current processing state of the task enum ETaskCurrentState @@ -157,7 +157,7 @@ // methods are called when task is being added or removed from the global task array /// Method is called when this task is being added to a CTaskArray object - void OnRegisterTask(TTasksGlobalStats& rtGlobalStats); + void OnRegisterTask(chcore::TTasksGlobalStats& rtGlobalStats); /// Method is called when task is being removed from the CTaskArray object void OnUnregisterTask(); @@ -208,7 +208,7 @@ // task initial information (needed to start a task); might be a bit processed. chcore::TTaskDefinition m_tTaskDefinition; - TTaskConfigTracker m_cfgTracker; + chcore::TTaskConfigTracker m_cfgTracker; chcore::TBasePathDataContainer m_arrSourcePathsInfo; @@ -219,10 +219,10 @@ // changing fast volatile ETaskCurrentState m_eCurrentState; // current state of processing this task represents - TTaskBasicProgressInfo m_tTaskBasicProgressInfo; // task progress information + chcore::TTaskBasicProgressInfo m_tTaskBasicProgressInfo; // task progress information // task control variables (per-session state) - TTaskLocalStats m_localStats; // local statistics + chcore::TTaskLocalStats m_localStats; // local statistics // task settings chcore::TFiltersArray m_afFilters; // filtering settings for files (will be filtered according to the rules inside when searching for files) @@ -242,7 +242,7 @@ icpf::log_file m_log; ///< Log file where task information will be stored // Local filesystem access - TLocalFilesystem m_fsLocal; + chcore::TLocalFilesystem m_fsLocal; /// Thread controlling object chcore::TWorkerThreadController m_workerThread; @@ -318,7 +318,7 @@ private: std::vector m_vTasks; // vector with tasks objects - TTasksGlobalStats m_globalStats; // global stats for all tasks + chcore::TTasksGlobalStats m_globalStats; // global stats for all tasks size_t m_stNextSessionUniqueID; // global counter for providing unique ids for tasks per session (launch of the program) Index: src/libchcore/ErrorCodes.h =================================================================== diff -u -N -rf46d334ffd78c7daa7626f214ae698adbac5f36d -rfb4c4006dee5aaf815d08bc3e89312445b994307 --- src/libchcore/ErrorCodes.h (.../ErrorCodes.h) (revision f46d334ffd78c7daa7626f214ae698adbac5f36d) +++ src/libchcore/ErrorCodes.h (.../ErrorCodes.h) (revision fb4c4006dee5aaf815d08bc3e89312445b994307) @@ -66,6 +66,9 @@ eErr_NodeDoesNotExist = 2504, eErr_UnsupportedMultipleSubnodesLevels = 2505, eErr_CannotWriteArchive = 2506, + + // Filesystem errors + eErr_FixedDriveWithoutDriveLetter = 3000, }; END_CHCORE_NAMESPACE Index: src/libchcore/TAutoHandles.h =================================================================== diff -u -N --- src/libchcore/TAutoHandles.h (revision 0) +++ src/libchcore/TAutoHandles.h (revision fb4c4006dee5aaf815d08bc3e89312445b994307) @@ -0,0 +1,137 @@ +// ============================================================================ +// Copyright (C) 2001-2010 by Jozef Starosczyk +// ixen@copyhandler.com +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License +// (version 2) as published by the Free Software Foundation; +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// ============================================================================ +/// @file TAutoHandles.h +/// @date 2010/09/18 +/// @brief Contains implementation of auto-close handles. +// ============================================================================ +#ifndef __TAUTOHANDLES_H__ +#define __TAUTOHANDLES_H__ + +#include "libchcore.h" + +BEGIN_CHCORE_NAMESPACE + +/// class encapsulates windows HANDLE, allowing automatic closing it in destructor. +class TAutoFileHandle +{ +public: + // ============================================================================ + /// TAutoFileHandle::TAutoFileHandle + /// @date 2010/08/26 + /// + /// @brief Constructs the TAutoFileHandle object. + // ============================================================================ + TAutoFileHandle() : + m_hHandle(INVALID_HANDLE_VALUE) + { + } + + // ============================================================================ + /// TAutoFileHandle::TAutoFileHandle + /// @date 2010/08/26 + /// + /// @brief Constructs the TAutoFileHandle object with specified handle. + /// @param[in] hHandle - System handle to be managed by this class. + // ============================================================================ + TAutoFileHandle(HANDLE hHandle) : + m_hHandle(hHandle) + { + } + + // ============================================================================ + /// TAutoFileHandle::~TAutoFileHandle + /// @date 2010/08/26 + /// + /// @brief Destructs the TAutoFileHandle object and closes handle if not closed already. + // ============================================================================ + ~TAutoFileHandle() + { + Close(); + } + + // ============================================================================ + /// TAutoFileHandle::operator= + /// @date 2010/08/26 + /// + /// @brief Assignment operator. + /// @param[in] hHandle - Handle to be assigned. + /// @return Reference to this object, + // ============================================================================ + TAutoFileHandle& operator=(HANDLE hHandle) + { + if(m_hHandle != hHandle) + { + Close(); + m_hHandle = hHandle; + } + return *this; + } + + // ============================================================================ + /// TAutoFileHandle::operator HANDLE + /// @date 2010/08/26 + /// + /// @brief Retrieves the system handle. + /// @return HANDLE value. + // ============================================================================ + operator HANDLE() + { + return m_hHandle; + } + + // ============================================================================ + /// TAutoFileHandle::Close + /// @date 2010/08/26 + /// + /// @brief Closes the internal handle if needed. + /// @return Result of the CloseHandle() function. + // ============================================================================ + BOOL Close() + { + BOOL bResult = TRUE; + if(m_hHandle != INVALID_HANDLE_VALUE) + { + bResult = CloseHandle(m_hHandle); + m_hHandle = INVALID_HANDLE_VALUE; + } + + return bResult; + } + + // ============================================================================ + /// TAutoFileHandle::Detach + /// @date 2010/09/12 + /// + /// @brief Detaches the handle, so it won't be closed in destructor. + /// @return Returns current handle. + // ============================================================================ + HANDLE Detach() + { + HANDLE hHandle = m_hHandle; + m_hHandle = INVALID_HANDLE_VALUE; + return hHandle; + } + +private: + HANDLE m_hHandle; ///< System handle +}; + +END_CHCORE_NAMESPACE + +#endif Index: src/ch/TAutoHandles.h =================================================================== diff -u -N --- src/ch/TAutoHandles.h (revision 3aed0979e4af7cf1ab8083b835216b1edf5aba59) +++ src/ch/TAutoHandles.h (revision 0) @@ -1,131 +0,0 @@ -// ============================================================================ -// Copyright (C) 2001-2010 by Jozef Starosczyk -// ixen@copyhandler.com -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU Library General Public License -// (version 2) as published by the Free Software Foundation; -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this program; if not, write to the -// Free Software Foundation, Inc., -// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// ============================================================================ -/// @file TAutoHandles.h -/// @date 2010/09/18 -/// @brief Contains implementation of auto-close handles. -// ============================================================================ -#ifndef __TAUTOHANDLES_H__ -#define __TAUTOHANDLES_H__ - -/// class encapsulates windows HANDLE, allowing automatic closing it in destructor. -class TAutoFileHandle -{ -public: - // ============================================================================ - /// TAutoFileHandle::TAutoFileHandle - /// @date 2010/08/26 - /// - /// @brief Constructs the TAutoFileHandle object. - // ============================================================================ - TAutoFileHandle() : - m_hHandle(INVALID_HANDLE_VALUE) - { - } - - // ============================================================================ - /// TAutoFileHandle::TAutoFileHandle - /// @date 2010/08/26 - /// - /// @brief Constructs the TAutoFileHandle object with specified handle. - /// @param[in] hHandle - System handle to be managed by this class. - // ============================================================================ - TAutoFileHandle(HANDLE hHandle) : - m_hHandle(hHandle) - { - } - - // ============================================================================ - /// TAutoFileHandle::~TAutoFileHandle - /// @date 2010/08/26 - /// - /// @brief Destructs the TAutoFileHandle object and closes handle if not closed already. - // ============================================================================ - ~TAutoFileHandle() - { - VERIFY(Close()); - } - - // ============================================================================ - /// TAutoFileHandle::operator= - /// @date 2010/08/26 - /// - /// @brief Assignment operator. - /// @param[in] hHandle - Handle to be assigned. - /// @return Reference to this object, - // ============================================================================ - TAutoFileHandle& operator=(HANDLE hHandle) - { - if(m_hHandle != hHandle) - { - VERIFY(Close()); - m_hHandle = hHandle; - } - return *this; - } - - // ============================================================================ - /// TAutoFileHandle::operator HANDLE - /// @date 2010/08/26 - /// - /// @brief Retrieves the system handle. - /// @return HANDLE value. - // ============================================================================ - operator HANDLE() - { - return m_hHandle; - } - - // ============================================================================ - /// TAutoFileHandle::Close - /// @date 2010/08/26 - /// - /// @brief Closes the internal handle if needed. - /// @return Result of the CloseHandle() function. - // ============================================================================ - BOOL Close() - { - BOOL bResult = TRUE; - if(m_hHandle != INVALID_HANDLE_VALUE) - { - bResult = CloseHandle(m_hHandle); - m_hHandle = INVALID_HANDLE_VALUE; - } - - return bResult; - } - - // ============================================================================ - /// TAutoFileHandle::Detach - /// @date 2010/09/12 - /// - /// @brief Detaches the handle, so it won't be closed in destructor. - /// @return Returns current handle. - // ============================================================================ - HANDLE Detach() - { - HANDLE hHandle = m_hHandle; - m_hHandle = INVALID_HANDLE_VALUE; - return hHandle; - } - -private: - HANDLE m_hHandle; ///< System handle -}; - -#endif Index: src/libchcore/TBasicProgressInfo.cpp =================================================================== diff -u -N --- src/libchcore/TBasicProgressInfo.cpp (revision 0) +++ src/libchcore/TBasicProgressInfo.cpp (revision fb4c4006dee5aaf815d08bc3e89312445b994307) @@ -0,0 +1,134 @@ +// ============================================================================ +// Copyright (C) 2001-2011 by Jozef Starosczyk +// ixen@copyhandler.com +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License +// (version 2) as published by the Free Software Foundation; +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// ============================================================================ +/// @file TBasicProgressInfo.cpp +/// @date 2011/03/28 +/// @brief Contains implementation of class recording progress info. +// ============================================================================ +#include "stdafx.h" +#include "TBasicProgressInfo.h" +#include "..\libchcore\TBinarySerializer.h" +#include "..\libchcore\SerializationHelpers.h" + +BEGIN_CHCORE_NAMESPACE + +TTaskBasicProgressInfo::TTaskBasicProgressInfo() : +m_stCurrentIndex(0), +m_ullCurrentFileProcessedSize(0), +m_stSubOperationIndex(0) +{ +} + +TTaskBasicProgressInfo::~TTaskBasicProgressInfo() +{ +} + +void TTaskBasicProgressInfo::SetCurrentIndex(size_t stIndex) +{ + boost::unique_lock lock(m_lock); + m_stCurrentIndex = stIndex; + m_ullCurrentFileProcessedSize = 0; +} + +void TTaskBasicProgressInfo::IncreaseCurrentIndex() +{ + boost::unique_lock lock(m_lock); + ++m_stCurrentIndex; + m_ullCurrentFileProcessedSize = 0; +} + +size_t TTaskBasicProgressInfo::GetCurrentIndex() const +{ + boost::shared_lock lock(m_lock); + return m_stCurrentIndex; +} + +void TTaskBasicProgressInfo::SetCurrentFileProcessedSize(unsigned long long ullSize) +{ + boost::unique_lock lock(m_lock); + m_ullCurrentFileProcessedSize = ullSize; +} + +unsigned long long TTaskBasicProgressInfo::GetCurrentFileProcessedSize() const +{ + boost::shared_lock lock(m_lock); + return m_ullCurrentFileProcessedSize; +} + +void TTaskBasicProgressInfo::IncreaseCurrentFileProcessedSize(unsigned long long ullSizeToAdd) +{ + boost::unique_lock lock(m_lock); + m_ullCurrentFileProcessedSize += ullSizeToAdd; +} + +void TTaskBasicProgressInfo::SetSubOperationIndex(size_t stSubOperationIndex) +{ + boost::unique_lock lock(m_lock); + m_stSubOperationIndex = stSubOperationIndex; +} + +size_t TTaskBasicProgressInfo::GetSubOperationIndex() const +{ + boost::shared_lock lock(m_lock); + return m_stSubOperationIndex; +} + +void TTaskBasicProgressInfo::IncreaseSubOperationIndex() +{ + boost::unique_lock lock(m_lock); + ++m_stSubOperationIndex; +} + +void TTaskBasicProgressInfo::Serialize(TReadBinarySerializer& rSerializer) +{ + using Serializers::Serialize; + + size_t stCurrentIndex = 0; + Serialize(rSerializer, stCurrentIndex); + + unsigned long long ullCurrentFileProcessedSize = 0; + Serialize(rSerializer, ullCurrentFileProcessedSize); + + size_t stSubOperationIndex = 0; + Serialize(rSerializer, stSubOperationIndex); + + boost::unique_lock lock(m_lock); + + m_stCurrentIndex = stCurrentIndex; + m_ullCurrentFileProcessedSize = ullCurrentFileProcessedSize; + m_stSubOperationIndex = stSubOperationIndex; +} + +void TTaskBasicProgressInfo::Serialize(TWriteBinarySerializer& rSerializer) const +{ + using Serializers::Serialize; + + m_lock.lock_shared(); + + size_t stCurrentIndex = m_stCurrentIndex; + unsigned long long ullCurrentFileProcessedSize = m_ullCurrentFileProcessedSize; + size_t stSubOperationIndex = m_stSubOperationIndex; + + m_lock.unlock_shared(); + + Serialize(rSerializer, stCurrentIndex); + Serialize(rSerializer, ullCurrentFileProcessedSize); + Serialize(rSerializer, stSubOperationIndex); +} + +END_CHCORE_NAMESPACE Index: src/ch/TBasicProgressInfo.cpp =================================================================== diff -u -N --- src/ch/TBasicProgressInfo.cpp (revision 5fd6beaad9f1eccb664b997d151acb59961e4827) +++ src/ch/TBasicProgressInfo.cpp (revision 0) @@ -1,131 +0,0 @@ -// ============================================================================ -// Copyright (C) 2001-2011 by Jozef Starosczyk -// ixen@copyhandler.com -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU Library General Public License -// (version 2) as published by the Free Software Foundation; -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this program; if not, write to the -// Free Software Foundation, Inc., -// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// ============================================================================ -/// @file TBasicProgressInfo.cpp -/// @date 2011/03/28 -/// @brief Contains implementation of class recording progress info. -// ============================================================================ -#include "stdafx.h" -#include "TBasicProgressInfo.h" -#include "..\libchcore\TBinarySerializer.h" -#include "..\libchcore\SerializationHelpers.h" - - -TTaskBasicProgressInfo::TTaskBasicProgressInfo() : -m_stCurrentIndex(0), -m_ullCurrentFileProcessedSize(0), -m_stSubOperationIndex(0) -{ -} - -TTaskBasicProgressInfo::~TTaskBasicProgressInfo() -{ -} - -void TTaskBasicProgressInfo::SetCurrentIndex(size_t stIndex) -{ - boost::unique_lock lock(m_lock); - m_stCurrentIndex = stIndex; - m_ullCurrentFileProcessedSize = 0; -} - -void TTaskBasicProgressInfo::IncreaseCurrentIndex() -{ - boost::unique_lock lock(m_lock); - ++m_stCurrentIndex; - m_ullCurrentFileProcessedSize = 0; -} - -size_t TTaskBasicProgressInfo::GetCurrentIndex() const -{ - boost::shared_lock lock(m_lock); - return m_stCurrentIndex; -} - -void TTaskBasicProgressInfo::SetCurrentFileProcessedSize(unsigned long long ullSize) -{ - boost::unique_lock lock(m_lock); - m_ullCurrentFileProcessedSize = ullSize; -} - -unsigned long long TTaskBasicProgressInfo::GetCurrentFileProcessedSize() const -{ - boost::shared_lock lock(m_lock); - return m_ullCurrentFileProcessedSize; -} - -void TTaskBasicProgressInfo::IncreaseCurrentFileProcessedSize(unsigned long long ullSizeToAdd) -{ - boost::unique_lock lock(m_lock); - m_ullCurrentFileProcessedSize += ullSizeToAdd; -} - -void TTaskBasicProgressInfo::SetSubOperationIndex(size_t stSubOperationIndex) -{ - boost::unique_lock lock(m_lock); - m_stSubOperationIndex = stSubOperationIndex; -} - -size_t TTaskBasicProgressInfo::GetSubOperationIndex() const -{ - boost::shared_lock lock(m_lock); - return m_stSubOperationIndex; -} - -void TTaskBasicProgressInfo::IncreaseSubOperationIndex() -{ - boost::unique_lock lock(m_lock); - ++m_stSubOperationIndex; -} - -void TTaskBasicProgressInfo::Serialize(chcore::TReadBinarySerializer& rSerializer) -{ - using chcore::Serializers::Serialize; - - size_t stCurrentIndex = 0; - Serialize(rSerializer, stCurrentIndex); - - unsigned long long ullCurrentFileProcessedSize = 0; - Serialize(rSerializer, ullCurrentFileProcessedSize); - - size_t stSubOperationIndex = 0; - Serialize(rSerializer, stSubOperationIndex); - - boost::unique_lock lock(m_lock); - - m_stCurrentIndex = stCurrentIndex; - m_ullCurrentFileProcessedSize = ullCurrentFileProcessedSize; - m_stSubOperationIndex = stSubOperationIndex; -} - -void TTaskBasicProgressInfo::Serialize(chcore::TWriteBinarySerializer& rSerializer) const -{ - using chcore::Serializers::Serialize; - - m_lock.lock_shared(); - - size_t stCurrentIndex = m_stCurrentIndex; - unsigned long long ullCurrentFileProcessedSize = m_ullCurrentFileProcessedSize; - size_t stSubOperationIndex = m_stSubOperationIndex; - - m_lock.unlock_shared(); - - Serialize(rSerializer, stCurrentIndex); - Serialize(rSerializer, ullCurrentFileProcessedSize); - Serialize(rSerializer, stSubOperationIndex); -} Index: src/libchcore/TBasicProgressInfo.h =================================================================== diff -u -N --- src/libchcore/TBasicProgressInfo.h (revision 0) +++ src/libchcore/TBasicProgressInfo.h (revision fb4c4006dee5aaf815d08bc3e89312445b994307) @@ -0,0 +1,73 @@ +// ============================================================================ +// Copyright (C) 2001-2011 by Jozef Starosczyk +// ixen@copyhandler.com +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License +// (version 2) as published by the Free Software Foundation; +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// ============================================================================ +/// @file TBasicProgressInfo.h +/// @date 2011/03/28 +/// @brief Contains class with progress tracking. +// ============================================================================ +#ifndef __TBASICPROGRESSINFO_H__ +#define __TBASICPROGRESSINFO_H__ + +#include "libchcore.h" + +BEGIN_CHCORE_NAMESPACE + +class TReadBinarySerializer; +class TWriteBinarySerializer; + +/////////////////////////////////////////////////////////////////////////// +// TTaskBasicProgressInfo + +class LIBCHCORE_API TTaskBasicProgressInfo +{ +public: + TTaskBasicProgressInfo(); + ~TTaskBasicProgressInfo(); + + void SetCurrentIndex(size_t stIndex); // might be unneeded when serialization is implemented + void IncreaseCurrentIndex(); + size_t GetCurrentIndex() const; + + void SetCurrentFileProcessedSize(unsigned long long ullSize); + unsigned long long GetCurrentFileProcessedSize() const; + void IncreaseCurrentFileProcessedSize(unsigned long long ullSizeToAdd); + + void SetSubOperationIndex(size_t stSubOperationIndex); + size_t GetSubOperationIndex() const; + void IncreaseSubOperationIndex(); + + void Serialize(TReadBinarySerializer& rSerializer); + void Serialize(TWriteBinarySerializer& rSerializer) const; + +private: + TTaskBasicProgressInfo(const TTaskBasicProgressInfo& rSrc); + +private: + volatile size_t m_stSubOperationIndex; // index of sub-operation from TOperationDescription + volatile size_t m_stCurrentIndex; // index to the m_files array stating currently processed item + volatile unsigned long long m_ullCurrentFileProcessedSize; // count of bytes processed for current file + +#pragma warning(push) +#pragma warning(disable: 4251) + mutable boost::shared_mutex m_lock; +#pragma warning(pop) +}; + +END_CHCORE_NAMESPACE + +#endif Index: src/ch/TBasicProgressInfo.h =================================================================== diff -u -N --- src/ch/TBasicProgressInfo.h (revision 5fd6beaad9f1eccb664b997d151acb59961e4827) +++ src/ch/TBasicProgressInfo.h (revision 0) @@ -1,61 +0,0 @@ -// ============================================================================ -// Copyright (C) 2001-2011 by Jozef Starosczyk -// ixen@copyhandler.com -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU Library General Public License -// (version 2) as published by the Free Software Foundation; -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this program; if not, write to the -// Free Software Foundation, Inc., -// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// ============================================================================ -/// @file TBasicProgressInfo.h -/// @date 2011/03/28 -/// @brief Contains class with progress tracking. -// ============================================================================ -#ifndef __TBASICPROGRESSINFO_H__ -#define __TBASICPROGRESSINFO_H__ - -/////////////////////////////////////////////////////////////////////////// -// TTaskBasicProgressInfo - -class TTaskBasicProgressInfo -{ -public: - TTaskBasicProgressInfo(); - ~TTaskBasicProgressInfo(); - - void SetCurrentIndex(size_t stIndex); // might be unneeded when serialization is implemented - void IncreaseCurrentIndex(); - size_t GetCurrentIndex() const; - - void SetCurrentFileProcessedSize(unsigned long long ullSize); - unsigned long long GetCurrentFileProcessedSize() const; - void IncreaseCurrentFileProcessedSize(unsigned long long ullSizeToAdd); - - void SetSubOperationIndex(size_t stSubOperationIndex); - size_t GetSubOperationIndex() const; - void IncreaseSubOperationIndex(); - - void Serialize(chcore::TReadBinarySerializer& rSerializer); - void Serialize(chcore::TWriteBinarySerializer& rSerializer) const; - -private: - TTaskBasicProgressInfo(const TTaskBasicProgressInfo& rSrc); - -private: - volatile size_t m_stSubOperationIndex; // index of sub-operation from TOperationDescription - volatile size_t m_stCurrentIndex; // index to the m_files array stating currently processed item - volatile unsigned long long m_ullCurrentFileProcessedSize; // count of bytes processed for current file - - mutable boost::shared_mutex m_lock; -}; - -#endif Index: src/libchcore/TLocalFilesystem.cpp =================================================================== diff -u -N --- src/libchcore/TLocalFilesystem.cpp (revision 0) +++ src/libchcore/TLocalFilesystem.cpp (revision fb4c4006dee5aaf815d08bc3e89312445b994307) @@ -0,0 +1,451 @@ +// ============================================================================ +// Copyright (C) 2001-2010 by Jozef Starosczyk +// ixen@copyhandler.com +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License +// (version 2) as published by the Free Software Foundation; +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// ============================================================================ +/// @file TLocalFilesystem.cpp +/// @date 2011/03/24 +/// @brief +// ============================================================================ +#include "stdafx.h" +#include "TLocalFilesystem.h" +#include +#include "TAutoHandles.h" +#include "FileInfo.h" +#include "DataBuffer.h" +#include + +BEGIN_CHCORE_NAMESPACE + +UINT TLocalFilesystem::GetDriveData(const TSmartPath& spPath) +{ + UINT uiDrvType = DRIVE_UNKNOWN; + if(!spPath.IsNetworkPath()) + { + std::wstring wstrDrive = spPath.ToWString(); + + if(!wstrDrive.empty()) + { + TSmartPath pathDrive = spPath.GetDrive(); + pathDrive.AppendSeparatorIfDoesNotExist(); + + uiDrvType = GetDriveType(pathDrive.ToString()); + if(uiDrvType == DRIVE_NO_ROOT_DIR) + uiDrvType = DRIVE_UNKNOWN; + } + } + else + uiDrvType = DRIVE_REMOTE; + + return uiDrvType; +} + +bool TLocalFilesystem::PathExist(TSmartPath pathToCheck) +{ + WIN32_FIND_DATA fd; + + // search by exact name + HANDLE hFind = FindFirstFile(PrependPathExtensionIfNeeded(pathToCheck).ToString(), &fd); + if(hFind != INVALID_HANDLE_VALUE) + { + FindClose(hFind); + return true; + } + + // another try (add '\\' if needed and '*' for marking that we look for ie. c:\* + // instead of c:\, which would never be found prev. way) + pathToCheck.AppendIfNotExists(_T("*"), false); + + hFind = FindFirstFile(PrependPathExtensionIfNeeded(pathToCheck).ToString(), &fd); + if(hFind != INVALID_HANDLE_VALUE) + { + ::FindClose(hFind); + return true; + } + else + return false; +} + +bool TLocalFilesystem::SetFileDirectoryTime(const TSmartPath& pathFileDir, const FILETIME& ftCreationTime, const FILETIME& ftLastAccessTime, const FILETIME& ftLastWriteTime) +{ + TAutoFileHandle hFile = CreateFile(PrependPathExtensionIfNeeded(pathFileDir).ToString(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS, NULL); + if(hFile == INVALID_HANDLE_VALUE) + return false; + + BOOL bResult = SetFileTime(hFile, &ftCreationTime, &ftLastAccessTime, &ftLastWriteTime); + + if(!hFile.Close()) + return false; + + return bResult != FALSE; +} + +bool TLocalFilesystem::SetAttributes(const TSmartPath& pathFileDir, DWORD dwAttributes) +{ + return ::SetFileAttributes(PrependPathExtensionIfNeeded(pathFileDir).ToString(), dwAttributes) != FALSE; +} + +bool TLocalFilesystem::CreateDirectory(const TSmartPath& pathDirectory, bool bCreateFullPath) +{ + if(!bCreateFullPath) + return ::CreateDirectory(PrependPathExtensionIfNeeded(pathDirectory).ToString(), NULL) != FALSE; + else + { + std::vector vComponents; + pathDirectory.SplitPath(vComponents); + + TSmartPath pathToTest; + BOOST_FOREACH(const TSmartPath& pathComponent, vComponents) + { + pathToTest += pathComponent; + // try to create subsequent paths + if(!pathToTest.IsDrive() && !pathToTest.IsServerName()) + { + // try to create the specified path + BOOL bRes = ::CreateDirectory(PrependPathExtensionIfNeeded(pathToTest).ToString(), NULL); + if(!bRes && GetLastError() != ERROR_ALREADY_EXISTS) + return false; + } + } + } + + return true; +} + +bool TLocalFilesystem::RemoveDirectory(const TSmartPath& pathFile) +{ + return ::RemoveDirectory(PrependPathExtensionIfNeeded(pathFile).ToString()) != FALSE; +} + +bool TLocalFilesystem::DeleteFile(const TSmartPath& pathFile) +{ + return ::DeleteFile(PrependPathExtensionIfNeeded(pathFile).ToString()) != FALSE; +} + +bool TLocalFilesystem::GetFileInfo(const TSmartPath& pathFile, TFileInfoPtr& rFileInfo, size_t stSrcIndex, const TPathContainer* pBasePaths) +{ + if(!rFileInfo) + THROW_CORE_EXCEPTION(eErr_InvalidArgument); + + WIN32_FIND_DATA wfd; + HANDLE hFind = FindFirstFile(PrependPathExtensionIfNeeded(pathFile).ToString(), &wfd); + + if(hFind != INVALID_HANDLE_VALUE) + { + FindClose(hFind); + + // new instance of path to accomodate the corrected path (i.e. input path might have lower case names, but we'd like to + // preserve the original case contained in the filesystem) + TSmartPath pathNew(pathFile); + pathNew.DeleteFileName(); + + // copy data from W32_F_D + rFileInfo->Init(pathNew + PathFromString(wfd.cFileName), stSrcIndex, pBasePaths, + wfd.dwFileAttributes, (((ULONGLONG) wfd.nFileSizeHigh) << 32) + wfd.nFileSizeLow, wfd.ftCreationTime, + wfd.ftLastAccessTime, wfd.ftLastWriteTime, 0); + + return true; + } + else + { + FILETIME fi = { 0, 0 }; + rFileInfo->Init(TSmartPath(), std::numeric_limits::max(), NULL, (DWORD)-1, 0, fi, fi, fi, 0); + return false; + } +} + +bool TLocalFilesystem::FastMove(const TSmartPath& pathSource, const TSmartPath& pathDestination) +{ + return ::MoveFile(PrependPathExtensionIfNeeded(pathSource).ToString(), PrependPathExtensionIfNeeded(pathDestination).ToString()) != FALSE; +} + +TLocalFilesystemFind TLocalFilesystem::CreateFinderObject(const TSmartPath& pathDir, const TSmartPath& pathMask) +{ + return TLocalFilesystemFind(pathDir, pathMask); +} + +TLocalFilesystemFile TLocalFilesystem::CreateFileObject() +{ + return TLocalFilesystemFile(); +} + +TSmartPath TLocalFilesystem::PrependPathExtensionIfNeeded(const TSmartPath& pathInput) +{ + if(pathInput.GetLength() >= 248) + return PathFromString(_T("\\\\?\\")) + pathInput; + else + return pathInput; +} + +TLocalFilesystem::EPathsRelation TLocalFilesystem::GetPathsRelation(const TSmartPath& pathFirst, const TSmartPath& pathSecond) +{ + if(pathFirst.IsEmpty() || pathSecond.IsEmpty()) + THROW_CORE_EXCEPTION(eErr_InvalidArgument); + + // get information about both paths + UINT uiFirstDriveType = 0; + uiFirstDriveType = GetDriveData(pathFirst); + + UINT uiSecondDriveType = 0; + uiSecondDriveType = GetDriveData(pathSecond); + + // what kind of relation... + EPathsRelation eRelation = eRelation_Other; + if(uiFirstDriveType == DRIVE_REMOTE || uiSecondDriveType == DRIVE_REMOTE) + eRelation = eRelation_Network; + else if(uiFirstDriveType == DRIVE_CDROM || uiSecondDriveType == DRIVE_CDROM) + eRelation = eRelation_CDRom; + else if(uiFirstDriveType == DRIVE_FIXED && uiSecondDriveType == DRIVE_FIXED) + { + // two hdd's - is this the same physical disk ? + wchar_t wchFirstDrive = pathFirst.GetDriveLetter(); + wchar_t wchSecondDrive = pathSecond.GetDriveLetter(); + + if(wchFirstDrive == L'\0' || wchSecondDrive == L'\0') + THROW_CORE_EXCEPTION(eErr_FixedDriveWithoutDriveLetter); + + if(wchFirstDrive == wchSecondDrive) + eRelation = eRelation_SinglePhysicalDisk; + else + { + DWORD dwFirstPhysicalDisk = GetPhysicalDiskNumber(wchFirstDrive); + DWORD dwSecondPhysicalDisk = GetPhysicalDiskNumber(wchSecondDrive); + if(dwFirstPhysicalDisk == std::numeric_limits::max() || dwSecondPhysicalDisk == std::numeric_limits::max()) + { + // NOTE: disabled throwing an exception here - when testing, it came out that some DRIVE_FIXED + // volumes might have problems handling this detection (TrueCrypt volumes for example). + // So for now we report it as two different physical disks. + //THROW(_T("Problem with physical disk detection"), 0, 0, 0); + eRelation = eRelation_TwoPhysicalDisks; + } + + if(dwFirstPhysicalDisk == dwSecondPhysicalDisk) + eRelation = eRelation_SinglePhysicalDisk; + else + eRelation = eRelation_TwoPhysicalDisks; + } + } + + return eRelation; +} + +DWORD TLocalFilesystem::GetPhysicalDiskNumber(wchar_t wchDrive) +{ + { + boost::shared_lock lock(m_lockDriveLetterToPhysicalDisk); + + std::map::iterator iterMap = m_mapDriveLetterToPhysicalDisk.find(wchDrive); + if(iterMap != m_mapDriveLetterToPhysicalDisk.end()) + return (*iterMap).second; + } + + wchar_t szDrive[] = { L'\\', L'\\', L'.', L'\\', wchDrive, L':', L'\0' }; + + HANDLE hDevice = CreateFile(szDrive, FILE_READ_ATTRIBUTES, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); + if(hDevice == INVALID_HANDLE_VALUE) + return std::numeric_limits::max(); + + // buffer for data (cannot make member nor static because this function might be called by many threads at once) + // buffer is larger than one extent to allow getting information in multi-extent volumes (raid?) + const int stSize = sizeof(VOLUME_DISK_EXTENTS) + 20 * sizeof(DISK_EXTENT); + boost::shared_array spData(new BYTE[stSize]); + + VOLUME_DISK_EXTENTS* pVolumeDiskExtents = (VOLUME_DISK_EXTENTS*)spData.get(); + DWORD dwBytesReturned = 0; + BOOL bResult = DeviceIoControl(hDevice, IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS, NULL, 0, pVolumeDiskExtents, stSize, &dwBytesReturned, NULL); + if(!bResult) + { + // NOTE: when ERROR_INVALID_FUNCTION is reported here, it probably means that underlying volume + // cannot support IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS properly (such case includes TrueCrypt volumes) + return std::numeric_limits::max(); + } + + CloseHandle(hDevice); + + if(pVolumeDiskExtents->NumberOfDiskExtents == 0) + return std::numeric_limits::max(); + + DISK_EXTENT* pDiskExtent = &pVolumeDiskExtents->Extents[0]; + + boost::unique_lock lock(m_lockDriveLetterToPhysicalDisk); + m_mapDriveLetterToPhysicalDisk.insert(std::make_pair(wchDrive, pDiskExtent->DiskNumber)); + + return pDiskExtent->DiskNumber; +} + +bool TLocalFilesystem::GetDynamicFreeSpace(const TSmartPath& path, unsigned long long& rullFree) +{ + rullFree = 0; + + ULARGE_INTEGER ui64Available, ui64Total; + if(GetDiskFreeSpaceEx(path.ToString(), &ui64Available, &ui64Total, NULL)) + { + rullFree = ui64Available.QuadPart; + return true; + } + else + return false; +} + +///////////////////////////////////////////////////////////////////////////////////// +// class TLocalFilesystemFind + +TLocalFilesystemFind::TLocalFilesystemFind(const TSmartPath& pathDir, const TSmartPath& pathMask) : + m_pathDir(pathDir), + m_pathMask(pathMask), + m_hFind(INVALID_HANDLE_VALUE) +{ +} + +TLocalFilesystemFind::~TLocalFilesystemFind() +{ + Close(); +} + +bool TLocalFilesystemFind::FindNext(TFileInfoPtr& rspFileInfo) +{ + WIN32_FIND_DATA wfd; + TSmartPath pathCurrent = m_pathDir + m_pathMask; + + // Iterate through dirs & files + bool bContinue = true; + if(m_hFind != INVALID_HANDLE_VALUE) + bContinue = (FindNextFile(m_hFind, &wfd) != FALSE); + else + { + m_hFind = FindFirstFile(TLocalFilesystem::PrependPathExtensionIfNeeded(pathCurrent).ToString(), &wfd); // in this case we always continue + bContinue = (m_hFind != INVALID_HANDLE_VALUE); + } + if(bContinue) + { + do + { + if(!(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) + { + rspFileInfo->Init(m_pathDir + PathFromString(wfd.cFileName), wfd.dwFileAttributes, (((ULONGLONG) wfd.nFileSizeHigh) << 32) + wfd.nFileSizeLow, wfd.ftCreationTime, + wfd.ftLastAccessTime, wfd.ftLastWriteTime, 0); + return true; + } + else if(wfd.cFileName[0] != _T('.') || (wfd.cFileName[1] != _T('\0') && (wfd.cFileName[1] != _T('.') || wfd.cFileName[2] != _T('\0')))) + { + // Add directory itself + rspFileInfo->Init(m_pathDir + PathFromString(wfd.cFileName), + wfd.dwFileAttributes, (((ULONGLONG) wfd.nFileSizeHigh) << 32) + wfd.nFileSizeLow, wfd.ftCreationTime, + wfd.ftLastAccessTime, wfd.ftLastWriteTime, 0); + return true; + } + } + while(m_hFind != INVALID_HANDLE_VALUE && ::FindNextFile(m_hFind, &wfd)); // checking m_hFind in case other thread changed it (it shouldn't happen though) + + Close(); + } + + return false; +} + +void TLocalFilesystemFind::Close() +{ + if(m_hFind != INVALID_HANDLE_VALUE) + FindClose(m_hFind); + m_hFind = INVALID_HANDLE_VALUE; +} + +TLocalFilesystemFile::TLocalFilesystemFile() : + m_hFile(INVALID_HANDLE_VALUE), + m_pathFile() +{ +} + +TLocalFilesystemFile::~TLocalFilesystemFile() +{ + Close(); +} + +bool TLocalFilesystemFile::OpenExistingForReading(const TSmartPath& pathFile, bool bNoBuffering) +{ + Close(); + + m_hFile = ::CreateFile(TLocalFilesystem::PrependPathExtensionIfNeeded(pathFile).ToString(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN | (bNoBuffering ? FILE_FLAG_NO_BUFFERING | FILE_FLAG_WRITE_THROUGH : 0), NULL); + if(m_hFile == INVALID_HANDLE_VALUE) + return false; + return true; +} + +bool TLocalFilesystemFile::CreateNewForWriting(const TSmartPath& pathFile, bool bNoBuffering) +{ + Close(); + + m_hFile = ::CreateFile(TLocalFilesystem::PrependPathExtensionIfNeeded(pathFile).ToString(), GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN | (bNoBuffering ? FILE_FLAG_NO_BUFFERING | FILE_FLAG_WRITE_THROUGH : 0), NULL); + if(m_hFile == INVALID_HANDLE_VALUE) + return false; + return true; +} + +bool TLocalFilesystemFile::OpenExistingForWriting(const TSmartPath& pathFile, bool bNoBuffering) +{ + Close(); + + m_hFile = CreateFile(TLocalFilesystem::PrependPathExtensionIfNeeded(pathFile).ToString(), GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN | (bNoBuffering ? FILE_FLAG_NO_BUFFERING | FILE_FLAG_WRITE_THROUGH : 0), NULL); + if(m_hFile == INVALID_HANDLE_VALUE) + return false; + return true; +} + +bool TLocalFilesystemFile::SetFilePointer(long long llNewPos, DWORD dwMoveMethod) +{ + if(!IsOpen()) + return false; + + LARGE_INTEGER li = { 0, 0 }; + LARGE_INTEGER liNew = { 0, 0 }; + + li.QuadPart = llNewPos; + + return SetFilePointerEx(m_hFile, li, &liNew, dwMoveMethod) != FALSE; +} + +bool TLocalFilesystemFile::SetEndOfFile() +{ + if(!IsOpen()) + return false; + + return ::SetEndOfFile(m_hFile) != FALSE; +} + +bool TLocalFilesystemFile::ReadFile(TDataBuffer& rBuffer, DWORD dwToRead, DWORD& rdwBytesRead) +{ + if(!IsOpen()) + return false; + + return ::ReadFile(m_hFile, rBuffer, dwToRead, &rdwBytesRead, NULL) != FALSE; +} + +bool TLocalFilesystemFile::WriteFile(TDataBuffer& rBuffer, DWORD dwToWrite, DWORD& rdwBytesWritten) +{ + if(!IsOpen()) + return false; + + return ::WriteFile(m_hFile, rBuffer, dwToWrite, &rdwBytesWritten, NULL) != NULL && dwToWrite == rdwBytesWritten; +} + +void TLocalFilesystemFile::Close() +{ + if(m_hFile != INVALID_HANDLE_VALUE) + ::CloseHandle(m_hFile); + m_hFile = INVALID_HANDLE_VALUE; +} + +END_CHCORE_NAMESPACE Index: src/ch/TLocalFilesystem.cpp =================================================================== diff -u -N --- src/ch/TLocalFilesystem.cpp (revision 2aea3ad6f3c68be709ac65c70d9646eafe3b034c) +++ src/ch/TLocalFilesystem.cpp (revision 0) @@ -1,447 +0,0 @@ -// ============================================================================ -// Copyright (C) 2001-2010 by Jozef Starosczyk -// ixen@copyhandler.com -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU Library General Public License -// (version 2) as published by the Free Software Foundation; -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this program; if not, write to the -// Free Software Foundation, Inc., -// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// ============================================================================ -/// @file TLocalFilesystem.cpp -/// @date 2011/03/24 -/// @brief -// ============================================================================ -#include "stdafx.h" -#include "TLocalFilesystem.h" -#include -#include "TAutoHandles.h" -#include "../libchcore/FileInfo.h" -#include "../libchcore/DataBuffer.h" -#include - -UINT TLocalFilesystem::GetDriveData(const chcore::TSmartPath& spPath) -{ - UINT uiDrvType = DRIVE_UNKNOWN; - if(!spPath.IsNetworkPath()) - { - std::wstring wstrDrive = spPath.ToWString(); - - if(!wstrDrive.empty()) - { - chcore::TSmartPath pathDrive = spPath.GetDrive(); - pathDrive.AppendSeparatorIfDoesNotExist(); - - uiDrvType = GetDriveType(pathDrive.ToString()); - if(uiDrvType == DRIVE_NO_ROOT_DIR) - uiDrvType = DRIVE_UNKNOWN; - } - } - else - uiDrvType = DRIVE_REMOTE; - - return uiDrvType; -} - -bool TLocalFilesystem::PathExist(chcore::TSmartPath pathToCheck) -{ - WIN32_FIND_DATA fd; - - // search by exact name - HANDLE hFind = FindFirstFile(PrependPathExtensionIfNeeded(pathToCheck).ToString(), &fd); - if(hFind != INVALID_HANDLE_VALUE) - { - FindClose(hFind); - return true; - } - - // another try (add '\\' if needed and '*' for marking that we look for ie. c:\* - // instead of c:\, which would never be found prev. way) - pathToCheck.AppendIfNotExists(_T("*"), false); - - hFind = FindFirstFile(PrependPathExtensionIfNeeded(pathToCheck).ToString(), &fd); - if(hFind != INVALID_HANDLE_VALUE) - { - ::FindClose(hFind); - return true; - } - else - return false; -} - -bool TLocalFilesystem::SetFileDirectoryTime(const chcore::TSmartPath& pathFileDir, const FILETIME& ftCreationTime, const FILETIME& ftLastAccessTime, const FILETIME& ftLastWriteTime) -{ - TAutoFileHandle hFile = CreateFile(PrependPathExtensionIfNeeded(pathFileDir).ToString(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS, NULL); - if(hFile == INVALID_HANDLE_VALUE) - return false; - - BOOL bResult = SetFileTime(hFile, &ftCreationTime, &ftLastAccessTime, &ftLastWriteTime); - - if(!hFile.Close()) - return false; - - return bResult != FALSE; -} - -bool TLocalFilesystem::SetAttributes(const chcore::TSmartPath& pathFileDir, DWORD dwAttributes) -{ - return ::SetFileAttributes(PrependPathExtensionIfNeeded(pathFileDir).ToString(), dwAttributes) != FALSE; -} - -bool TLocalFilesystem::CreateDirectory(const chcore::TSmartPath& pathDirectory, bool bCreateFullPath) -{ - if(!bCreateFullPath) - return ::CreateDirectory(PrependPathExtensionIfNeeded(pathDirectory).ToString(), NULL) != FALSE; - else - { - std::vector vComponents; - pathDirectory.SplitPath(vComponents); - - chcore::TSmartPath pathToTest; - BOOST_FOREACH(const chcore::TSmartPath& pathComponent, vComponents) - { - pathToTest += pathComponent; - // try to create subsequent paths - if(!pathToTest.IsDrive() && !pathToTest.IsServerName()) - { - // try to create the specified path - BOOL bRes = ::CreateDirectory(PrependPathExtensionIfNeeded(pathToTest).ToString(), NULL); - if(!bRes && GetLastError() != ERROR_ALREADY_EXISTS) - return false; - } - } - } - - return true; -} - -bool TLocalFilesystem::RemoveDirectory(const chcore::TSmartPath& pathFile) -{ - return ::RemoveDirectory(PrependPathExtensionIfNeeded(pathFile).ToString()) != FALSE; -} - -bool TLocalFilesystem::DeleteFile(const chcore::TSmartPath& pathFile) -{ - return ::DeleteFile(PrependPathExtensionIfNeeded(pathFile).ToString()) != FALSE; -} - -bool TLocalFilesystem::GetFileInfo(const chcore::TSmartPath& pathFile, chcore::TFileInfoPtr& rFileInfo, size_t stSrcIndex, const chcore::TPathContainer* pBasePaths) -{ - if(!rFileInfo) - THROW(_T("Invalid argument"), 0, 0, 0); - - WIN32_FIND_DATA wfd; - HANDLE hFind = FindFirstFile(PrependPathExtensionIfNeeded(pathFile).ToString(), &wfd); - - if(hFind != INVALID_HANDLE_VALUE) - { - FindClose(hFind); - - // new instance of path to accomodate the corrected path (i.e. input path might have lower case names, but we'd like to - // preserve the original case contained in the filesystem) - chcore::TSmartPath pathNew(pathFile); - pathNew.DeleteFileName(); - - // copy data from W32_F_D - rFileInfo->Init(pathNew + chcore::PathFromString(wfd.cFileName), stSrcIndex, pBasePaths, - wfd.dwFileAttributes, (((ULONGLONG) wfd.nFileSizeHigh) << 32) + wfd.nFileSizeLow, wfd.ftCreationTime, - wfd.ftLastAccessTime, wfd.ftLastWriteTime, 0); - - return true; - } - else - { - FILETIME fi = { 0, 0 }; - rFileInfo->Init(chcore::TSmartPath(), std::numeric_limits::max(), NULL, (DWORD)-1, 0, fi, fi, fi, 0); - return false; - } -} - -bool TLocalFilesystem::FastMove(const chcore::TSmartPath& pathSource, const chcore::TSmartPath& pathDestination) -{ - return ::MoveFile(PrependPathExtensionIfNeeded(pathSource).ToString(), PrependPathExtensionIfNeeded(pathDestination).ToString()) != FALSE; -} - -TLocalFilesystemFind TLocalFilesystem::CreateFinderObject(const chcore::TSmartPath& pathDir, const chcore::TSmartPath& pathMask) -{ - return TLocalFilesystemFind(pathDir, pathMask); -} - -TLocalFilesystemFile TLocalFilesystem::CreateFileObject() -{ - return TLocalFilesystemFile(); -} - -chcore::TSmartPath TLocalFilesystem::PrependPathExtensionIfNeeded(const chcore::TSmartPath& pathInput) -{ - if(pathInput.GetLength() >= 248) - return chcore::PathFromString(_T("\\\\?\\")) + pathInput; - else - return pathInput; -} - -TLocalFilesystem::EPathsRelation TLocalFilesystem::GetPathsRelation(const chcore::TSmartPath& pathFirst, const chcore::TSmartPath& pathSecond) -{ - if(pathFirst.IsEmpty() || pathSecond.IsEmpty()) - THROW(_T("Invalid pointer"), 0, 0, 0); - - // get information about both paths - UINT uiFirstDriveType = 0; - uiFirstDriveType = GetDriveData(pathFirst); - - UINT uiSecondDriveType = 0; - uiSecondDriveType = GetDriveData(pathSecond); - - // what kind of relation... - EPathsRelation eRelation = eRelation_Other; - if(uiFirstDriveType == DRIVE_REMOTE || uiSecondDriveType == DRIVE_REMOTE) - eRelation = eRelation_Network; - else if(uiFirstDriveType == DRIVE_CDROM || uiSecondDriveType == DRIVE_CDROM) - eRelation = eRelation_CDRom; - else if(uiFirstDriveType == DRIVE_FIXED && uiSecondDriveType == DRIVE_FIXED) - { - // two hdd's - is this the same physical disk ? - wchar_t wchFirstDrive = pathFirst.GetDriveLetter(); - wchar_t wchSecondDrive = pathSecond.GetDriveLetter(); - - if(wchFirstDrive == L'\0' || wchSecondDrive == L'\0') - THROW(_T("Fixed drive without drive letter"), 0, 0, 0); - - if(wchFirstDrive == wchSecondDrive) - eRelation = eRelation_SinglePhysicalDisk; - else - { - DWORD dwFirstPhysicalDisk = GetPhysicalDiskNumber(wchFirstDrive); - DWORD dwSecondPhysicalDisk = GetPhysicalDiskNumber(wchSecondDrive); - if(dwFirstPhysicalDisk == std::numeric_limits::max() || dwSecondPhysicalDisk == std::numeric_limits::max()) - { - // NOTE: disabled throwing an exception here - when testing, it came out that some DRIVE_FIXED - // volumes might have problems handling this detection (TrueCrypt volumes for example). - // So for now we report it as two different physical disks. - //THROW(_T("Problem with physical disk detection"), 0, 0, 0); - eRelation = eRelation_TwoPhysicalDisks; - } - - if(dwFirstPhysicalDisk == dwSecondPhysicalDisk) - eRelation = eRelation_SinglePhysicalDisk; - else - eRelation = eRelation_TwoPhysicalDisks; - } - } - - return eRelation; -} - -DWORD TLocalFilesystem::GetPhysicalDiskNumber(wchar_t wchDrive) -{ - { - boost::shared_lock lock(m_lockDriveLetterToPhysicalDisk); - - std::map::iterator iterMap = m_mapDriveLetterToPhysicalDisk.find(wchDrive); - if(iterMap != m_mapDriveLetterToPhysicalDisk.end()) - return (*iterMap).second; - } - - wchar_t szDrive[] = { L'\\', L'\\', L'.', L'\\', wchDrive, L':', L'\0' }; - - HANDLE hDevice = CreateFile(szDrive, FILE_READ_ATTRIBUTES, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); - if(hDevice == INVALID_HANDLE_VALUE) - return std::numeric_limits::max(); - - // buffer for data (cannot make member nor static because this function might be called by many threads at once) - // buffer is larger than one extent to allow getting information in multi-extent volumes (raid?) - const int stSize = sizeof(VOLUME_DISK_EXTENTS) + 20 * sizeof(DISK_EXTENT); - boost::shared_array spData(new BYTE[stSize]); - - VOLUME_DISK_EXTENTS* pVolumeDiskExtents = (VOLUME_DISK_EXTENTS*)spData.get(); - DWORD dwBytesReturned = 0; - BOOL bResult = DeviceIoControl(hDevice, IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS, NULL, 0, pVolumeDiskExtents, stSize, &dwBytesReturned, NULL); - if(!bResult) - { - // NOTE: when ERROR_INVALID_FUNCTION is reported here, it probably means that underlying volume - // cannot support IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS properly (such case includes TrueCrypt volumes) - return std::numeric_limits::max(); - } - - CloseHandle(hDevice); - - if(pVolumeDiskExtents->NumberOfDiskExtents == 0) - return std::numeric_limits::max(); - - DISK_EXTENT* pDiskExtent = &pVolumeDiskExtents->Extents[0]; - - boost::unique_lock lock(m_lockDriveLetterToPhysicalDisk); - m_mapDriveLetterToPhysicalDisk.insert(std::make_pair(wchDrive, pDiskExtent->DiskNumber)); - - return pDiskExtent->DiskNumber; -} - -bool TLocalFilesystem::GetDynamicFreeSpace(const chcore::TSmartPath& path, unsigned long long& rullFree) -{ - rullFree = 0; - - ULARGE_INTEGER ui64Available, ui64Total; - if(GetDiskFreeSpaceEx(path.ToString(), &ui64Available, &ui64Total, NULL)) - { - rullFree = ui64Available.QuadPart; - return true; - } - else - return false; -} - -///////////////////////////////////////////////////////////////////////////////////// -// class TLocalFilesystemFind - -TLocalFilesystemFind::TLocalFilesystemFind(const chcore::TSmartPath& pathDir, const chcore::TSmartPath& pathMask) : - m_pathDir(pathDir), - m_pathMask(pathMask), - m_hFind(INVALID_HANDLE_VALUE) -{ -} - -TLocalFilesystemFind::~TLocalFilesystemFind() -{ - Close(); -} - -bool TLocalFilesystemFind::FindNext(chcore::TFileInfoPtr& rspFileInfo) -{ - WIN32_FIND_DATA wfd; - chcore::TSmartPath pathCurrent = m_pathDir + m_pathMask; - - // Iterate through dirs & files - bool bContinue = true; - if(m_hFind != INVALID_HANDLE_VALUE) - bContinue = (FindNextFile(m_hFind, &wfd) != FALSE); - else - { - m_hFind = FindFirstFile(TLocalFilesystem::PrependPathExtensionIfNeeded(pathCurrent).ToString(), &wfd); // in this case we always continue - bContinue = (m_hFind != INVALID_HANDLE_VALUE); - } - if(bContinue) - { - do - { - if(!(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) - { - rspFileInfo->Init(m_pathDir + chcore::PathFromString(wfd.cFileName), wfd.dwFileAttributes, (((ULONGLONG) wfd.nFileSizeHigh) << 32) + wfd.nFileSizeLow, wfd.ftCreationTime, - wfd.ftLastAccessTime, wfd.ftLastWriteTime, 0); - return true; - } - else if(wfd.cFileName[0] != _T('.') || (wfd.cFileName[1] != _T('\0') && (wfd.cFileName[1] != _T('.') || wfd.cFileName[2] != _T('\0')))) - { - // Add directory itself - rspFileInfo->Init(m_pathDir + chcore::PathFromString(wfd.cFileName), - wfd.dwFileAttributes, (((ULONGLONG) wfd.nFileSizeHigh) << 32) + wfd.nFileSizeLow, wfd.ftCreationTime, - wfd.ftLastAccessTime, wfd.ftLastWriteTime, 0); - return true; - } - } - while(m_hFind != INVALID_HANDLE_VALUE && ::FindNextFile(m_hFind, &wfd)); // checking m_hFind in case other thread changed it (it shouldn't happen though) - - Close(); - } - - return false; -} - -void TLocalFilesystemFind::Close() -{ - if(m_hFind != INVALID_HANDLE_VALUE) - FindClose(m_hFind); - m_hFind = INVALID_HANDLE_VALUE; -} - -TLocalFilesystemFile::TLocalFilesystemFile() : - m_hFile(INVALID_HANDLE_VALUE), - m_pathFile() -{ -} - -TLocalFilesystemFile::~TLocalFilesystemFile() -{ - Close(); -} - -bool TLocalFilesystemFile::OpenExistingForReading(const chcore::TSmartPath& pathFile, bool bNoBuffering) -{ - Close(); - - m_hFile = ::CreateFile(TLocalFilesystem::PrependPathExtensionIfNeeded(pathFile).ToString(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN | (bNoBuffering ? FILE_FLAG_NO_BUFFERING | FILE_FLAG_WRITE_THROUGH : 0), NULL); - if(m_hFile == INVALID_HANDLE_VALUE) - return false; - return true; -} - -bool TLocalFilesystemFile::CreateNewForWriting(const chcore::TSmartPath& pathFile, bool bNoBuffering) -{ - Close(); - - m_hFile = ::CreateFile(TLocalFilesystem::PrependPathExtensionIfNeeded(pathFile).ToString(), GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN | (bNoBuffering ? FILE_FLAG_NO_BUFFERING | FILE_FLAG_WRITE_THROUGH : 0), NULL); - if(m_hFile == INVALID_HANDLE_VALUE) - return false; - return true; -} - -bool TLocalFilesystemFile::OpenExistingForWriting(const chcore::TSmartPath& pathFile, bool bNoBuffering) -{ - Close(); - - m_hFile = CreateFile(TLocalFilesystem::PrependPathExtensionIfNeeded(pathFile).ToString(), GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN | (bNoBuffering ? FILE_FLAG_NO_BUFFERING | FILE_FLAG_WRITE_THROUGH : 0), NULL); - if(m_hFile == INVALID_HANDLE_VALUE) - return false; - return true; -} - -bool TLocalFilesystemFile::SetFilePointer(long long llNewPos, DWORD dwMoveMethod) -{ - if(!IsOpen()) - return false; - - LARGE_INTEGER li = { 0, 0 }; - LARGE_INTEGER liNew = { 0, 0 }; - - li.QuadPart = llNewPos; - - return SetFilePointerEx(m_hFile, li, &liNew, dwMoveMethod) != FALSE; -} - -bool TLocalFilesystemFile::SetEndOfFile() -{ - if(!IsOpen()) - return false; - - return ::SetEndOfFile(m_hFile) != FALSE; -} - -bool TLocalFilesystemFile::ReadFile(chcore::TDataBuffer& rBuffer, DWORD dwToRead, DWORD& rdwBytesRead) -{ - if(!IsOpen()) - return false; - - return ::ReadFile(m_hFile, rBuffer, dwToRead, &rdwBytesRead, NULL) != FALSE; -} - -bool TLocalFilesystemFile::WriteFile(chcore::TDataBuffer& rBuffer, DWORD dwToWrite, DWORD& rdwBytesWritten) -{ - if(!IsOpen()) - return false; - - return ::WriteFile(m_hFile, rBuffer, dwToWrite, &rdwBytesWritten, NULL) != NULL && dwToWrite == rdwBytesWritten; -} - -void TLocalFilesystemFile::Close() -{ - if(m_hFile != INVALID_HANDLE_VALUE) - ::CloseHandle(m_hFile); - m_hFile = INVALID_HANDLE_VALUE; -} Index: src/libchcore/TLocalFilesystem.h =================================================================== diff -u -N --- src/libchcore/TLocalFilesystem.h (revision 0) +++ src/libchcore/TLocalFilesystem.h (revision fb4c4006dee5aaf815d08bc3e89312445b994307) @@ -0,0 +1,138 @@ +// ============================================================================ +// Copyright (C) 2001-2010 by Jozef Starosczyk +// ixen@copyhandler.com +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License +// (version 2) as published by the Free Software Foundation; +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// ============================================================================ +/// @file TLocalFilesystem.h +/// @date 2011/03/24 +/// @brief Contains class responsible for accessing local filesystem. +// ============================================================================ +#ifndef __TLOCALFILESYSTEM_H__ +#define __TLOCALFILESYSTEM_H__ + +#include "libchcore.h" +#include "TPath.h" +#include + +BEGIN_CHCORE_NAMESPACE + +class TFileInfo; +typedef boost::shared_ptr TFileInfoPtr; + +class TAutoFileHandle; +class TLocalFilesystemFind; +class TLocalFilesystemFile; +class TDataBuffer; + +class LIBCHCORE_API TLocalFilesystem +{ +public: + enum EPathsRelation + { + eRelation_Network, // at least one of the paths is network one + eRelation_CDRom, // at least one of the paths relates to cd/dvd drive + eRelation_TwoPhysicalDisks, // paths lies on two separate physical disks + eRelation_SinglePhysicalDisk, // paths lies on the same physical disk + eRelation_Other // other type of relation + }; + +public: + static bool PathExist(TSmartPath strPath); // check for file or folder existence + + static bool SetFileDirectoryTime(const TSmartPath& pathFileDir, const FILETIME& ftCreationTime, const FILETIME& ftLastAccessTime, const FILETIME& ftLastWriteTime); + static bool SetAttributes(const TSmartPath& pathFileDir, DWORD dwAttributes); + + static bool CreateDirectory(const TSmartPath& pathDirectory, bool bCreateFullPath); + static bool RemoveDirectory(const TSmartPath& pathFile); + static bool DeleteFile(const TSmartPath& pathFile); + + static bool GetFileInfo(const TSmartPath& pathFile, TFileInfoPtr& rFileInfo, size_t stSrcIndex = std::numeric_limits::max(), const TPathContainer* pBasePaths = NULL); + static bool FastMove(const TSmartPath& pathSource, const TSmartPath& pathDestination); + + static TLocalFilesystemFind CreateFinderObject(const TSmartPath& pathDir, const TSmartPath& pathMask); + static TLocalFilesystemFile CreateFileObject(); + + EPathsRelation GetPathsRelation(const TSmartPath& pathFirst, const TSmartPath& pathSecond); + + bool GetDynamicFreeSpace(const TSmartPath& path, unsigned long long& rullFree); + +private: + static TSmartPath PrependPathExtensionIfNeeded(const TSmartPath& pathInput); + static UINT GetDriveData(const TSmartPath& spPath); + DWORD GetPhysicalDiskNumber(wchar_t wchDrive); + +private: +#pragma warning(push) +#pragma warning(disable: 4251) + std::map m_mapDriveLetterToPhysicalDisk; // caches drive letter -> physical disk number + boost::shared_mutex m_lockDriveLetterToPhysicalDisk; +#pragma warning(pop) + + friend class TLocalFilesystemFind; + friend class TLocalFilesystemFile; +}; + +class LIBCHCORE_API TLocalFilesystemFind +{ +public: + ~TLocalFilesystemFind(); + + bool FindNext(TFileInfoPtr& rspFileInfo); + void Close(); + +private: + TLocalFilesystemFind(const TSmartPath& pathDir, const TSmartPath& pathMask); + +private: + TSmartPath m_pathDir; + TSmartPath m_pathMask; + HANDLE m_hFind; + + friend class TLocalFilesystem; +}; + +class LIBCHCORE_API TLocalFilesystemFile +{ +public: + ~TLocalFilesystemFile(); + + bool OpenExistingForReading(const TSmartPath& pathFile, bool bNoBuffering); + bool CreateNewForWriting(const TSmartPath& pathFile, bool bNoBuffering); + bool OpenExistingForWriting(const TSmartPath& pathFile, bool bNoBuffering); + + bool SetFilePointer(long long llNewPos, DWORD dwMoveMethod); + bool SetEndOfFile(); + + bool ReadFile(TDataBuffer& rBuffer, DWORD dwToRead, DWORD& rdwBytesRead); + bool WriteFile(TDataBuffer& rBuffer, DWORD dwToWrite, DWORD& rdwBytesWritten); + + bool IsOpen() const { return m_hFile != INVALID_HANDLE_VALUE; } + + void Close(); + +private: + TLocalFilesystemFile(); + +private: + TSmartPath m_pathFile; + HANDLE m_hFile; + + friend class TLocalFilesystem; +}; + +END_CHCORE_NAMESPACE + +#endif Index: src/libchcore/TTaskConfigTracker.cpp =================================================================== diff -u -N --- src/libchcore/TTaskConfigTracker.cpp (revision 0) +++ src/libchcore/TTaskConfigTracker.cpp (revision fb4c4006dee5aaf815d08bc3e89312445b994307) @@ -0,0 +1,251 @@ +// ============================================================================ +// Copyright (C) 2001-2010 by Jozef Starosczyk +// ixen@copyhandler.com +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License +// (version 2) as published by the Free Software Foundation; +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// ============================================================================ +/// @file TTaskConfigTracker.cpp +/// @date 2010/10/04 +/// @brief Contains implementation of TTaskConfigTracker class. +// ============================================================================ +#include "stdafx.h" +#include "TTaskConfigTracker.h" + +BEGIN_CHCORE_NAMESPACE + +TOptionsSet& TOptionsSet::operator%(ETaskOptions eOption) +{ + m_setOptions.insert(eOption); + + return *this; +} + +std::set& TOptionsSet::Get() +{ + return m_setOptions; +} + +TTaskConfigTracker::TTaskConfigTracker() +{ +} + +TTaskConfigTracker::~TTaskConfigTracker() +{ +} + +bool TTaskConfigTracker::IsModified() const +{ + boost::shared_lock lock(m_lock); + return !m_setModified.empty(); +} + +bool TTaskConfigTracker::IsModified(ETaskOptions eOption) const +{ + boost::shared_lock lock(m_lock); + return m_setModified.find(eOption) != m_setModified.end(); +} + +bool TTaskConfigTracker::IsModified(TOptionsSet setOptions) const +{ + boost::shared_lock lock(m_lock); + + std::set setCommon; + std::set_intersection(setOptions.Get().begin(), setOptions.Get().end(), m_setModified.begin(), m_setModified.end(), std::inserter(setCommon, setCommon.begin())); + + return !setCommon.empty(); +} + +bool TTaskConfigTracker::IsModified(ETaskOptions eOption, bool bResetModificationState) +{ + boost::upgrade_lock lock(m_lock); + + std::set::iterator iterOption = m_setModified.find(eOption); + bool bModified = (iterOption != m_setModified.end()); + if(bModified && bResetModificationState) + { + boost::upgrade_to_unique_lock upgraded_lock(lock); + m_setModified.erase(iterOption); + } + + return bModified; +} + +bool TTaskConfigTracker::IsModified(TOptionsSet setOptions, bool bResetModificationState) +{ + boost::upgrade_lock lock(m_lock); + + std::set setCommon; + std::set_intersection(setOptions.Get().begin(), setOptions.Get().end(), m_setModified.begin(), m_setModified.end(), std::inserter(setCommon, setCommon.begin())); + + bool bModified = !setCommon.empty(); + if(bModified && bResetModificationState) + { + boost::upgrade_to_unique_lock upgraded_lock(lock); + std::set::iterator iterOption; + BOOST_FOREACH(ETaskOptions eOption, setCommon) + { + iterOption = m_setModified.find(eOption); + if(iterOption != m_setModified.end()) + m_setModified.erase(iterOption); + } + } + + return bModified; +} + +void TTaskConfigTracker::AddModified(const TString& strModified) +{ + ETaskOptions eOption = TTaskConfigTracker::GetOptionFromString(strModified); + + boost::unique_lock lock(m_lock); + + m_setModified.insert(eOption); +} + +void TTaskConfigTracker::AddModified(ETaskOptions eModified) +{ + boost::unique_lock lock(m_lock); + m_setModified.insert(eModified); +} + +void TTaskConfigTracker::AddModified(TOptionsSet setOptions) +{ + boost::unique_lock lock(m_lock); + m_setModified.insert(setOptions.Get().begin(), setOptions.Get().end()); +} + +void TTaskConfigTracker::AddModified(const TStringSet& setModified) +{ + TStringSet::const_iterator iterBegin = setModified.Begin(); + TStringSet::const_iterator iterEnd = setModified.End(); + + for(; iterBegin != iterEnd; ++iterBegin) + { + AddModified(*iterBegin); + } +} + +void TTaskConfigTracker::AddModified(const std::set& setModified) +{ + boost::unique_lock lock(m_lock); + + m_setModified.insert(setModified.begin(), setModified.end()); +} + +void TTaskConfigTracker::RemoveModification(ETaskOptions eModified) +{ + boost::upgrade_lock lock(m_lock); + std::set::iterator iterOption = m_setModified.find(eModified); + if(iterOption != m_setModified.end()) + { + boost::upgrade_to_unique_lock upgraded_lock(lock); + m_setModified.erase(iterOption); + } +} + +void TTaskConfigTracker::RemoveModificationSet(TOptionsSet setOptions) +{ + boost::unique_lock lock(m_lock); + + std::set setCommon; + std::set_intersection(setOptions.Get().begin(), setOptions.Get().end(), m_setModified.begin(), m_setModified.end(), std::inserter(setCommon, setCommon.begin())); + + std::set::iterator iterOption; + BOOST_FOREACH(ETaskOptions eOption, setCommon) + { + iterOption = m_setModified.find(eOption); + if(iterOption != m_setModified.end()) + m_setModified.erase(iterOption); + } +} + +void TTaskConfigTracker::RemoveModification(const TString& strModified) +{ + ETaskOptions eOption = TTaskConfigTracker::GetOptionFromString(strModified); + RemoveModification(eOption); +} + +void TTaskConfigTracker::Clear() +{ + boost::unique_lock lock(m_lock); + m_setModified.clear(); +} + +void TTaskConfigTracker::NotificationProc(const TStringSet& setModifications, void* pParam) +{ + if(!pParam) + THROW_CORE_EXCEPTION(eErr_InvalidArgument); + + TTaskConfigTracker* pTracker = (TTaskConfigTracker*)pParam; + pTracker->AddModified(setModifications); +} + +ETaskOptions TTaskConfigTracker::GetOptionFromString(const TString& strOption) +{ + if(strOption == TaskPropData::GetPropertyName()) + return eTO_UseOnlyDefaultBuffer; + else if(strOption == TaskPropData::GetPropertyName()) + return eTO_DefaultBufferSize; + else if(strOption == TaskPropData::GetPropertyName()) + return eTO_OneDiskBufferSize; + else if(strOption == TaskPropData::GetPropertyName()) + return eTO_TwoDisksBufferSize; + else if(strOption == TaskPropData::GetPropertyName()) + return eTO_CDBufferSize; + else if(strOption == TaskPropData::GetPropertyName()) + return eTO_LANBufferSize; + else if(strOption == TaskPropData::GetPropertyName()) + return eTO_DisableBuffering; + else if(strOption == TaskPropData::GetPropertyName()) + return eTO_DisableBufferingMinSize; + + else if(strOption == TaskPropData::GetPropertyName()) + return eTO_SetDestinationAttributes; + else if(strOption == TaskPropData::GetPropertyName()) + return eTO_SetDestinationDateTime; + else if(strOption == TaskPropData::GetPropertyName()) + return eTO_ProtectReadOnlyFiles; + else if(strOption == TaskPropData::GetPropertyName()) + return eTO_ScanDirectoriesBeforeBlocking; + else if(strOption == TaskPropData::GetPropertyName()) + return eTO_ThreadPriority; + else if(strOption == TaskPropData::GetPropertyName()) + return eTO_DisablePriorityBoost; + else if(strOption == TaskPropData::GetPropertyName()) + return eTO_DeleteInSeparateSubTask; + + else if(strOption == TaskPropData::GetPropertyName()) + return eTO_CreateEmptyFiles; + else if(strOption == TaskPropData::GetPropertyName()) + return eTO_CreateDirectoriesRelativeToRoot; + else if(strOption == TaskPropData::GetPropertyName()) + return eTO_IgnoreDirectories; + else if(strOption == TaskPropData::GetPropertyName()) + return eTO_AlternateFilenameFormatString_AfterFirst; + else if(strOption == TaskPropData::GetPropertyName()) + return eTO_AlternateFilenameFormatString_First; + else if(strOption == TaskPropData::GetPropertyName()) + return eTO_Filters; + else + { + BOOST_ASSERT(false); // unhandled case + THROW_CORE_EXCEPTION(eErr_UnhandledCase); + } + + // add new elements before this one + BOOST_STATIC_ASSERT(eTO_Last == eTO_Filters + 1); +} + +END_CHCORE_NAMESPACE Index: src/ch/TTaskConfigTracker.cpp =================================================================== diff -u -N --- src/ch/TTaskConfigTracker.cpp (revision 633a533cb6e741d44fe28aa56339e1d2709b1b27) +++ src/ch/TTaskConfigTracker.cpp (revision 0) @@ -1,248 +0,0 @@ -// ============================================================================ -// Copyright (C) 2001-2010 by Jozef Starosczyk -// ixen@copyhandler.com -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU Library General Public License -// (version 2) as published by the Free Software Foundation; -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this program; if not, write to the -// Free Software Foundation, Inc., -// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// ============================================================================ -/// @file TTaskConfigTracker.cpp -/// @date 2010/10/04 -/// @brief Contains implementation of TTaskConfigTracker class. -// ============================================================================ -#include "stdafx.h" -#include "TTaskConfigTracker.h" -#include "CfgProperties.h" - -TOptionsSet& TOptionsSet::operator%(ETaskOptions eOption) -{ - m_setOptions.insert(eOption); - - return *this; -} - -std::set& TOptionsSet::Get() -{ - return m_setOptions; -} - -TTaskConfigTracker::TTaskConfigTracker() -{ -} - -TTaskConfigTracker::~TTaskConfigTracker() -{ -} - -bool TTaskConfigTracker::IsModified() const -{ - boost::shared_lock lock(m_lock); - return !m_setModified.empty(); -} - -bool TTaskConfigTracker::IsModified(ETaskOptions eOption) const -{ - boost::shared_lock lock(m_lock); - return m_setModified.find(eOption) != m_setModified.end(); -} - -bool TTaskConfigTracker::IsModified(TOptionsSet setOptions) const -{ - boost::shared_lock lock(m_lock); - - std::set setCommon; - std::set_intersection(setOptions.Get().begin(), setOptions.Get().end(), m_setModified.begin(), m_setModified.end(), std::inserter(setCommon, setCommon.begin())); - - return !setCommon.empty(); -} - -bool TTaskConfigTracker::IsModified(ETaskOptions eOption, bool bResetModificationState) -{ - boost::upgrade_lock lock(m_lock); - - std::set::iterator iterOption = m_setModified.find(eOption); - bool bModified = (iterOption != m_setModified.end()); - if(bModified && bResetModificationState) - { - boost::upgrade_to_unique_lock upgraded_lock(lock); - m_setModified.erase(iterOption); - } - - return bModified; -} - -bool TTaskConfigTracker::IsModified(TOptionsSet setOptions, bool bResetModificationState) -{ - boost::upgrade_lock lock(m_lock); - - std::set setCommon; - std::set_intersection(setOptions.Get().begin(), setOptions.Get().end(), m_setModified.begin(), m_setModified.end(), std::inserter(setCommon, setCommon.begin())); - - bool bModified = !setCommon.empty(); - if(bModified && bResetModificationState) - { - boost::upgrade_to_unique_lock upgraded_lock(lock); - std::set::iterator iterOption; - BOOST_FOREACH(ETaskOptions eOption, setCommon) - { - iterOption = m_setModified.find(eOption); - if(iterOption != m_setModified.end()) - m_setModified.erase(iterOption); - } - } - - return bModified; -} - -void TTaskConfigTracker::AddModified(const chcore::TString& strModified) -{ - ETaskOptions eOption = TTaskConfigTracker::GetOptionFromString(strModified); - - boost::unique_lock lock(m_lock); - - m_setModified.insert(eOption); -} - -void TTaskConfigTracker::AddModified(ETaskOptions eModified) -{ - boost::unique_lock lock(m_lock); - m_setModified.insert(eModified); -} - -void TTaskConfigTracker::AddModified(TOptionsSet setOptions) -{ - boost::unique_lock lock(m_lock); - m_setModified.insert(setOptions.Get().begin(), setOptions.Get().end()); -} - -void TTaskConfigTracker::AddModified(const chcore::TStringSet& setModified) -{ - chcore::TStringSet::const_iterator iterBegin = setModified.Begin(); - chcore::TStringSet::const_iterator iterEnd = setModified.End(); - - for(; iterBegin != iterEnd; ++iterBegin) - { - AddModified(*iterBegin); - } -} - -void TTaskConfigTracker::AddModified(const std::set& setModified) -{ - boost::unique_lock lock(m_lock); - - m_setModified.insert(setModified.begin(), setModified.end()); -} - -void TTaskConfigTracker::RemoveModification(ETaskOptions eModified) -{ - boost::upgrade_lock lock(m_lock); - std::set::iterator iterOption = m_setModified.find(eModified); - if(iterOption != m_setModified.end()) - { - boost::upgrade_to_unique_lock upgraded_lock(lock); - m_setModified.erase(iterOption); - } -} - -void TTaskConfigTracker::RemoveModificationSet(TOptionsSet setOptions) -{ - boost::unique_lock lock(m_lock); - - std::set setCommon; - std::set_intersection(setOptions.Get().begin(), setOptions.Get().end(), m_setModified.begin(), m_setModified.end(), std::inserter(setCommon, setCommon.begin())); - - std::set::iterator iterOption; - BOOST_FOREACH(ETaskOptions eOption, setCommon) - { - iterOption = m_setModified.find(eOption); - if(iterOption != m_setModified.end()) - m_setModified.erase(iterOption); - } -} - -void TTaskConfigTracker::RemoveModification(const chcore::TString& strModified) -{ - ETaskOptions eOption = TTaskConfigTracker::GetOptionFromString(strModified); - RemoveModification(eOption); -} - -void TTaskConfigTracker::Clear() -{ - boost::unique_lock lock(m_lock); - m_setModified.clear(); -} - -void TTaskConfigTracker::NotificationProc(const chcore::TStringSet& setModifications, void* pParam) -{ - if(!pParam) - THROW(_T("Invalid pointer"), 0, 0, 0); - - TTaskConfigTracker* pTracker = (TTaskConfigTracker*)pParam; - pTracker->AddModified(setModifications); -} - -ETaskOptions TTaskConfigTracker::GetOptionFromString(const chcore::TString& strOption) -{ - if(strOption == TaskPropData::GetPropertyName()) - return eTO_UseOnlyDefaultBuffer; - else if(strOption == TaskPropData::GetPropertyName()) - return eTO_DefaultBufferSize; - else if(strOption == TaskPropData::GetPropertyName()) - return eTO_OneDiskBufferSize; - else if(strOption == TaskPropData::GetPropertyName()) - return eTO_TwoDisksBufferSize; - else if(strOption == TaskPropData::GetPropertyName()) - return eTO_CDBufferSize; - else if(strOption == TaskPropData::GetPropertyName()) - return eTO_LANBufferSize; - else if(strOption == TaskPropData::GetPropertyName()) - return eTO_DisableBuffering; - else if(strOption == TaskPropData::GetPropertyName()) - return eTO_DisableBufferingMinSize; - - else if(strOption == TaskPropData::GetPropertyName()) - return eTO_SetDestinationAttributes; - else if(strOption == TaskPropData::GetPropertyName()) - return eTO_SetDestinationDateTime; - else if(strOption == TaskPropData::GetPropertyName()) - return eTO_ProtectReadOnlyFiles; - else if(strOption == TaskPropData::GetPropertyName()) - return eTO_ScanDirectoriesBeforeBlocking; - else if(strOption == TaskPropData::GetPropertyName()) - return eTO_ThreadPriority; - else if(strOption == TaskPropData::GetPropertyName()) - return eTO_DisablePriorityBoost; - else if(strOption == TaskPropData::GetPropertyName()) - return eTO_DeleteInSeparateSubTask; - - else if(strOption == TaskPropData::GetPropertyName()) - return eTO_CreateEmptyFiles; - else if(strOption == TaskPropData::GetPropertyName()) - return eTO_CreateDirectoriesRelativeToRoot; - else if(strOption == TaskPropData::GetPropertyName()) - return eTO_IgnoreDirectories; - else if(strOption == TaskPropData::GetPropertyName()) - return eTO_AlternateFilenameFormatString_AfterFirst; - else if(strOption == TaskPropData::GetPropertyName()) - return eTO_AlternateFilenameFormatString_First; - else if(strOption == TaskPropData::GetPropertyName()) - return eTO_Filters; - else - { - BOOST_ASSERT(false); // unhandled case - THROW(_T("Unhandled case"), 0, 0, 0); - } - - // add new elements before this one - BOOST_STATIC_ASSERT(eTO_Last == eTO_Filters + 1); -} Index: src/libchcore/TTaskConfigTracker.h =================================================================== diff -u -N --- src/libchcore/TTaskConfigTracker.h (revision 0) +++ src/libchcore/TTaskConfigTracker.h (revision fb4c4006dee5aaf815d08bc3e89312445b994307) @@ -0,0 +1,83 @@ +// ============================================================================ +// Copyright (C) 2001-2010 by Jozef Starosczyk +// ixen@copyhandler.com +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License +// (version 2) as published by the Free Software Foundation; +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// ============================================================================ +/// @file TConfigTracker.h +/// @date 2010/10/04 +/// @brief Contains declaration of the TTaskConfigTracker class. +// ============================================================================ +#ifndef __TCONFIGTRACKER_H__ +#define __TCONFIGTRACKER_H__ + +#include "libchcore.h" +#include "TTaskConfiguration.h" + +BEGIN_CHCORE_NAMESPACE + +class LIBCHCORE_API TOptionsSet +{ +public: + TOptionsSet& operator%(ETaskOptions eOption); + + std::set& Get(); + +private: +#pragma warning(push) +#pragma warning(disable: 4251) + std::set m_setOptions; +#pragma warning(pop) +}; + +class LIBCHCORE_API TTaskConfigTracker +{ +public: + TTaskConfigTracker(); + ~TTaskConfigTracker(); + + bool IsModified() const; + bool IsModified(ETaskOptions eOption) const; + bool IsModified(TOptionsSet setOptions) const; + bool IsModified(ETaskOptions eOption, bool bResetModificationState); + bool IsModified(TOptionsSet setOptions, bool bResetModificationState); + + void AddModified(const TString& strModified); + void AddModified(ETaskOptions eModified); + void AddModified(TOptionsSet setOptions); + void AddModified(const TStringSet& setModified); + void AddModified(const std::set& setModified); + + void RemoveModification(ETaskOptions eModified); + void RemoveModificationSet(TOptionsSet setOptions); + void RemoveModification(const TString& strModified); + void Clear(); + + static void NotificationProc(const TStringSet& setModifications, void* pParam); + +protected: + static ETaskOptions GetOptionFromString(const TString& strOption); + +protected: +#pragma warning(push) +#pragma warning(disable: 4251) + std::set m_setModified; + mutable boost::shared_mutex m_lock; +#pragma warning(pop) +}; + +END_CHCORE_NAMESPACE + +#endif // __TCONFIGTRACKER_H__ Index: src/ch/TTaskConfigTracker.h =================================================================== diff -u -N --- src/ch/TTaskConfigTracker.h (revision 633a533cb6e741d44fe28aa56339e1d2709b1b27) +++ src/ch/TTaskConfigTracker.h (revision 0) @@ -1,72 +0,0 @@ -// ============================================================================ -// Copyright (C) 2001-2010 by Jozef Starosczyk -// ixen@copyhandler.com -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU Library General Public License -// (version 2) as published by the Free Software Foundation; -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this program; if not, write to the -// Free Software Foundation, Inc., -// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// ============================================================================ -/// @file TConfigTracker.h -/// @date 2010/10/04 -/// @brief Contains declaration of the TTaskConfigTracker class. -// ============================================================================ -#ifndef __TCONFIGTRACKER_H__ -#define __TCONFIGTRACKER_H__ - -#include "CfgProperties.h" - -class TOptionsSet -{ -public: - TOptionsSet& operator%(ETaskOptions eOption); - - std::set& Get(); - -private: - std::set m_setOptions; -}; - -class TTaskConfigTracker -{ -public: - TTaskConfigTracker(); - ~TTaskConfigTracker(); - - bool IsModified() const; - bool IsModified(ETaskOptions eOption) const; - bool IsModified(TOptionsSet setOptions) const; - bool IsModified(ETaskOptions eOption, bool bResetModificationState); - bool IsModified(TOptionsSet setOptions, bool bResetModificationState); - - void AddModified(const chcore::TString& strModified); - void AddModified(ETaskOptions eModified); - void AddModified(TOptionsSet setOptions); - void AddModified(const chcore::TStringSet& setModified); - void AddModified(const std::set& setModified); - - void RemoveModification(ETaskOptions eModified); - void RemoveModificationSet(TOptionsSet setOptions); - void RemoveModification(const chcore::TString& strModified); - void Clear(); - - static void NotificationProc(const chcore::TStringSet& setModifications, void* pParam); - -protected: - static ETaskOptions GetOptionFromString(const chcore::TString& strOption); - -protected: - std::set m_setModified; - mutable boost::shared_mutex m_lock; -}; - -#endif // __TCONFIGTRACKER_H__ Index: src/libchcore/TTaskConfiguration.h =================================================================== diff -u -N --- src/libchcore/TTaskConfiguration.h (revision 0) +++ src/libchcore/TTaskConfiguration.h (revision fb4c4006dee5aaf815d08bc3e89312445b994307) @@ -0,0 +1,163 @@ +// ============================================================================ +// Copyright (C) 2001-2010 by Jozef Starosczyk +// ixen@copyhandler.com +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License +// (version 2) as published by the Free Software Foundation; +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// ============================================================================ +/// @file TTaskConfiguration.h +/// @date 2010/09/18 +/// @brief Contains class responsible for keeping task configuration. +// ============================================================================ +#ifndef __TTASKCONFIGURATION_H__ +#define __TTASKCONFIGURATION_H__ + +#include "libchcore.h" +#include "TConfig.h" +#include "FileFilter.h" + +BEGIN_CHCORE_NAMESPACE + +enum ETaskOptions +{ + eTO_UseOnlyDefaultBuffer, + eTO_DefaultBufferSize, + eTO_OneDiskBufferSize, + eTO_TwoDisksBufferSize, + eTO_CDBufferSize, + eTO_LANBufferSize, + eTO_DisableBuffering, + eTO_DisableBufferingMinSize, + + eTO_SetDestinationAttributes, + eTO_SetDestinationDateTime, + eTO_ProtectReadOnlyFiles, + eTO_ScanDirectoriesBeforeBlocking, + eTO_ThreadPriority, + eTO_DisablePriorityBoost, + eTO_DeleteInSeparateSubTask, + + eTO_CreateEmptyFiles, + eTO_CreateDirectoriesRelativeToRoot, + eTO_IgnoreDirectories, + + eTO_AlternateFilenameFormatString_First, + eTO_AlternateFilenameFormatString_AfterFirst, + + eTO_Filters, + + // add new elements before this one + eTO_Last +}; + +///////////////////////////////////////////////////////////////////////////////////////////// +// Properties definitions + +template struct TaskPropData; + +#define TASK_PROPERTY(enum_id, val_type, val_name, def_value)\ + template<> struct TaskPropData\ +{\ + typedef val_type value_type;\ +\ + static value_type GetDefaultValue() { return def_value; }\ + static const wchar_t* GetPropertyName() { return val_name; }\ + static void ValidateRange(value_type&) {}\ +} + +#define TASK_PROPERTY_MINMAX(enum_id, val_type, val_name, def_value, min_val, max_val)\ + template<> struct TaskPropData\ +{\ + typedef val_type value_type;\ +\ + static value_type GetDefaultValue() { return def_value; }\ + static const wchar_t* GetPropertyName() { return val_name; }\ + static void ValidateRange(value_type& rValue)\ + {\ + if(rValue < (min_val))\ + rValue = (min_val);\ + else if(rValue > (max_val))\ + rValue = (max_val);\ + }\ +} + +// Buffer settings +TASK_PROPERTY(eTO_UseOnlyDefaultBuffer, bool, _T("Buffer.UseOnlyDefaultBuffer"), false); +TASK_PROPERTY_MINMAX(eTO_DefaultBufferSize, unsigned int, _T("Buffer.DefaultBufferSize"), 2097152, 1, 0xffffffff); +TASK_PROPERTY_MINMAX(eTO_OneDiskBufferSize, unsigned int, _T("Buffer.OnePhysicalDiskSize"), 4194304, 1, 0xffffffff); +TASK_PROPERTY_MINMAX(eTO_TwoDisksBufferSize, unsigned int, _T("Buffer.TwoPhysicalDisksSize"), 524288, 1, 0xffffffff); +TASK_PROPERTY_MINMAX(eTO_CDBufferSize, unsigned int, _T("Buffer.CDSize"), 262144, 1, 0xffffffff); +TASK_PROPERTY_MINMAX(eTO_LANBufferSize, unsigned int, _T("Buffer.LANSize"), 131072, 1, 0xffffffff); + +TASK_PROPERTY(eTO_DisableBuffering, bool, _T("Operation.Buffering.DisableBufferingForLargeFiles"), true); +TASK_PROPERTY_MINMAX(eTO_DisableBufferingMinSize, int, _T("Operation.Buffering.MinSizeOfFileToDisableBuffering"), 2097152, 1, 0xffffffff); + +TASK_PROPERTY(eTO_SetDestinationAttributes, bool, _T("Operation.SetDestinationAttributes"), true); +TASK_PROPERTY(eTO_SetDestinationDateTime, bool, _T("Operation.SetDestinationTime"), true); +TASK_PROPERTY(eTO_ProtectReadOnlyFiles, bool, _T("Operation.ProtectReadOnlyFiles"), true); +TASK_PROPERTY(eTO_ScanDirectoriesBeforeBlocking, bool, _T("Operation.ScanForFilesBeforeBlocking"), true); + +// Thread settings +TASK_PROPERTY(eTO_ThreadPriority, int, _T("Operation.Thread.Priority"), THREAD_PRIORITY_NORMAL); +TASK_PROPERTY(eTO_DisablePriorityBoost, bool, _T("Operation.Thread.DisablePriorityBoost"), false); + +// Operation settings +TASK_PROPERTY(eTO_DeleteInSeparateSubTask, bool, _T("Operation.DeleteFilesInSeparateOperation"), true); + +TASK_PROPERTY(eTO_CreateEmptyFiles, bool, _T("Operation.CreateEmptyFiles"), false); +TASK_PROPERTY(eTO_CreateDirectoriesRelativeToRoot, bool, _T("Operation.CreateDirectoriesRelativeToRoot"), false); +TASK_PROPERTY(eTO_IgnoreDirectories, bool, _T("Operation.IgnoreDirectories"), false); + +TASK_PROPERTY(eTO_Filters, chcore::TFiltersArray, _T("Operation.Filtering"), chcore::TFiltersArray()); + +// Naming settings +TASK_PROPERTY(eTO_AlternateFilenameFormatString_First, CString, _T("Naming.AlternateFilenameFormatFirst"), _T("Copy of %name")); +TASK_PROPERTY(eTO_AlternateFilenameFormatString_AfterFirst, CString, _T("Naming.AlternateFilenameFormatAfterFirst"), _T("Copy (%count) of %name")); + +///////////////////////////////////////////////////////////////////////////////////////////// +// other properties names +//#define TASK_PROP_NAME_FILTERING _T("Filtering") + +///////////////////////////////////////////////////////////////////////////////////////////// +// Properties retrieval +template +typename TaskPropData::value_type GetTaskPropValue(const chcore::TConfig& rConfig) +{ + typename TaskPropData::value_type tValue; + bool bResult = GetConfigValue(rConfig, TaskPropData::GetPropertyName(), tValue); + if(!bResult) + tValue = TaskPropData::GetDefaultValue(); + + TaskPropData::ValidateRange(tValue); + return tValue; +} + +template +bool GetTaskPropValue(const chcore::TConfig& rConfig, typename TaskPropData::value_type& rValue) +{ + bool bResult = GetConfigValue(rConfig, TaskPropData::GetPropertyName(), rValue); + if(bResult) + TaskPropData::ValidateRange(rValue); + return bResult; +} + +template +void SetTaskPropValue(chcore::TConfig& rConfig, const typename TaskPropData::value_type& rValue) +{ + SetConfigValue(rConfig, TaskPropData::GetPropertyName(), rValue); +} + +END_CHCORE_NAMESPACE + +#endif Index: src/ch/TTaskConfiguration.h =================================================================== diff -u -N --- src/ch/TTaskConfiguration.h (revision 2aea3ad6f3c68be709ac65c70d9646eafe3b034c) +++ src/ch/TTaskConfiguration.h (revision 0) @@ -1,159 +0,0 @@ -// ============================================================================ -// Copyright (C) 2001-2010 by Jozef Starosczyk -// ixen@copyhandler.com -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU Library General Public License -// (version 2) as published by the Free Software Foundation; -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this program; if not, write to the -// Free Software Foundation, Inc., -// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// ============================================================================ -/// @file TTaskConfiguration.h -/// @date 2010/09/18 -/// @brief Contains class responsible for keeping task configuration. -// ============================================================================ -#ifndef __TTASKCONFIGURATION_H__ -#define __TTASKCONFIGURATION_H__ - -#include "../libchcore/TConfig.h" -#include "../libchcore/FileFilter.h" - -enum ETaskOptions -{ - eTO_UseOnlyDefaultBuffer, - eTO_DefaultBufferSize, - eTO_OneDiskBufferSize, - eTO_TwoDisksBufferSize, - eTO_CDBufferSize, - eTO_LANBufferSize, - eTO_DisableBuffering, - eTO_DisableBufferingMinSize, - - eTO_SetDestinationAttributes, - eTO_SetDestinationDateTime, - eTO_ProtectReadOnlyFiles, - eTO_ScanDirectoriesBeforeBlocking, - eTO_ThreadPriority, - eTO_DisablePriorityBoost, - eTO_DeleteInSeparateSubTask, - - eTO_CreateEmptyFiles, - eTO_CreateDirectoriesRelativeToRoot, - eTO_IgnoreDirectories, - - eTO_AlternateFilenameFormatString_First, - eTO_AlternateFilenameFormatString_AfterFirst, - - eTO_Filters, - - // add new elements before this one - eTO_Last -}; - -///////////////////////////////////////////////////////////////////////////////////////////// -// Properties definitions - -template struct TaskPropData; - -#define TASK_PROPERTY(enum_id, val_type, val_name, def_value)\ - template<> struct TaskPropData\ -{\ - typedef val_type value_type;\ -\ - static value_type GetDefaultValue() { return def_value; }\ - static const wchar_t* GetPropertyName() { return val_name; }\ - static void ValidateRange(value_type&) {}\ -} - -#define TASK_PROPERTY_MINMAX(enum_id, val_type, val_name, def_value, min_val, max_val)\ - template<> struct TaskPropData\ -{\ - typedef val_type value_type;\ -\ - static value_type GetDefaultValue() { return def_value; }\ - static const wchar_t* GetPropertyName() { return val_name; }\ - static void ValidateRange(value_type& rValue)\ - {\ - if(rValue < (min_val))\ - rValue = (min_val);\ - else if(rValue > (max_val))\ - rValue = (max_val);\ - }\ -} - -// Buffer settings -TASK_PROPERTY(eTO_UseOnlyDefaultBuffer, bool, _T("Buffer.UseOnlyDefaultBuffer"), false); -TASK_PROPERTY_MINMAX(eTO_DefaultBufferSize, unsigned int, _T("Buffer.DefaultBufferSize"), 2097152, 1, 0xffffffff); -TASK_PROPERTY_MINMAX(eTO_OneDiskBufferSize, unsigned int, _T("Buffer.OnePhysicalDiskSize"), 4194304, 1, 0xffffffff); -TASK_PROPERTY_MINMAX(eTO_TwoDisksBufferSize, unsigned int, _T("Buffer.TwoPhysicalDisksSize"), 524288, 1, 0xffffffff); -TASK_PROPERTY_MINMAX(eTO_CDBufferSize, unsigned int, _T("Buffer.CDSize"), 262144, 1, 0xffffffff); -TASK_PROPERTY_MINMAX(eTO_LANBufferSize, unsigned int, _T("Buffer.LANSize"), 131072, 1, 0xffffffff); - -TASK_PROPERTY(eTO_DisableBuffering, bool, _T("Operation.Buffering.DisableBufferingForLargeFiles"), true); -TASK_PROPERTY_MINMAX(eTO_DisableBufferingMinSize, int, _T("Operation.Buffering.MinSizeOfFileToDisableBuffering"), 2097152, 1, 0xffffffff); - -TASK_PROPERTY(eTO_SetDestinationAttributes, bool, _T("Operation.SetDestinationAttributes"), true); -TASK_PROPERTY(eTO_SetDestinationDateTime, bool, _T("Operation.SetDestinationTime"), true); -TASK_PROPERTY(eTO_ProtectReadOnlyFiles, bool, _T("Operation.ProtectReadOnlyFiles"), true); -TASK_PROPERTY(eTO_ScanDirectoriesBeforeBlocking, bool, _T("Operation.ScanForFilesBeforeBlocking"), true); - -// Thread settings -TASK_PROPERTY(eTO_ThreadPriority, int, _T("Operation.Thread.Priority"), THREAD_PRIORITY_NORMAL); -TASK_PROPERTY(eTO_DisablePriorityBoost, bool, _T("Operation.Thread.DisablePriorityBoost"), false); - -// Operation settings -TASK_PROPERTY(eTO_DeleteInSeparateSubTask, bool, _T("Operation.DeleteFilesInSeparateOperation"), true); - -TASK_PROPERTY(eTO_CreateEmptyFiles, bool, _T("Operation.CreateEmptyFiles"), false); -TASK_PROPERTY(eTO_CreateDirectoriesRelativeToRoot, bool, _T("Operation.CreateDirectoriesRelativeToRoot"), false); -TASK_PROPERTY(eTO_IgnoreDirectories, bool, _T("Operation.IgnoreDirectories"), false); - -TASK_PROPERTY(eTO_Filters, chcore::TFiltersArray, _T("Operation.Filtering"), chcore::TFiltersArray()); - -// Naming settings -TASK_PROPERTY(eTO_AlternateFilenameFormatString_First, CString, _T("Naming.AlternateFilenameFormatFirst"), _T("Copy of %name")); -TASK_PROPERTY(eTO_AlternateFilenameFormatString_AfterFirst, CString, _T("Naming.AlternateFilenameFormatAfterFirst"), _T("Copy (%count) of %name")); - -///////////////////////////////////////////////////////////////////////////////////////////// -// other properties names -//#define TASK_PROP_NAME_FILTERING _T("Filtering") - -///////////////////////////////////////////////////////////////////////////////////////////// -// Properties retrieval -template -typename TaskPropData::value_type GetTaskPropValue(const chcore::TConfig& rConfig) -{ - typename TaskPropData::value_type tValue; - bool bResult = GetConfigValue(rConfig, TaskPropData::GetPropertyName(), tValue); - if(!bResult) - tValue = TaskPropData::GetDefaultValue(); - - TaskPropData::ValidateRange(tValue); - return tValue; -} - -template -bool GetTaskPropValue(const chcore::TConfig& rConfig, typename TaskPropData::value_type& rValue) -{ - bool bResult = GetConfigValue(rConfig, TaskPropData::GetPropertyName(), rValue); - if(bResult) - TaskPropData::ValidateRange(rValue); - return bResult; -} - -template -void SetTaskPropValue(chcore::TConfig& rConfig, const typename TaskPropData::value_type& rValue) -{ - SetConfigValue(rConfig, TaskPropData::GetPropertyName(), rValue); -} - - -#endif Index: src/libchcore/TTaskGlobalStats.cpp =================================================================== diff -u -N --- src/libchcore/TTaskGlobalStats.cpp (revision 0) +++ src/libchcore/TTaskGlobalStats.cpp (revision fb4c4006dee5aaf815d08bc3e89312445b994307) @@ -0,0 +1,123 @@ +// ============================================================================ +// Copyright (C) 2001-2009 by Jozef Starosczyk +// ixen@copyhandler.com +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License +// (version 2) as published by the Free Software Foundation; +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// ============================================================================ +/// @file TTaskGlobalStats.cpp +/// @date 2011/03/28 +/// @brief Contains declarations of classes responsible for maintaining task global stats. +// ============================================================================ +#include "stdafx.h" +#include "TTaskGlobalStats.h" +#include + +BEGIN_CHCORE_NAMESPACE + +//////////////////////////////////////////////////////////////////////////////// +// TTasksGlobalStats members + +TTasksGlobalStats::TTasksGlobalStats() : +m_ullGlobalTotalSize(0), +m_ullGlobalProcessedSize(0), +m_stRunningTasks(0) +{ +} + +TTasksGlobalStats::~TTasksGlobalStats() +{ +} + +void TTasksGlobalStats::IncreaseGlobalTotalSize(unsigned long long ullModify) +{ + boost::unique_lock lock(m_lock); + m_ullGlobalTotalSize += ullModify; +} + +void TTasksGlobalStats::DecreaseGlobalTotalSize(unsigned long long ullModify) +{ + boost::unique_lock lock(m_lock); + m_ullGlobalTotalSize -= ullModify; +} + +unsigned long long TTasksGlobalStats::GetGlobalTotalSize() const +{ + boost::shared_lock lock(m_lock); + return m_ullGlobalTotalSize; +} + +void TTasksGlobalStats::IncreaseGlobalProcessedSize(unsigned long long ullModify) +{ + boost::unique_lock lock(m_lock); + m_ullGlobalProcessedSize += ullModify; +} + +void TTasksGlobalStats::DecreaseGlobalProcessedSize(unsigned long long ullModify) +{ + boost::unique_lock lock(m_lock); + m_ullGlobalProcessedSize -= ullModify; +} + +unsigned long long TTasksGlobalStats::GetGlobalProcessedSize() const +{ + boost::shared_lock lock(m_lock); + return m_ullGlobalProcessedSize; +} + +void TTasksGlobalStats::IncreaseGlobalProgressData(unsigned long long ullTasksPosition, unsigned long long ullTasksSize) +{ + boost::unique_lock lock(m_lock); + m_ullGlobalTotalSize += ullTasksSize; + m_ullGlobalProcessedSize += ullTasksPosition; +} + +void TTasksGlobalStats::DecreaseGlobalProgressData(unsigned long long ullTasksPosition, unsigned long long ullTasksSize) +{ + boost::unique_lock lock(m_lock); + m_ullGlobalTotalSize -= ullTasksSize; + m_ullGlobalProcessedSize -= ullTasksPosition; +} + +int TTasksGlobalStats::GetProgressPercents() const +{ + unsigned long long llPercent = 0; + + boost::shared_lock lock(m_lock); + + if(m_ullGlobalTotalSize != 0) + llPercent = m_ullGlobalProcessedSize * 100 / m_ullGlobalTotalSize; + + return boost::numeric_cast(llPercent); +} + +void TTasksGlobalStats::IncreaseRunningTasks() +{ + boost::unique_lock lock(m_lock); + ++m_stRunningTasks; +} + +void TTasksGlobalStats::DecreaseRunningTasks() +{ + boost::unique_lock lock(m_lock); + --m_stRunningTasks; +} + +size_t TTasksGlobalStats::GetRunningTasksCount() const +{ + boost::shared_lock lock(m_lock); + return m_stRunningTasks; +} + +END_CHCORE_NAMESPACE Index: src/ch/TTaskGlobalStats.cpp =================================================================== diff -u -N --- src/ch/TTaskGlobalStats.cpp (revision 6e8aa26e2428e3bc71099255c5911f57bc722100) +++ src/ch/TTaskGlobalStats.cpp (revision 0) @@ -1,118 +0,0 @@ -// ============================================================================ -// Copyright (C) 2001-2009 by Jozef Starosczyk -// ixen@copyhandler.com -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU Library General Public License -// (version 2) as published by the Free Software Foundation; -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this program; if not, write to the -// Free Software Foundation, Inc., -// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// ============================================================================ -/// @file TTaskGlobalStats.cpp -/// @date 2011/03/28 -/// @brief Contains declarations of classes responsible for maintaining task global stats. -// ============================================================================ -#include "stdafx.h" -#include "TTaskGlobalStats.h" - -//////////////////////////////////////////////////////////////////////////////// -// TTasksGlobalStats members - -TTasksGlobalStats::TTasksGlobalStats() : -m_ullGlobalTotalSize(0), -m_ullGlobalProcessedSize(0), -m_stRunningTasks(0) -{ -} - -TTasksGlobalStats::~TTasksGlobalStats() -{ -} - -void TTasksGlobalStats::IncreaseGlobalTotalSize(unsigned long long ullModify) -{ - boost::unique_lock lock(m_lock); - m_ullGlobalTotalSize += ullModify; -} - -void TTasksGlobalStats::DecreaseGlobalTotalSize(unsigned long long ullModify) -{ - boost::unique_lock lock(m_lock); - m_ullGlobalTotalSize -= ullModify; -} - -unsigned long long TTasksGlobalStats::GetGlobalTotalSize() const -{ - boost::shared_lock lock(m_lock); - return m_ullGlobalTotalSize; -} - -void TTasksGlobalStats::IncreaseGlobalProcessedSize(unsigned long long ullModify) -{ - boost::unique_lock lock(m_lock); - m_ullGlobalProcessedSize += ullModify; -} - -void TTasksGlobalStats::DecreaseGlobalProcessedSize(unsigned long long ullModify) -{ - boost::unique_lock lock(m_lock); - m_ullGlobalProcessedSize -= ullModify; -} - -unsigned long long TTasksGlobalStats::GetGlobalProcessedSize() const -{ - boost::shared_lock lock(m_lock); - return m_ullGlobalProcessedSize; -} - -void TTasksGlobalStats::IncreaseGlobalProgressData(unsigned long long ullTasksPosition, unsigned long long ullTasksSize) -{ - boost::unique_lock lock(m_lock); - m_ullGlobalTotalSize += ullTasksSize; - m_ullGlobalProcessedSize += ullTasksPosition; -} - -void TTasksGlobalStats::DecreaseGlobalProgressData(unsigned long long ullTasksPosition, unsigned long long ullTasksSize) -{ - boost::unique_lock lock(m_lock); - m_ullGlobalTotalSize -= ullTasksSize; - m_ullGlobalProcessedSize -= ullTasksPosition; -} - -int TTasksGlobalStats::GetProgressPercents() const -{ - unsigned long long llPercent = 0; - - boost::shared_lock lock(m_lock); - - if(m_ullGlobalTotalSize != 0) - llPercent = m_ullGlobalProcessedSize * 100 / m_ullGlobalTotalSize; - - return boost::numeric_cast(llPercent); -} - -void TTasksGlobalStats::IncreaseRunningTasks() -{ - boost::unique_lock lock(m_lock); - ++m_stRunningTasks; -} - -void TTasksGlobalStats::DecreaseRunningTasks() -{ - boost::unique_lock lock(m_lock); - --m_stRunningTasks; -} - -size_t TTasksGlobalStats::GetRunningTasksCount() const -{ - boost::shared_lock lock(m_lock); - return m_stRunningTasks; -} Index: src/libchcore/TTaskGlobalStats.h =================================================================== diff -u -N --- src/libchcore/TTaskGlobalStats.h (revision 0) +++ src/libchcore/TTaskGlobalStats.h (revision fb4c4006dee5aaf815d08bc3e89312445b994307) @@ -0,0 +1,68 @@ +// ============================================================================ +// Copyright (C) 2001-2009 by Jozef Starosczyk +// ixen@copyhandler.com +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License +// (version 2) as published by the Free Software Foundation; +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// ============================================================================ +/// @file TTaskGlobalStats.h +/// @date 2011/03/28 +/// @brief Contains declarations of classes responsible for maintaining task global stats. +// ============================================================================ +#ifndef __TTASKGLOBALSTATS_H__ +#define __TTASKGLOBALSTATS_H__ + +#include "libchcore.h" + +BEGIN_CHCORE_NAMESPACE + +/////////////////////////////////////////////////////////////////////////// +// TTasksGlobalStats +class LIBCHCORE_API TTasksGlobalStats +{ +public: + TTasksGlobalStats(); + ~TTasksGlobalStats(); + + void IncreaseGlobalTotalSize(unsigned long long ullModify); + void DecreaseGlobalTotalSize(unsigned long long ullModify); + unsigned long long GetGlobalTotalSize() const; + + void IncreaseGlobalProcessedSize(unsigned long long ullModify); + void DecreaseGlobalProcessedSize(unsigned long long ullModify); + unsigned long long GetGlobalProcessedSize() const; + + void IncreaseGlobalProgressData(unsigned long long ullTasksPosition, unsigned long long ullTasksSize); + void DecreaseGlobalProgressData(unsigned long long ullTasksPosition, unsigned long long ullTasksSize); + + int GetProgressPercents() const; + + void IncreaseRunningTasks(); + void DecreaseRunningTasks(); + size_t GetRunningTasksCount() const; + +private: + volatile unsigned long long m_ullGlobalTotalSize; + volatile unsigned long long m_ullGlobalProcessedSize; + + volatile size_t m_stRunningTasks; // count of current operations +#pragma warning(push) +#pragma warning(disable: 4251) + mutable boost::shared_mutex m_lock; +#pragma warning(pop) +}; + +END_CHCORE_NAMESPACE + +#endif Index: src/ch/TTaskGlobalStats.h =================================================================== diff -u -N --- src/ch/TTaskGlobalStats.h (revision 6e8aa26e2428e3bc71099255c5911f57bc722100) +++ src/ch/TTaskGlobalStats.h (revision 0) @@ -1,59 +0,0 @@ -// ============================================================================ -// Copyright (C) 2001-2009 by Jozef Starosczyk -// ixen@copyhandler.com -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU Library General Public License -// (version 2) as published by the Free Software Foundation; -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this program; if not, write to the -// Free Software Foundation, Inc., -// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// ============================================================================ -/// @file TTaskGlobalStats.h -/// @date 2011/03/28 -/// @brief Contains declarations of classes responsible for maintaining task global stats. -// ============================================================================ -#ifndef __TTASKGLOBALSTATS_H__ -#define __TTASKGLOBALSTATS_H__ - -/////////////////////////////////////////////////////////////////////////// -// TTasksGlobalStats -class TTasksGlobalStats -{ -public: - TTasksGlobalStats(); - ~TTasksGlobalStats(); - - void IncreaseGlobalTotalSize(unsigned long long ullModify); - void DecreaseGlobalTotalSize(unsigned long long ullModify); - unsigned long long GetGlobalTotalSize() const; - - void IncreaseGlobalProcessedSize(unsigned long long ullModify); - void DecreaseGlobalProcessedSize(unsigned long long ullModify); - unsigned long long GetGlobalProcessedSize() const; - - void IncreaseGlobalProgressData(unsigned long long ullTasksPosition, unsigned long long ullTasksSize); - void DecreaseGlobalProgressData(unsigned long long ullTasksPosition, unsigned long long ullTasksSize); - - int GetProgressPercents() const; - - void IncreaseRunningTasks(); - void DecreaseRunningTasks(); - size_t GetRunningTasksCount() const; - -private: - volatile unsigned long long m_ullGlobalTotalSize; - volatile unsigned long long m_ullGlobalProcessedSize; - - volatile size_t m_stRunningTasks; // count of current operations - mutable boost::shared_mutex m_lock; -}; - -#endif Index: src/libchcore/TTaskLocalStats.cpp =================================================================== diff -u -N --- src/libchcore/TTaskLocalStats.cpp (revision 0) +++ src/libchcore/TTaskLocalStats.cpp (revision fb4c4006dee5aaf815d08bc3e89312445b994307) @@ -0,0 +1,262 @@ +// ============================================================================ +// Copyright (C) 2001-2011 by Jozef Starosczyk +// ixen@copyhandler.com +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License +// (version 2) as published by the Free Software Foundation; +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// ============================================================================ +/// @file TTaskLocalStats.cpp +/// @date 2011/03/28 +/// @brief Contains implementation of classes responsible for maintaining local task stats. +// ============================================================================ +#include "stdafx.h" +#include "TTaskLocalStats.h" +#include "TTaskGlobalStats.h" +#include + +BEGIN_CHCORE_NAMESPACE + +//////////////////////////////////////////////////////////////////////////////// +// TTasksGlobalStats members +TTaskLocalStats::TTaskLocalStats() : +m_prtGlobalStats(NULL), +m_ullProcessedSize(0), +m_ullTotalSize(0), +m_bTaskIsRunning(false), +m_timeElapsed(0), +m_timeLast(-1), +m_iCurrentBufferIndex(0) +{ +} + +TTaskLocalStats::~TTaskLocalStats() +{ + DisconnectGlobalStats(); +} + +void TTaskLocalStats::ConnectGlobalStats(TTasksGlobalStats& rtGlobalStats) +{ + DisconnectGlobalStats(); + + boost::unique_lock lock(m_lock); + + m_prtGlobalStats = &rtGlobalStats; + m_prtGlobalStats->IncreaseGlobalProgressData(m_ullProcessedSize, m_ullTotalSize); + if(m_bTaskIsRunning) + m_prtGlobalStats->IncreaseRunningTasks(); +} + +void TTaskLocalStats::DisconnectGlobalStats() +{ + boost::unique_lock lock(m_lock); + + if(m_prtGlobalStats) + { + m_prtGlobalStats->DecreaseGlobalProgressData(m_ullProcessedSize, m_ullTotalSize); + if(m_bTaskIsRunning) + m_prtGlobalStats->DecreaseRunningTasks(); + m_prtGlobalStats = NULL; + } +} + +void TTaskLocalStats::IncreaseProcessedSize(unsigned long long ullAdd) +{ + boost::unique_lock lock(m_lock); + + if(m_prtGlobalStats) + m_prtGlobalStats->IncreaseGlobalProcessedSize(ullAdd); + + m_ullProcessedSize += ullAdd; +} + +void TTaskLocalStats::DecreaseProcessedSize(unsigned long long ullSub) +{ + boost::unique_lock lock(m_lock); + if(m_prtGlobalStats) + m_prtGlobalStats->DecreaseGlobalProcessedSize(ullSub); + + m_ullProcessedSize -= ullSub; +} + +void TTaskLocalStats::SetProcessedSize(unsigned long long ullSet) +{ + boost::unique_lock lock(m_lock); + + if(m_prtGlobalStats) + { + if(ullSet < m_ullProcessedSize) + m_prtGlobalStats->DecreaseGlobalProcessedSize(m_ullProcessedSize - ullSet); + else + m_prtGlobalStats->IncreaseGlobalProcessedSize(ullSet - m_ullProcessedSize); + } + + m_ullProcessedSize = ullSet; +} + +unsigned long long TTaskLocalStats::GetProcessedSize() const +{ + boost::shared_lock lock(m_lock); + return m_ullProcessedSize; +} + +unsigned long long TTaskLocalStats::GetUnProcessedSize() const +{ + boost::shared_lock lock(m_lock); + return m_ullTotalSize - m_ullProcessedSize; +} + +void TTaskLocalStats::IncreaseTotalSize(unsigned long long ullAdd) +{ + boost::unique_lock lock(m_lock); + + if(m_prtGlobalStats) + m_prtGlobalStats->IncreaseGlobalTotalSize(ullAdd); + m_ullTotalSize += ullAdd; +} + +void TTaskLocalStats::DecreaseTotalSize(unsigned long long ullSub) +{ + boost::unique_lock lock(m_lock); + + if(m_prtGlobalStats) + m_prtGlobalStats->DecreaseGlobalTotalSize(ullSub); + + m_ullTotalSize -= ullSub; +} + +void TTaskLocalStats::SetTotalSize(unsigned long long ullSet) +{ + boost::unique_lock lock(m_lock); + + if(m_prtGlobalStats) + { + if(ullSet < m_ullTotalSize) + m_prtGlobalStats->DecreaseGlobalTotalSize(m_ullTotalSize - ullSet); + else + m_prtGlobalStats->IncreaseGlobalTotalSize(ullSet - m_ullTotalSize); + } + + m_ullTotalSize = ullSet; +} + +unsigned long long TTaskLocalStats::GetTotalSize() const +{ + boost::shared_lock lock(m_lock); + return m_ullTotalSize; +} + +int TTaskLocalStats::GetProgressInPercent() const +{ + boost::shared_lock lock(m_lock); + + unsigned long long ullPercent = 0; + + if(m_ullTotalSize != 0) + ullPercent = m_ullProcessedSize * 100 / m_ullTotalSize; + + return boost::numeric_cast(ullPercent); +} + +void TTaskLocalStats::MarkTaskAsRunning() +{ + boost::unique_lock lock(m_lock); + if(!m_bTaskIsRunning) + { + if(m_prtGlobalStats) + m_prtGlobalStats->IncreaseRunningTasks(); + m_bTaskIsRunning = true; + } +} + +void TTaskLocalStats::MarkTaskAsNotRunning() +{ + boost::unique_lock lock(m_lock); + if(m_bTaskIsRunning) + { + if(m_prtGlobalStats) + m_prtGlobalStats->DecreaseRunningTasks(); + m_bTaskIsRunning = false; + } +} + +bool TTaskLocalStats::IsRunning() const +{ + boost::shared_lock lock(m_lock); + return m_bTaskIsRunning; +} + +void TTaskLocalStats::SetTimeElapsed(time_t timeElapsed) +{ + boost::unique_lock lock(m_lock); + m_timeElapsed = timeElapsed; +} + +time_t TTaskLocalStats::GetTimeElapsed() +{ + UpdateTime(); + + boost::shared_lock lock(m_lock); + return m_timeElapsed; +} + +void TTaskLocalStats::EnableTimeTracking() +{ + boost::upgrade_lock lock(m_lock); + if(m_timeLast == -1) + { + boost::upgrade_to_unique_lock lock_upgraded(lock); + m_timeLast = time(NULL); + } +} + +void TTaskLocalStats::DisableTimeTracking() +{ + UpdateTime(); + + boost::upgrade_lock lock(m_lock); + if(m_timeLast != -1) + { + boost::upgrade_to_unique_lock lock_upgraded(lock); + m_timeLast = -1; + } +} + +void TTaskLocalStats::UpdateTime() +{ + boost::upgrade_lock lock(m_lock); + if(m_timeLast != -1) + { + time_t timeCurrent = time(NULL); + + boost::upgrade_to_unique_lock lock_upgraded(lock); + m_timeElapsed += timeCurrent - m_timeLast; + m_timeLast = timeCurrent; + } +} + +void TTaskLocalStats::SetCurrentBufferIndex(int iCurrentIndex) +{ + boost::unique_lock lock(m_lock); + m_iCurrentBufferIndex = iCurrentIndex; +} + +int TTaskLocalStats::GetCurrentBufferIndex() const +{ + // locking possibly not needed, not entirely sure now + boost::shared_lock lock(m_lock); + int iResult = m_iCurrentBufferIndex; + return iResult; +} + +END_CHCORE_NAMESPACE Index: src/ch/TTaskLocalStats.cpp =================================================================== diff -u -N --- src/ch/TTaskLocalStats.cpp (revision 6e8aa26e2428e3bc71099255c5911f57bc722100) +++ src/ch/TTaskLocalStats.cpp (revision 0) @@ -1,257 +0,0 @@ -// ============================================================================ -// Copyright (C) 2001-2011 by Jozef Starosczyk -// ixen@copyhandler.com -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU Library General Public License -// (version 2) as published by the Free Software Foundation; -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this program; if not, write to the -// Free Software Foundation, Inc., -// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// ============================================================================ -/// @file TTaskLocalStats.cpp -/// @date 2011/03/28 -/// @brief Contains implementation of classes responsible for maintaining local task stats. -// ============================================================================ -#include "stdafx.h" -#include "TTaskLocalStats.h" -#include "TTaskGlobalStats.h" - -//////////////////////////////////////////////////////////////////////////////// -// TTasksGlobalStats members -TTaskLocalStats::TTaskLocalStats() : -m_prtGlobalStats(NULL), -m_ullProcessedSize(0), -m_ullTotalSize(0), -m_bTaskIsRunning(false), -m_timeElapsed(0), -m_timeLast(-1), -m_iCurrentBufferIndex(0) -{ -} - -TTaskLocalStats::~TTaskLocalStats() -{ - DisconnectGlobalStats(); -} - -void TTaskLocalStats::ConnectGlobalStats(TTasksGlobalStats& rtGlobalStats) -{ - DisconnectGlobalStats(); - - boost::unique_lock lock(m_lock); - - m_prtGlobalStats = &rtGlobalStats; - m_prtGlobalStats->IncreaseGlobalProgressData(m_ullProcessedSize, m_ullTotalSize); - if(m_bTaskIsRunning) - m_prtGlobalStats->IncreaseRunningTasks(); -} - -void TTaskLocalStats::DisconnectGlobalStats() -{ - boost::unique_lock lock(m_lock); - - if(m_prtGlobalStats) - { - m_prtGlobalStats->DecreaseGlobalProgressData(m_ullProcessedSize, m_ullTotalSize); - if(m_bTaskIsRunning) - m_prtGlobalStats->DecreaseRunningTasks(); - m_prtGlobalStats = NULL; - } -} - -void TTaskLocalStats::IncreaseProcessedSize(unsigned long long ullAdd) -{ - boost::unique_lock lock(m_lock); - - if(m_prtGlobalStats) - m_prtGlobalStats->IncreaseGlobalProcessedSize(ullAdd); - - m_ullProcessedSize += ullAdd; -} - -void TTaskLocalStats::DecreaseProcessedSize(unsigned long long ullSub) -{ - boost::unique_lock lock(m_lock); - if(m_prtGlobalStats) - m_prtGlobalStats->DecreaseGlobalProcessedSize(ullSub); - - m_ullProcessedSize -= ullSub; -} - -void TTaskLocalStats::SetProcessedSize(unsigned long long ullSet) -{ - boost::unique_lock lock(m_lock); - - if(m_prtGlobalStats) - { - if(ullSet < m_ullProcessedSize) - m_prtGlobalStats->DecreaseGlobalProcessedSize(m_ullProcessedSize - ullSet); - else - m_prtGlobalStats->IncreaseGlobalProcessedSize(ullSet - m_ullProcessedSize); - } - - m_ullProcessedSize = ullSet; -} - -unsigned long long TTaskLocalStats::GetProcessedSize() const -{ - boost::shared_lock lock(m_lock); - return m_ullProcessedSize; -} - -unsigned long long TTaskLocalStats::GetUnProcessedSize() const -{ - boost::shared_lock lock(m_lock); - return m_ullTotalSize - m_ullProcessedSize; -} - -void TTaskLocalStats::IncreaseTotalSize(unsigned long long ullAdd) -{ - boost::unique_lock lock(m_lock); - - if(m_prtGlobalStats) - m_prtGlobalStats->IncreaseGlobalTotalSize(ullAdd); - m_ullTotalSize += ullAdd; -} - -void TTaskLocalStats::DecreaseTotalSize(unsigned long long ullSub) -{ - boost::unique_lock lock(m_lock); - - if(m_prtGlobalStats) - m_prtGlobalStats->DecreaseGlobalTotalSize(ullSub); - - m_ullTotalSize -= ullSub; -} - -void TTaskLocalStats::SetTotalSize(unsigned long long ullSet) -{ - boost::unique_lock lock(m_lock); - - if(m_prtGlobalStats) - { - if(ullSet < m_ullTotalSize) - m_prtGlobalStats->DecreaseGlobalTotalSize(m_ullTotalSize - ullSet); - else - m_prtGlobalStats->IncreaseGlobalTotalSize(ullSet - m_ullTotalSize); - } - - m_ullTotalSize = ullSet; -} - -unsigned long long TTaskLocalStats::GetTotalSize() const -{ - boost::shared_lock lock(m_lock); - return m_ullTotalSize; -} - -int TTaskLocalStats::GetProgressInPercent() const -{ - boost::shared_lock lock(m_lock); - - unsigned long long ullPercent = 0; - - if(m_ullTotalSize != 0) - ullPercent = m_ullProcessedSize * 100 / m_ullTotalSize; - - return boost::numeric_cast(ullPercent); -} - -void TTaskLocalStats::MarkTaskAsRunning() -{ - boost::unique_lock lock(m_lock); - if(!m_bTaskIsRunning) - { - if(m_prtGlobalStats) - m_prtGlobalStats->IncreaseRunningTasks(); - m_bTaskIsRunning = true; - } -} - -void TTaskLocalStats::MarkTaskAsNotRunning() -{ - boost::unique_lock lock(m_lock); - if(m_bTaskIsRunning) - { - if(m_prtGlobalStats) - m_prtGlobalStats->DecreaseRunningTasks(); - m_bTaskIsRunning = false; - } -} - -bool TTaskLocalStats::IsRunning() const -{ - boost::shared_lock lock(m_lock); - return m_bTaskIsRunning; -} - -void TTaskLocalStats::SetTimeElapsed(time_t timeElapsed) -{ - boost::unique_lock lock(m_lock); - m_timeElapsed = timeElapsed; -} - -time_t TTaskLocalStats::GetTimeElapsed() -{ - UpdateTime(); - - boost::shared_lock lock(m_lock); - return m_timeElapsed; -} - -void TTaskLocalStats::EnableTimeTracking() -{ - boost::upgrade_lock lock(m_lock); - if(m_timeLast == -1) - { - boost::upgrade_to_unique_lock lock_upgraded(lock); - m_timeLast = time(NULL); - } -} - -void TTaskLocalStats::DisableTimeTracking() -{ - UpdateTime(); - - boost::upgrade_lock lock(m_lock); - if(m_timeLast != -1) - { - boost::upgrade_to_unique_lock lock_upgraded(lock); - m_timeLast = -1; - } -} - -void TTaskLocalStats::UpdateTime() -{ - boost::upgrade_lock lock(m_lock); - if(m_timeLast != -1) - { - time_t timeCurrent = time(NULL); - - boost::upgrade_to_unique_lock lock_upgraded(lock); - m_timeElapsed += timeCurrent - m_timeLast; - m_timeLast = timeCurrent; - } -} - -void TTaskLocalStats::SetCurrentBufferIndex(int iCurrentIndex) -{ - boost::unique_lock lock(m_lock); - m_iCurrentBufferIndex = iCurrentIndex; -} - -int TTaskLocalStats::GetCurrentBufferIndex() const -{ - // locking possibly not needed, not entirely sure now - boost::shared_lock lock(m_lock); - int iResult = m_iCurrentBufferIndex; - return iResult; -} Index: src/libchcore/TTaskLocalStats.h =================================================================== diff -u -N --- src/libchcore/TTaskLocalStats.h (revision 0) +++ src/libchcore/TTaskLocalStats.h (revision fb4c4006dee5aaf815d08bc3e89312445b994307) @@ -0,0 +1,89 @@ +// ============================================================================ +// Copyright (C) 2001-2011 by Jozef Starosczyk +// ixen@copyhandler.com +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU Library General Public License +// (version 2) as published by the Free Software Foundation; +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this program; if not, write to the +// Free Software Foundation, Inc., +// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// ============================================================================ +/// @file TTaskLocalStats.h +/// @date 2011/03/28 +/// @brief Contains classes responsible for maintaining local task stats. +// ============================================================================ +#ifndef __TTASKLOCALSTATS_H__ +#define __TTASKLOCALSTATS_H__ + +#include "libchcore.h" + +BEGIN_CHCORE_NAMESPACE + +class TTasksGlobalStats; + +class LIBCHCORE_API TTaskLocalStats +{ +public: + TTaskLocalStats(); + ~TTaskLocalStats(); + + void ConnectGlobalStats(TTasksGlobalStats& rtGlobalStats); + void DisconnectGlobalStats(); + + void IncreaseProcessedSize(unsigned long long ullAdd); + void DecreaseProcessedSize(unsigned long long ullSub); + void SetProcessedSize(unsigned long long ullSet); + unsigned long long GetProcessedSize() const; + unsigned long long GetUnProcessedSize() const; + + void IncreaseTotalSize(unsigned long long ullAdd); + void DecreaseTotalSize(unsigned long long ullSub); + void SetTotalSize(unsigned long long ullSet); + unsigned long long GetTotalSize() const; + + int GetProgressInPercent() const; + + void MarkTaskAsRunning(); + void MarkTaskAsNotRunning(); + bool IsRunning() const; + + void SetTimeElapsed(time_t timeElapsed); + time_t GetTimeElapsed(); + + void EnableTimeTracking(); + void DisableTimeTracking(); + void UpdateTime(); + + void SetCurrentBufferIndex(int iCurrentIndex); + int GetCurrentBufferIndex() const; + +private: + volatile unsigned long long m_ullProcessedSize; + volatile unsigned long long m_ullTotalSize; + + volatile bool m_bTaskIsRunning; + + // time + volatile time_t m_timeElapsed; + volatile time_t m_timeLast; + + volatile int m_iCurrentBufferIndex; + +#pragma warning(push) +#pragma warning(disable: 4251) + mutable boost::shared_mutex m_lock; +#pragma warning(pop) + TTasksGlobalStats* m_prtGlobalStats; +}; + +END_CHCORE_NAMESPACE + +#endif Index: src/ch/TTaskLocalStats.h =================================================================== diff -u -N --- src/ch/TTaskLocalStats.h (revision 6e8aa26e2428e3bc71099255c5911f57bc722100) +++ src/ch/TTaskLocalStats.h (revision 0) @@ -1,80 +0,0 @@ -// ============================================================================ -// Copyright (C) 2001-2011 by Jozef Starosczyk -// ixen@copyhandler.com -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU Library General Public License -// (version 2) as published by the Free Software Foundation; -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this program; if not, write to the -// Free Software Foundation, Inc., -// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// ============================================================================ -/// @file TTaskLocalStats.h -/// @date 2011/03/28 -/// @brief Contains classes responsible for maintaining local task stats. -// ============================================================================ -#ifndef __TTASKLOCALSTATS_H__ -#define __TTASKLOCALSTATS_H__ - -class TTasksGlobalStats; - -class TTaskLocalStats -{ -public: - TTaskLocalStats(); - ~TTaskLocalStats(); - - void ConnectGlobalStats(TTasksGlobalStats& rtGlobalStats); - void DisconnectGlobalStats(); - - void IncreaseProcessedSize(unsigned long long ullAdd); - void DecreaseProcessedSize(unsigned long long ullSub); - void SetProcessedSize(unsigned long long ullSet); - unsigned long long GetProcessedSize() const; - unsigned long long GetUnProcessedSize() const; - - void IncreaseTotalSize(unsigned long long ullAdd); - void DecreaseTotalSize(unsigned long long ullSub); - void SetTotalSize(unsigned long long ullSet); - unsigned long long GetTotalSize() const; - - int GetProgressInPercent() const; - - void MarkTaskAsRunning(); - void MarkTaskAsNotRunning(); - bool IsRunning() const; - - void SetTimeElapsed(time_t timeElapsed); - time_t GetTimeElapsed(); - - void EnableTimeTracking(); - void DisableTimeTracking(); - void UpdateTime(); - - void SetCurrentBufferIndex(int iCurrentIndex); - int GetCurrentBufferIndex() const; - -private: - volatile unsigned long long m_ullProcessedSize; - volatile unsigned long long m_ullTotalSize; - - volatile bool m_bTaskIsRunning; - - // time - volatile time_t m_timeElapsed; - volatile time_t m_timeLast; - - volatile int m_iCurrentBufferIndex; - - mutable boost::shared_mutex m_lock; - TTasksGlobalStats* m_prtGlobalStats; -}; - -#endif Index: src/libchcore/libchcore.vc90.vcproj =================================================================== diff -u -N -rf46d334ffd78c7daa7626f214ae698adbac5f36d -rfb4c4006dee5aaf815d08bc3e89312445b994307 --- src/libchcore/libchcore.vc90.vcproj (.../libchcore.vc90.vcproj) (revision f46d334ffd78c7daa7626f214ae698adbac5f36d) +++ src/libchcore/libchcore.vc90.vcproj (.../libchcore.vc90.vcproj) (revision fb4c4006dee5aaf815d08bc3e89312445b994307) @@ -364,13 +364,61 @@ > + + + + + + + + + + + + + + + + + + + + + + + +