Index: src/ch/CfgProperties.h =================================================================== diff -u -N -rd037fe7234987387e26b0be460be37a956fcb27d -rd18db617f4727a237c94b59af9b4328f829eda16 --- src/ch/CfgProperties.h (.../CfgProperties.h) (revision d037fe7234987387e26b0be460be37a956fcb27d) +++ src/ch/CfgProperties.h (.../CfgProperties.h) (revision d18db617f4727a237c94b59af9b4328f829eda16) @@ -63,6 +63,11 @@ PP_CMSETDESTATTRIBUTES, PP_CMSETDESTDATE, PP_CMPROTECTROFILES, + + PP_USECUSTOMNAMING, + PP_CUSTOMNAME_FIRST, + PP_CUSTOMNAME_SUBSEQUENT, + PP_CMLIMITMAXOPERATIONS, PP_CMREADSIZEBEFOREBLOCKING, PP_CMFASTMOVEBEFOREBLOCKING, @@ -253,6 +258,10 @@ ADAPT_TASK_PROPERTY(PP_CMDISABLEPRIORITYBOOST, chcore::eTO_DisablePriorityBoost); ADAPT_TASK_PROPERTY(PP_CMDELETEAFTERFINISHED, chcore::eTO_DeleteInSeparateSubTask); +PROPERTY(PP_USECUSTOMNAMING, bool, _T("CHConfig.Core.Naming.UseCustomNaming"), false); +PROPERTY(PP_CUSTOMNAME_FIRST, CString, _T("CHConfig.Core.Naming.FirstCustomName"), _T("")); +PROPERTY(PP_CUSTOMNAME_SUBSEQUENT, CString, _T("CHConfig.Core.Naming.SubsequentCustomName"), _T("")); + // Shell extension PROPERTY(PP_SHSHOWCOPY, bool, _T("CHConfig.ShellExtension.ShowCommands.Copy"), true); PROPERTY(PP_SHSHOWMOVE, bool, _T("CHConfig.ShellExtension.ShowCommands.Move"), true); Index: src/ch/OptionsDlg.cpp =================================================================== diff -u -N -r4fe995b304ea342b50293f92d3c1992b43b820f7 -rd18db617f4727a237c94b59af9b4328f829eda16 --- src/ch/OptionsDlg.cpp (.../OptionsDlg.cpp) (revision 4fe995b304ea342b50293f92d3c1992b43b820f7) +++ src/ch/OptionsDlg.cpp (.../OptionsDlg.cpp) (revision d18db617f4727a237c94b59af9b4328f829eda16) @@ -78,6 +78,9 @@ #define PROP_CUSTOM_UINT(text, value, callback, param)\ m_ctlProperties.AddString(text, ID_PROPERTY_CUSTOM, CString(boost::lexical_cast((value)).c_str()), callback, this, param, 0) +#define PROP_STRING(text, value)\ + m_ctlProperties.AddString(text, ID_PROPERTY_TEXT, (value), 0) + #define SKIP_SEPARATOR(pos)\ pos++ @@ -285,6 +288,11 @@ PROP_BOOL(IDS_SETDESTATTRIB_STRING, GetPropValue(GetConfig())); PROP_BOOL(IDS_SETDESTTIME_STRING, GetPropValue(GetConfig())); PROP_BOOL(IDS_PROTECTROFILES_STRING, GetPropValue(GetConfig())); + + PROP_BOOL(IDS_USECUSTOMNAMING, GetPropValue(GetConfig())); + PROP_STRING(IDS_CUSTOMNAME_FIRST, GetPropValue(GetConfig())); + PROP_STRING(IDS_CUSTOMNAME_SUBSEQUENT, GetPropValue(GetConfig())); + PROP_UINT(IDS_LIMITOPERATIONS_STRING, GetPropValue(GetConfig())); PROP_BOOL(IDS_READSIZEBEFOREBLOCK_STRING, GetPropValue(GetConfig())); PROP_BOOL(IDS_FASTMOVEBEFOREBLOCK_STRING, GetPropValue(GetConfig())); @@ -400,6 +408,10 @@ SetPropValue(rConfig, GetBoolProp(iPosition++)); SetPropValue(rConfig, GetBoolProp(iPosition++)); SetPropValue(rConfig, GetBoolProp(iPosition++)); + SetPropValue(rConfig, GetBoolProp(iPosition++)); + SetPropValue(rConfig, GetStringProp(iPosition++)); + SetPropValue(rConfig, GetStringProp(iPosition++)); + SetPropValue(rConfig, GetUintProp(iPosition++)); SetPropValue(rConfig, GetBoolProp(iPosition++)); SetPropValue(rConfig, GetBoolProp(iPosition++)); Index: src/ch/TTaskManagerWrapper.cpp =================================================================== diff -u -N -r25129f39720523eca2cb702242890a7862f70ec6 -rd18db617f4727a237c94b59af9b4328f829eda16 --- src/ch/TTaskManagerWrapper.cpp (.../TTaskManagerWrapper.cpp) (revision 25129f39720523eca2cb702242890a7862f70ec6) +++ src/ch/TTaskManagerWrapper.cpp (.../TTaskManagerWrapper.cpp) (revision d18db617f4727a237c94b59af9b4328f829eda16) @@ -24,6 +24,8 @@ #include "..\libchcore\TTaskDefinition.h" #include "..\libchcore\TTask.h" #include "..\libchcore\TBaseException.h" +#include "CfgProperties.h" +#include "ch.h" TTaskManagerWrapper::TTaskManagerWrapper(const chcore::TTaskManagerPtr& spTaskManager) : m_spTaskManager(spTaskManager) @@ -32,12 +34,8 @@ chcore::TTaskPtr TTaskManagerWrapper::CreateTask(chcore::TTaskDefinition& rTaskDefinition) { - ictranslate::CResourceManager& rResourceManager = ictranslate::CResourceManager::Acquire(); + UpdateFileNamingFormat(rTaskDefinition.GetConfiguration()); - // load resource strings - chcore::SetTaskPropValue(rTaskDefinition.GetConfiguration(), rResourceManager.LoadString(IDS_FIRSTCOPY_STRING)); - chcore::SetTaskPropValue(rTaskDefinition.GetConfiguration(), rResourceManager.LoadString(IDS_NEXTCOPY_STRING)); - CString strMessage; try { @@ -62,7 +60,7 @@ strMessage = e.what(); } - + ictranslate::CResourceManager& rResourceManager = ictranslate::CResourceManager::Acquire(); ictranslate::CFormat fmt; fmt.SetFormat(rResourceManager.LoadString(IDS_TASK_CREATE_FAILED)); @@ -71,3 +69,26 @@ return nullptr; } + +void TTaskManagerWrapper::UpdateFileNamingFormat(chcore::TConfig& rTaskConfig) +{ + ictranslate::CResourceManager& rResourceManager = ictranslate::CResourceManager::Acquire(); + + CString strFirstCopyFormat; + CString strSubsequentCopyFormat; + bool bUseCustomNaming = GetPropValue(GetConfig()); + if(bUseCustomNaming) + { + strFirstCopyFormat = GetPropValue(GetConfig()); + strSubsequentCopyFormat = GetPropValue(GetConfig()); + } + else + { + strFirstCopyFormat = rResourceManager.LoadString(IDS_FIRSTCOPY_STRING); + strSubsequentCopyFormat = rResourceManager.LoadString(IDS_NEXTCOPY_STRING); + } + + // load resource strings + chcore::SetTaskPropValue(rTaskConfig, (PCTSTR)strFirstCopyFormat); + chcore::SetTaskPropValue(rTaskConfig, (PCTSTR)strSubsequentCopyFormat); +} Index: src/ch/TTaskManagerWrapper.h =================================================================== diff -u -N -r25129f39720523eca2cb702242890a7862f70ec6 -rd18db617f4727a237c94b59af9b4328f829eda16 --- src/ch/TTaskManagerWrapper.h (.../TTaskManagerWrapper.h) (revision 25129f39720523eca2cb702242890a7862f70ec6) +++ src/ch/TTaskManagerWrapper.h (.../TTaskManagerWrapper.h) (revision d18db617f4727a237c94b59af9b4328f829eda16) @@ -29,6 +29,9 @@ chcore::TTaskPtr CreateTask(chcore::TTaskDefinition& rTaskDefinition); private: + void UpdateFileNamingFormat(chcore::TConfig& rTaskConfig); + +private: chcore::TTaskManagerPtr m_spTaskManager; }; Index: src/ch/ch.rc =================================================================== diff -u -N -r25129f39720523eca2cb702242890a7862f70ec6 -rd18db617f4727a237c94b59af9b4328f829eda16 --- src/ch/ch.rc (.../ch.rc) (revision 25129f39720523eca2cb702242890a7862f70ec6) +++ src/ch/ch.rc (.../ch.rc) (revision d18db617f4727a237c94b59af9b4328f829eda16) @@ -853,6 +853,9 @@ IDS_SECURE_CONNECTION_TYPES "No!Yes!Auto" IDS_BUFFER_QUEUE_DEPTH "Buffer queue depth" IDS_FASTMOVEBEFOREBLOCK_STRING "Use fast move before blocking" + IDS_USECUSTOMNAMING "Use custom naming" + IDS_CUSTOMNAME_FIRST "Name format for first copy (use %name)" + IDS_CUSTOMNAME_SUBSEQUENT "Name format for the subsequent copies (use %name, %count)" END STRINGTABLE @@ -973,8 +976,8 @@ STRINGTABLE BEGIN - IDS_FIRSTCOPY_STRING "Copy of %name" - IDS_NEXTCOPY_STRING "Copy (%count) of %name" + IDS_FIRSTCOPY_STRING "%name - copy" + IDS_NEXTCOPY_STRING "%name - copy (%count)" IDS_NOTFOUND_STRING "File not found (doesn't exist)" IDS_BYTE_STRING "B" IDS_KBYTE_STRING "kB" Index: src/ch/langs/polish.lng =================================================================== diff -u -N -rd037fe7234987387e26b0be460be37a956fcb27d -rd18db617f4727a237c94b59af9b4328f829eda16 Binary files differ Index: src/ch/resource.h =================================================================== diff -u -N -r25129f39720523eca2cb702242890a7862f70ec6 -rd18db617f4727a237c94b59af9b4328f829eda16 --- src/ch/resource.h (.../resource.h) (revision 25129f39720523eca2cb702242890a7862f70ec6) +++ src/ch/resource.h (.../resource.h) (revision d18db617f4727a237c94b59af9b4328f829eda16) @@ -529,6 +529,9 @@ #define IDS_FASTMOVEBEFOREBLOCK_STRING 8103 #define IDS_CFG_USE_SECURE_CONNECTION 8104 #define IDS_SECURE_CONNECTION_TYPES 8105 +#define IDS_USECUSTOMNAMING 8106 +#define IDS_CUSTOMNAME_FIRST 8107 +#define IDS_CUSTOMNAME_SUBSEQUENT 8108 #define IDS_MENUCOPY_STRING 9000 #define IDS_MENUMOVE_STRING 9001 #define IDS_MENUCOPYMOVESPECIAL_STRING 9002 Index: src/libchcore/TBufferSizes.cpp =================================================================== diff -u -N -re8f31b0f922b402878356e130c866c4f3682a7f5 -rd18db617f4727a237c94b59af9b4328f829eda16 --- src/libchcore/TBufferSizes.cpp (.../TBufferSizes.cpp) (revision e8f31b0f922b402878356e130c866c4f3682a7f5) +++ src/libchcore/TBufferSizes.cpp (.../TBufferSizes.cpp) (revision d18db617f4727a237c94b59af9b4328f829eda16) @@ -100,32 +100,32 @@ } } - void chcore::TBufferSizes::SetDefaultSize(UINT uiSize) + void TBufferSizes::SetDefaultSize(UINT uiSize) { m_uiDefaultSize = std::max(BufferGranularity, RoundUp(uiSize, BufferGranularity)); } - void chcore::TBufferSizes::SetOneDiskSize(UINT uiSize) + void TBufferSizes::SetOneDiskSize(UINT uiSize) { m_uiOneDiskSize = std::max(BufferGranularity, RoundUp(uiSize, BufferGranularity)); } - void chcore::TBufferSizes::SetTwoDisksSize(UINT uiSize) + void TBufferSizes::SetTwoDisksSize(UINT uiSize) { m_uiTwoDisksSize = std::max(BufferGranularity, RoundUp(uiSize, BufferGranularity)); } - void chcore::TBufferSizes::SetCDSize(UINT uiSize) + void TBufferSizes::SetCDSize(UINT uiSize) { m_uiCDSize = std::max(BufferGranularity, RoundUp(uiSize, BufferGranularity)); } - void chcore::TBufferSizes::SetLANSize(UINT uiSize) + void TBufferSizes::SetLANSize(UINT uiSize) { m_uiLANSize = std::max(BufferGranularity, RoundUp(uiSize, BufferGranularity)); } - void chcore::TBufferSizes::SetBufferCount(UINT uiBufferCount) + void TBufferSizes::SetBufferCount(UINT uiBufferCount) { m_uiBufferCount = std::max(uiBufferCount, MinBufferCount); } Index: src/libchcore/TCoreStdException.h =================================================================== diff -u -N -ra27d1acf1bda3c25b6dcce0d0eb0278009ce63ae -rd18db617f4727a237c94b59af9b4328f829eda16 --- src/libchcore/TCoreStdException.h (.../TCoreStdException.h) (revision a27d1acf1bda3c25b6dcce0d0eb0278009ce63ae) +++ src/libchcore/TCoreStdException.h (.../TCoreStdException.h) (revision d18db617f4727a237c94b59af9b4328f829eda16) @@ -23,7 +23,7 @@ #include "TCoreException.h" #define THROW_CORE_EXCEPTION_STD(error_code, std_exception)\ - throw chcore::TCoreStdException(error_code, std_exception, __FILEW__, __LINE__, __FUNCTIONW__) + throw TCoreStdException(error_code, std_exception, __FILEW__, __LINE__, __FUNCTIONW__) namespace chcore { Index: src/libchcore/TFeedbackHandlerBase.cpp =================================================================== diff -u -N -r8592d6dcef30c8e4967ca4dcee37c1ca52afbf16 -rd18db617f4727a237c94b59af9b4328f829eda16 --- src/libchcore/TFeedbackHandlerBase.cpp (.../TFeedbackHandlerBase.cpp) (revision 8592d6dcef30c8e4967ca4dcee37c1ca52afbf16) +++ src/libchcore/TFeedbackHandlerBase.cpp (.../TFeedbackHandlerBase.cpp) (revision d18db617f4727a237c94b59af9b4328f829eda16) @@ -43,7 +43,7 @@ m_eFileError = ePermanentResult; } - chcore::EFeedbackResult TFeedbackHandlerBase::GetFileErrorPermanentResponse() const + EFeedbackResult TFeedbackHandlerBase::GetFileErrorPermanentResponse() const { boost::shared_lock lock(m_lock); return m_eFileError; @@ -81,7 +81,7 @@ m_eNotEnoughSpace = ePermanentResult; } - chcore::EFeedbackResult TFeedbackHandlerBase::GetNotEnoughSpacePermanentResponse() const + EFeedbackResult TFeedbackHandlerBase::GetNotEnoughSpacePermanentResponse() const { boost::shared_lock lock(m_lock); return m_eNotEnoughSpace; Index: src/libchcore/TFilesystemFeedbackWrapper.cpp =================================================================== diff -u -N -ra6fac511b0dd40e1c18cab086e0bc5ff5d2bc8d7 -rd18db617f4727a237c94b59af9b4328f829eda16 --- src/libchcore/TFilesystemFeedbackWrapper.cpp (.../TFilesystemFeedbackWrapper.cpp) (revision a6fac511b0dd40e1c18cab086e0bc5ff5d2bc8d7) +++ src/libchcore/TFilesystemFeedbackWrapper.cpp (.../TFilesystemFeedbackWrapper.cpp) (revision d18db617f4727a237c94b59af9b4328f829eda16) @@ -26,7 +26,7 @@ namespace chcore { - TFilesystemFeedbackWrapper::TFilesystemFeedbackWrapper(const IFeedbackHandlerPtr& spFeedbackHandler, const IFilesystemPtr& spFilesystem, chcore::log_file& rLog, TWorkerThreadController& rThreadController) : + TFilesystemFeedbackWrapper::TFilesystemFeedbackWrapper(const IFeedbackHandlerPtr& spFeedbackHandler, const IFilesystemPtr& spFilesystem, log_file& rLog, TWorkerThreadController& rThreadController) : m_spFeedbackHandler(spFeedbackHandler), m_spFilesystem(spFilesystem), m_rLog(rLog), Index: src/libchcore/TFilesystemFileFeedbackWrapper.cpp =================================================================== diff -u -N -r4fe995b304ea342b50293f92d3c1992b43b820f7 -rd18db617f4727a237c94b59af9b4328f829eda16 --- src/libchcore/TFilesystemFileFeedbackWrapper.cpp (.../TFilesystemFileFeedbackWrapper.cpp) (revision 4fe995b304ea342b50293f92d3c1992b43b820f7) +++ src/libchcore/TFilesystemFileFeedbackWrapper.cpp (.../TFilesystemFileFeedbackWrapper.cpp) (revision d18db617f4727a237c94b59af9b4328f829eda16) @@ -27,7 +27,7 @@ namespace chcore { - TFilesystemFileFeedbackWrapper::TFilesystemFileFeedbackWrapper(const IFeedbackHandlerPtr& spFeedbackHandler, chcore::log_file& rLog, TWorkerThreadController& rThreadController, const IFilesystemPtr& spFilesystem) : + TFilesystemFileFeedbackWrapper::TFilesystemFileFeedbackWrapper(const IFeedbackHandlerPtr& spFeedbackHandler, log_file& rLog, TWorkerThreadController& rThreadController, const IFilesystemPtr& spFilesystem) : m_spFeedbackHandler(spFeedbackHandler), m_rLog(rLog), m_rThreadController(rThreadController), Index: src/libchcore/TStringPattern.cpp =================================================================== diff -u -N -rfcf6698a5e67445b1a68627fa94837b1ad97284e -rd18db617f4727a237c94b59af9b4328f829eda16 --- src/libchcore/TStringPattern.cpp (.../TStringPattern.cpp) (revision fcf6698a5e67445b1a68627fa94837b1ad97284e) +++ src/libchcore/TStringPattern.cpp (.../TStringPattern.cpp) (revision d18db617f4727a237c94b59af9b4328f829eda16) @@ -45,7 +45,7 @@ m_strPattern = strPattern; } - chcore::TString TStringPattern::ToString() const + TString TStringPattern::ToString() const { TString strPrefix; switch (m_ePatternType) Index: src/libchcore/TSubTaskContext.cpp =================================================================== diff -u -N -r4fe995b304ea342b50293f92d3c1992b43b820f7 -rd18db617f4727a237c94b59af9b4328f829eda16 --- src/libchcore/TSubTaskContext.cpp (.../TSubTaskContext.cpp) (revision 4fe995b304ea342b50293f92d3c1992b43b820f7) +++ src/libchcore/TSubTaskContext.cpp (.../TSubTaskContext.cpp) (revision d18db617f4727a237c94b59af9b4328f829eda16) @@ -31,7 +31,7 @@ { TSubTaskContext::TSubTaskContext(TConfig& rConfig, const TBasePathDataContainerPtr& spBasePaths, const TFileFiltersArray& rFilters, - TTaskConfigTracker& rCfgTracker, chcore::log_file& rLog, + TTaskConfigTracker& rCfgTracker, log_file& rLog, TWorkerThreadController& rThreadController, const IFilesystemPtr& spFilesystem) : m_rConfig(rConfig), m_eOperationType(eOperation_None), @@ -106,12 +106,12 @@ return m_rCfgTracker; } - chcore::log_file& TSubTaskContext::GetLog() + log_file& TSubTaskContext::GetLog() { return m_rLog; } - const chcore::log_file& TSubTaskContext::GetLog() const + const log_file& TSubTaskContext::GetLog() const { return m_rLog; } Index: src/libchcore/TSubTaskContext.h =================================================================== diff -u -N -r4fe995b304ea342b50293f92d3c1992b43b820f7 -rd18db617f4727a237c94b59af9b4328f829eda16 --- src/libchcore/TSubTaskContext.h (.../TSubTaskContext.h) (revision 4fe995b304ea342b50293f92d3c1992b43b820f7) +++ src/libchcore/TSubTaskContext.h (.../TSubTaskContext.h) (revision d18db617f4727a237c94b59af9b4328f829eda16) @@ -46,7 +46,7 @@ public: TSubTaskContext(TConfig& rConfig, const TBasePathDataContainerPtr& spBasePaths, const TFileFiltersArray& rFilters, - TTaskConfigTracker& rCfgTracker, chcore::log_file& rLog, + TTaskConfigTracker& rCfgTracker, log_file& rLog, TWorkerThreadController& rThreadController, const IFilesystemPtr& spFilesystem); ~TSubTaskContext(); @@ -68,8 +68,8 @@ TTaskConfigTracker& GetCfgTracker(); const TTaskConfigTracker& GetCfgTracker() const; - chcore::log_file& GetLog(); - const chcore::log_file& GetLog() const; + log_file& GetLog(); + const log_file& GetLog() const; TWorkerThreadController& GetThreadController(); const TWorkerThreadController& GetThreadController() const; @@ -108,7 +108,7 @@ #pragma warning(pop) // additional data - chcore::log_file& m_rLog; + log_file& m_rLog; // thread control TWorkerThreadController& m_rThreadController; Index: src/libchcore/TSubTaskCopyMove.cpp =================================================================== diff -u -N -r4fe995b304ea342b50293f92d3c1992b43b820f7 -rd18db617f4727a237c94b59af9b4328f829eda16 --- src/libchcore/TSubTaskCopyMove.cpp (.../TSubTaskCopyMove.cpp) (revision 4fe995b304ea342b50293f92d3c1992b43b820f7) +++ src/libchcore/TSubTaskCopyMove.cpp (.../TSubTaskCopyMove.cpp) (revision d18db617f4727a237c94b59af9b4328f829eda16) @@ -101,7 +101,7 @@ TScopedRunningTimeTracker guard(m_tSubTaskStats); TFeedbackHandlerWrapperPtr spFeedbackHandler(std::make_shared(spFeedback, guard)); - chcore::log_file& rLog = GetContext().GetLog(); + log_file& rLog = GetContext().GetLog(); TFileInfoArray& rFilesCache = GetContext().GetFilesCache(); TTaskConfigTracker& rCfgTracker = GetContext().GetCfgTracker(); TWorkerThreadController& rThreadController = GetContext().GetThreadController(); @@ -334,7 +334,7 @@ TSubTaskBase::ESubOperationResult TSubTaskCopyMove::CustomCopyFileFB(const IFeedbackHandlerPtr& spFeedbackHandler, CUSTOM_COPY_PARAMS* pData) { TWorkerThreadController& rThreadController = GetContext().GetThreadController(); - chcore::log_file& rLog = GetContext().GetLog(); + log_file& rLog = GetContext().GetLog(); const TConfig& rConfig = GetContext().GetConfig(); IFilesystemPtr spFilesystem = GetContext().GetLocalFilesystem(); @@ -792,7 +792,7 @@ { const TConfig& rConfig = GetContext().GetConfig(); TTaskConfigTracker& rCfgTracker = GetContext().GetCfgTracker(); - chcore::log_file& rLog = GetContext().GetLog(); + log_file& rLog = GetContext().GetLog(); if(bForce || (rCfgTracker.IsModified() && rCfgTracker.IsModified(TOptionsSet() % eTO_DefaultBufferSize % eTO_OneDiskBufferSize % eTO_TwoDisksBufferSize % eTO_CDBufferSize % eTO_LANBufferSize % eTO_UseOnlyDefaultBuffer % eTO_BufferQueueDepth, true))) { @@ -824,7 +824,7 @@ const TSmartPath& pathFile, bool& bSkip) { - chcore::log_file& rLog = GetContext().GetLog(); + log_file& rLog = GetContext().GetLog(); DWORD dwLastError = rBuffer.GetErrorCode(); bSkip = false; @@ -863,7 +863,7 @@ const TSmartPath& pathFile, bool& bSkip) { - chcore::log_file& rLog = GetContext().GetLog(); + log_file& rLog = GetContext().GetLog(); DWORD dwLastError = rBuffer.GetErrorCode(); bSkip = false; Index: src/libchcore/TSubTaskDelete.cpp =================================================================== diff -u -N -r4fe995b304ea342b50293f92d3c1992b43b820f7 -rd18db617f4727a237c94b59af9b4328f829eda16 --- src/libchcore/TSubTaskDelete.cpp (.../TSubTaskDelete.cpp) (revision 4fe995b304ea342b50293f92d3c1992b43b820f7) +++ src/libchcore/TSubTaskDelete.cpp (.../TSubTaskDelete.cpp) (revision d18db617f4727a237c94b59af9b4328f829eda16) @@ -81,7 +81,7 @@ TFeedbackHandlerWrapperPtr spFeedbackHandler(std::make_shared(spFeedback, guard)); // log - chcore::log_file& rLog = GetContext().GetLog(); + log_file& rLog = GetContext().GetLog(); TFileInfoArray& rFilesCache = GetContext().GetFilesCache(); TWorkerThreadController& rThreadController = GetContext().GetThreadController(); IFilesystemPtr spFilesystem = GetContext().GetLocalFilesystem(); Index: src/libchcore/TSubTaskFastMove.cpp =================================================================== diff -u -N -r4fe995b304ea342b50293f92d3c1992b43b820f7 -rd18db617f4727a237c94b59af9b4328f829eda16 --- src/libchcore/TSubTaskFastMove.cpp (.../TSubTaskFastMove.cpp) (revision 4fe995b304ea342b50293f92d3c1992b43b820f7) +++ src/libchcore/TSubTaskFastMove.cpp (.../TSubTaskFastMove.cpp) (revision d18db617f4727a237c94b59af9b4328f829eda16) @@ -84,7 +84,7 @@ TFeedbackHandlerWrapperPtr spFeedbackHandler(std::make_shared(spFeedback, guard)); // log - chcore::log_file& rLog = GetContext().GetLog(); + log_file& rLog = GetContext().GetLog(); TWorkerThreadController& rThreadController = GetContext().GetThreadController(); TBasePathDataContainerPtr spBasePaths = GetContext().GetBasePaths(); const TConfig& rConfig = GetContext().GetConfig(); Index: src/libchcore/TSubTaskScanDirectory.cpp =================================================================== diff -u -N -r4fe995b304ea342b50293f92d3c1992b43b820f7 -rd18db617f4727a237c94b59af9b4328f829eda16 --- src/libchcore/TSubTaskScanDirectory.cpp (.../TSubTaskScanDirectory.cpp) (revision 4fe995b304ea342b50293f92d3c1992b43b820f7) +++ src/libchcore/TSubTaskScanDirectory.cpp (.../TSubTaskScanDirectory.cpp) (revision d18db617f4727a237c94b59af9b4328f829eda16) @@ -85,7 +85,7 @@ TFeedbackHandlerWrapperPtr spFeedbackHandler(std::make_shared(spFeedback, guard)); // log - chcore::log_file& rLog = GetContext().GetLog(); + log_file& rLog = GetContext().GetLog(); TFileInfoArray& rFilesCache = GetContext().GetFilesCache(); TWorkerThreadController& rThreadController = GetContext().GetThreadController(); TBasePathDataContainerPtr spBasePaths = GetContext().GetBasePaths(); Index: src/libchcore/TTask.cpp =================================================================== diff -u -N -r4fe995b304ea342b50293f92d3c1992b43b820f7 -rd18db617f4727a237c94b59af9b4328f829eda16 --- src/libchcore/TTask.cpp (.../TTask.cpp) (revision 4fe995b304ea342b50293f92d3c1992b43b820f7) +++ src/libchcore/TTask.cpp (.../TTask.cpp) (revision d18db617f4727a237c94b59af9b4328f829eda16) @@ -41,6 +41,7 @@ #include "log.h" #include #include "TLocalFilesystem.h" +#include "TTaskConfigVerifier.h" namespace chcore { @@ -535,7 +536,7 @@ TSubTaskBase::ESubOperationResult eResult = TSubTaskBase::eSubResult_Continue; // initialize log file - m_log.init(m_tBaseData.GetLogPath().ToString(), 262144, chcore::log_file::level_debug, false, false); + m_log.init(m_tBaseData.GetLogPath().ToString(), 262144, log_file::level_debug, false, false); // start operation OnBeginOperation(); @@ -544,6 +545,9 @@ m_tConfiguration.ConnectToNotifier(TTaskConfigTracker::NotificationProc, &m_cfgTracker); m_tConfiguration.ConnectToNotifier(TTask::OnCfgOptionChanged, this); + // verify configuration is valid + TTaskConfigVerifier::VerifyAndUpdate(m_tConfiguration, &m_log); + // set thread options HANDLE hThread = GetCurrentThread(); ::SetThreadPriorityBoost(hThread, GetTaskPropValue(m_tConfiguration)); @@ -723,10 +727,10 @@ return m_spSerializer; } - chcore::log_file& TTask::GetLog() + log_file& TTask::GetLog() { if (!m_log.is_initialized()) - m_log.init(m_tBaseData.GetLogPath().ToString(), 262144, chcore::log_file::level_debug, false, false); + m_log.init(m_tBaseData.GetLogPath().ToString(), 262144, log_file::level_debug, false, false); return m_log; } Index: src/libchcore/TTask.h =================================================================== diff -u -N -r4fe995b304ea342b50293f92d3c1992b43b820f7 -rd18db617f4727a237c94b59af9b4328f829eda16 --- src/libchcore/TTask.h (.../TTask.h) (revision 4fe995b304ea342b50293f92d3c1992b43b820f7) +++ src/libchcore/TTask.h (.../TTask.h) (revision d18db617f4727a237c94b59af9b4328f829eda16) @@ -88,7 +88,7 @@ void SetTaskDefinition(const TTaskDefinition& rTaskDefinition); void SetLogPath(const TSmartPath& pathLog); - chcore::log_file& GetLog(); + log_file& GetLog(); // 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 TTaskManager object @@ -162,7 +162,7 @@ bool m_bContinue; // allows task to continue // other helpers - chcore::log_file m_log; ///< Log file where task information will be stored + log_file m_log; ///< Log file where task information will be stored /// Thread controlling object TWorkerThreadController m_workerThread; Index: src/libchcore/TTaskConfigVerifier.cpp =================================================================== diff -u -N --- src/libchcore/TTaskConfigVerifier.cpp (revision 0) +++ src/libchcore/TTaskConfigVerifier.cpp (revision d18db617f4727a237c94b59af9b4328f829eda16) @@ -0,0 +1,59 @@ +// ============================================================================ +// Copyright (C) 2001-2016 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. +// ============================================================================ +#include "stdafx.h" +#include "TTaskConfigVerifier.h" +#include "TTaskConfiguration.h" +#include "log.h" +#include + +namespace chcore +{ + void TTaskConfigVerifier::VerifyAndUpdate(TConfig& rConfig, log_file* pLog) + { + TString strFirstFormat = GetTaskPropValue(rConfig); + if(strFirstFormat.Find(L"%name") == TString::npos) + { + TString strDefaultFormat = TaskPropData::GetDefaultValue(); + if(pLog) + { + pLog->logw( + boost::str(boost::wformat(L"First alternate filename format string (%1%) does not contain %%name placeholder. Switching to default (%2%).") + % strFirstFormat.c_str() + % strDefaultFormat.c_str()).c_str()); + } + + SetTaskPropValue(rConfig, strDefaultFormat); + } + + TString strSubsequentFormat = GetTaskPropValue(rConfig); + if(strSubsequentFormat.Find(L"%name") == TString::npos || strSubsequentFormat.Find(L"%count") == TString::npos) + { + TString strDefaultFormat = TaskPropData::GetDefaultValue(); + if(pLog) + { + pLog->logw( + boost::str(boost::wformat(L"Subsequent alternate filename format string (%1%) does not contain %%name or %%count placeholder. Switching to default (%2%).") + % strSubsequentFormat.c_str() + % strDefaultFormat.c_str()).c_str()); + } + + SetTaskPropValue(rConfig, strDefaultFormat); + } + } +} Index: src/libchcore/TTaskConfigVerifier.h =================================================================== diff -u -N --- src/libchcore/TTaskConfigVerifier.h (revision 0) +++ src/libchcore/TTaskConfigVerifier.h (revision d18db617f4727a237c94b59af9b4328f829eda16) @@ -0,0 +1,34 @@ +// ============================================================================ +// Copyright (C) 2001-2016 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. +// ============================================================================ +#ifndef __TTASKCONFIGVERIFIER_H__ +#define __TTASKCONFIGVERIFIER_H__ + +namespace chcore +{ + class log_file; + class TConfig; + + class TTaskConfigVerifier + { + public: + static void VerifyAndUpdate(TConfig& rConfig, log_file* pLog); + }; +} + +#endif Index: src/libchcore/TTaskConfiguration.h =================================================================== diff -u -N -r4fe995b304ea342b50293f92d3c1992b43b820f7 -rd18db617f4727a237c94b59af9b4328f829eda16 --- src/libchcore/TTaskConfiguration.h (.../TTaskConfiguration.h) (revision 4fe995b304ea342b50293f92d3c1992b43b820f7) +++ src/libchcore/TTaskConfiguration.h (.../TTaskConfiguration.h) (revision d18db617f4727a237c94b59af9b4328f829eda16) @@ -138,8 +138,8 @@ TASK_PROPERTY(eTO_IgnoreDirectories, bool, _T("Operation.IgnoreDirectories"), false); // Naming settings - TASK_PROPERTY(eTO_AlternateFilenameFormatString_First, TString, _T("Naming.AlternateFilenameFormatFirst"), _T("Copy of %name")); - TASK_PROPERTY(eTO_AlternateFilenameFormatString_AfterFirst, TString, _T("Naming.AlternateFilenameFormatAfterFirst"), _T("Copy (%count) of %name")); + TASK_PROPERTY(eTO_AlternateFilenameFormatString_First, TString, _T("Naming.AlternateFilenameFormatFirst"), _T("%name - copy")); + TASK_PROPERTY(eTO_AlternateFilenameFormatString_AfterFirst, TString, _T("Naming.AlternateFilenameFormatAfterFirst"), _T("%name - copy (%count)")); ///////////////////////////////////////////////////////////////////////////////////////////// // other properties names Index: src/libchcore/Tests/TestsTSQLiteDatabase.cpp =================================================================== diff -u -N -rd32a79f0e9220bad2c6eeb5e8a986228b6e832fb -rd18db617f4727a237c94b59af9b4328f829eda16 --- src/libchcore/Tests/TestsTSQLiteDatabase.cpp (.../TestsTSQLiteDatabase.cpp) (revision d32a79f0e9220bad2c6eeb5e8a986228b6e832fb) +++ src/libchcore/Tests/TestsTSQLiteDatabase.cpp (.../TestsTSQLiteDatabase.cpp) (revision d18db617f4727a237c94b59af9b4328f829eda16) @@ -4,7 +4,7 @@ #include "../TSQLiteDatabase.h" using namespace chcore; -using namespace chcore::sqlite; +using namespace sqlite; TEST(SQLiteDatabase, CreationWithVerification) { Index: src/libchcore/Tests/TestsTSQLiteStatement.cpp =================================================================== diff -u -N -r2408cac34e827fa43ff1622f65251e219f96a4f1 -rd18db617f4727a237c94b59af9b4328f829eda16 --- src/libchcore/Tests/TestsTSQLiteStatement.cpp (.../TestsTSQLiteStatement.cpp) (revision 2408cac34e827fa43ff1622f65251e219f96a4f1) +++ src/libchcore/Tests/TestsTSQLiteStatement.cpp (.../TestsTSQLiteStatement.cpp) (revision d18db617f4727a237c94b59af9b4328f829eda16) @@ -6,7 +6,7 @@ #include "../TSQLiteException.h" using namespace chcore; -using namespace chcore::sqlite; +using namespace sqlite; TEST(SQLiteStatement, CorrectPrepare) { Index: src/libchcore/Tests/TestsTSQLiteTransaction.cpp =================================================================== diff -u -N -rd32a79f0e9220bad2c6eeb5e8a986228b6e832fb -rd18db617f4727a237c94b59af9b4328f829eda16 --- src/libchcore/Tests/TestsTSQLiteTransaction.cpp (.../TestsTSQLiteTransaction.cpp) (revision d32a79f0e9220bad2c6eeb5e8a986228b6e832fb) +++ src/libchcore/Tests/TestsTSQLiteTransaction.cpp (.../TestsTSQLiteTransaction.cpp) (revision d18db617f4727a237c94b59af9b4328f829eda16) @@ -7,7 +7,7 @@ #include "../TSQLiteException.h" using namespace chcore; -using namespace chcore::sqlite; +using namespace sqlite; TEST(SQLiteTransaction, BeginTransactionWithDefaultRollback_Empty) { Index: src/libchcore/Tests/TestsTTaskConfigVerifier.cpp =================================================================== diff -u -N --- src/libchcore/Tests/TestsTTaskConfigVerifier.cpp (revision 0) +++ src/libchcore/Tests/TestsTTaskConfigVerifier.cpp (revision d18db617f4727a237c94b59af9b4328f829eda16) @@ -0,0 +1,80 @@ +#include "stdafx.h" +#include "gtest/gtest.h" +#include "../TConfig.h" +#include "../log.h" +#include "../TTaskConfiguration.h" +#include "../TTaskConfigVerifier.h" + +using namespace chcore; + +TEST(TestsTTaskConfigVerifier, VerifyAndUpdate_FirstAlternateFilenameFormat_Valid) +{ + TConfig config; + + SetTaskPropValue(config, L"First copy of %name"); + + TTaskConfigVerifier::VerifyAndUpdate(config, nullptr); + + TString strValue = GetTaskPropValue(config); + + EXPECT_STREQ(L"First copy of %name", strValue.c_str()); + +} + +TEST(TestsTTaskConfigVerifier, VerifyAndUpdate_FirstAlternateFilenameFormat_Invalid) +{ + TConfig config; + + SetTaskPropValue(config, L"First copy of %nme"); + + TTaskConfigVerifier::VerifyAndUpdate(config, nullptr); + + TString strValue = GetTaskPropValue(config); + + EXPECT_STREQ(L"%name - copy", strValue.c_str()); + +} + +TEST(TestsTTaskConfigVerifier, VerifyAndUpdate_NextAlternateFilenameFormat_Valid) +{ + log_file log; + TConfig config; + + SetTaskPropValue(config, L"Subsequent copy of %name (%count)"); + + TTaskConfigVerifier::VerifyAndUpdate(config, nullptr); + + TString strValue = GetTaskPropValue(config); + + EXPECT_STREQ(L"Subsequent copy of %name (%count)", strValue.c_str()); + +} + +TEST(TestsTTaskConfigVerifier, VerifyAndUpdate_NextAlternateFilenameFormat_InvalidCount) +{ + log_file log; + TConfig config; + + SetTaskPropValue(config, L"Subsequent copy of %name (%cout)"); + + TTaskConfigVerifier::VerifyAndUpdate(config, nullptr); + + TString strValue = GetTaskPropValue(config); + + EXPECT_STREQ(L"%name - copy (%count)", strValue.c_str()); + +} + +TEST(TestsTTaskConfigVerifier, VerifyAndUpdate_NextAlternateFilenameFormat_InvalidName) +{ + log_file log; + TConfig config; + + SetTaskPropValue(config, L"Subsequent copy of %ame (%count)"); + + TTaskConfigVerifier::VerifyAndUpdate(config, nullptr); + + TString strValue = GetTaskPropValue(config); + + EXPECT_STREQ(L"%name - copy (%count)", strValue.c_str()); +} Index: src/libchcore/libchcore.vc140.vcxproj =================================================================== diff -u -N -r4fe995b304ea342b50293f92d3c1992b43b820f7 -rd18db617f4727a237c94b59af9b4328f829eda16 --- src/libchcore/libchcore.vc140.vcxproj (.../libchcore.vc140.vcxproj) (revision 4fe995b304ea342b50293f92d3c1992b43b820f7) +++ src/libchcore/libchcore.vc140.vcxproj (.../libchcore.vc140.vcxproj) (revision d18db617f4727a237c94b59af9b4328f829eda16) @@ -541,6 +541,7 @@ + @@ -710,6 +711,12 @@ true true + + true + true + true + true + true true @@ -774,6 +781,7 @@ + Index: src/libchcore/libchcore.vc140.vcxproj.filters =================================================================== diff -u -N -r4fe995b304ea342b50293f92d3c1992b43b820f7 -rd18db617f4727a237c94b59af9b4328f829eda16 --- src/libchcore/libchcore.vc140.vcxproj.filters (.../libchcore.vc140.vcxproj.filters) (revision 4fe995b304ea342b50293f92d3c1992b43b820f7) +++ src/libchcore/libchcore.vc140.vcxproj.filters (.../libchcore.vc140.vcxproj.filters) (revision d18db617f4727a237c94b59af9b4328f829eda16) @@ -81,6 +81,9 @@ {4a321c2c-525d-4a77-bad6-d01210bba74c} + + {953a12ea-2aa5-4c7a-a310-a461ce8b962f} + @@ -458,6 +461,9 @@ Source Files\SubTasks + + Source Files\Task Config + @@ -838,5 +844,11 @@ Tests + + Source Files\Task Config + + + Tests\TaskConfig + \ No newline at end of file Index: src/libchcore/log.cpp =================================================================== diff -u -N -r5598fd0318a9e148ff2c2eb83a6f6c4af251e798 -rd18db617f4727a237c94b59af9b4328f829eda16 --- src/libchcore/log.cpp (.../log.cpp) (revision 5598fd0318a9e148ff2c2eb83a6f6c4af251e798) +++ src/libchcore/log.cpp (.../log.cpp) (revision d18db617f4727a237c94b59af9b4328f829eda16) @@ -88,7 +88,7 @@ } // ============================================================================ - /// chcore::log_file::is_initialized + /// log_file::is_initialized /// @date 2009/05/19 /// /// @brief Checks is the log_file object has been initialized. @@ -100,7 +100,7 @@ } // ============================================================================ - /// chcore::log_file::set_log_level + /// log_file::set_log_level /// @date 2009/05/23 /// /// @brief Changes the log level for this class. @@ -112,7 +112,7 @@ } // ============================================================================ - /// chcore::log_file::set_max_size + /// log_file::set_max_size /// @date 2009/05/23 /// /// @brief Sets the max size of the log file.