Index: src/libchcore/TSubTaskFastMove.cpp
===================================================================
diff -u -N -r9ebcc7abf1e0e70f0db2d08b2691351a26ef259b -re96806b7f8ff7ca7e9f4afbea603e6351a3dc3e3
--- src/libchcore/TSubTaskFastMove.cpp	(.../TSubTaskFastMove.cpp)	(revision 9ebcc7abf1e0e70f0db2d08b2691351a26ef259b)
+++ src/libchcore/TSubTaskFastMove.cpp	(.../TSubTaskFastMove.cpp)	(revision e96806b7f8ff7ca7e9f4afbea603e6351a3dc3e3)
@@ -40,232 +40,229 @@
 #include "TFeedbackHandlerWrapper.h"
 #include "TBufferSizes.h"
 
-BEGIN_CHCORE_NAMESPACE
-
-TSubTaskFastMove::TSubTaskFastMove(TSubTaskContext& rContext) :
-	TSubTaskBase(rContext),
-	m_tSubTaskStats(eSubOperation_FastMove)
+namespace chcore
 {
-}
+	TSubTaskFastMove::TSubTaskFastMove(TSubTaskContext& rContext) :
+		TSubTaskBase(rContext),
+		m_tSubTaskStats(eSubOperation_FastMove)
+	{
+	}
 
-TSubTaskFastMove::~TSubTaskFastMove()
-{
-}
+	TSubTaskFastMove::~TSubTaskFastMove()
+	{
+	}
 
-void TSubTaskFastMove::Reset()
-{
-	m_tSubTaskStats.Clear();
-}
+	void TSubTaskFastMove::Reset()
+	{
+		m_tSubTaskStats.Clear();
+	}
 
-TSubTaskFastMove::ESubOperationResult TSubTaskFastMove::Exec(const IFeedbackHandlerPtr& spFeedback)
-{
-	TScopedRunningTimeTracker guard(m_tSubTaskStats);
-	TFeedbackHandlerWrapperPtr spFeedbackHandler(boost::make_shared<TFeedbackHandlerWrapper>(spFeedback, guard));
+	TSubTaskFastMove::ESubOperationResult TSubTaskFastMove::Exec(const IFeedbackHandlerPtr& spFeedback)
+	{
+		TScopedRunningTimeTracker guard(m_tSubTaskStats);
+		TFeedbackHandlerWrapperPtr spFeedbackHandler(boost::make_shared<TFeedbackHandlerWrapper>(spFeedback, guard));
 
-	// log
-	icpf::log_file& rLog = GetContext().GetLog();
-	TWorkerThreadController& rThreadController = GetContext().GetThreadController();
-	TBasePathDataContainerPtr spBasePaths = GetContext().GetBasePaths();
-	const TConfig& rConfig = GetContext().GetConfig();
-	TSmartPath pathDestination = GetContext().GetDestinationPath();
-	const TFileFiltersArray& rafFilters = GetContext().GetFilters();
-	IFilesystemPtr spFilesystem = GetContext().GetLocalFilesystem();
+		// log
+		icpf::log_file& rLog = GetContext().GetLog();
+		TWorkerThreadController& rThreadController = GetContext().GetThreadController();
+		TBasePathDataContainerPtr spBasePaths = GetContext().GetBasePaths();
+		const TConfig& rConfig = GetContext().GetConfig();
+		TSmartPath pathDestination = GetContext().GetDestinationPath();
+		const TFileFiltersArray& rafFilters = GetContext().GetFilters();
+		IFilesystemPtr spFilesystem = GetContext().GetLocalFilesystem();
 
-	rLog.logi(_T("Performing initial fast-move operation..."));
+		rLog.logi(_T("Performing initial fast-move operation..."));
 
-	// new stats
-	m_tSubTaskStats.SetCurrentBufferIndex(TBufferSizes::eBuffer_Default);
-	m_tSubTaskStats.SetTotalCount(spBasePaths->GetCount());
-	m_tSubTaskStats.SetProcessedCount(0);
-	m_tSubTaskStats.SetTotalSize(0);
-	m_tSubTaskStats.SetProcessedSize(0);
-	m_tSubTaskStats.SetCurrentPath(TString());
+		// new stats
+		m_tSubTaskStats.SetCurrentBufferIndex(TBufferSizes::eBuffer_Default);
+		m_tSubTaskStats.SetTotalCount(spBasePaths->GetCount());
+		m_tSubTaskStats.SetProcessedCount(0);
+		m_tSubTaskStats.SetTotalSize(0);
+		m_tSubTaskStats.SetProcessedSize(0);
+		m_tSubTaskStats.SetCurrentPath(TString());
 
-	bool bIgnoreDirs = GetTaskPropValue<eTO_IgnoreDirectories>(rConfig);
-	bool bForceDirectories = GetTaskPropValue<eTO_CreateDirectoriesRelativeToRoot>(rConfig);
+		bool bIgnoreDirs = GetTaskPropValue<eTO_IgnoreDirectories>(rConfig);
+		bool bForceDirectories = GetTaskPropValue<eTO_CreateDirectoriesRelativeToRoot>(rConfig);
 
-	// when using special options with move operation, we don't want to use fast-moving, since most probably
-	// some searching and special processing needs to be done
-	if(bIgnoreDirs || bForceDirectories)
-		return eSubResult_Continue;
+		// when using special options with move operation, we don't want to use fast-moving, since most probably
+		// some searching and special processing needs to be done
+		if (bIgnoreDirs || bForceDirectories)
+			return eSubResult_Continue;
 
-	// add everything
-	TString strFormat;
-	bool bRetry = true;
-	bool bSkipInputPath = false;
+		// add everything
+		TString strFormat;
+		bool bRetry = true;
+		bool bSkipInputPath = false;
 
-	file_count_t fcSize = spBasePaths->GetCount();
-	file_count_t fcIndex = m_tSubTaskStats.GetCurrentIndex();
-	for(; fcIndex < fcSize ; fcIndex++)
-	{
-		TBasePathDataPtr spBasePath = spBasePaths->GetAt(fcIndex);
-		TSmartPath pathCurrent = spBasePath->GetSrcPath();
+		file_count_t fcSize = spBasePaths->GetCount();
+		file_count_t fcIndex = m_tSubTaskStats.GetCurrentIndex();
+		for (; fcIndex < fcSize; fcIndex++)
+		{
+			TBasePathDataPtr spBasePath = spBasePaths->GetAt(fcIndex);
+			TSmartPath pathCurrent = spBasePath->GetSrcPath();
 
-		// store currently processed index
-		m_tSubTaskStats.SetCurrentIndex(fcIndex);
+			// store currently processed index
+			m_tSubTaskStats.SetCurrentIndex(fcIndex);
 
-		// new stats
-		m_tSubTaskStats.SetProcessedCount(fcIndex);
-		m_tSubTaskStats.SetCurrentPath(pathCurrent.ToString());
+			// new stats
+			m_tSubTaskStats.SetProcessedCount(fcIndex);
+			m_tSubTaskStats.SetCurrentPath(pathCurrent.ToString());
 
-		// retrieve base path data
-		// check if we want to process this path at all
-		if(spBasePath->GetSkipFurtherProcessing())
-			continue;
+			// retrieve base path data
+			// check if we want to process this path at all
+			if (spBasePath->GetSkipFurtherProcessing())
+				continue;
 
-		TFileInfoPtr spFileInfo(boost::make_shared<TFileInfo>());
-		bSkipInputPath = false;
-		// try to get some info about the input path; let user know if the path does not exist.
-		do
-		{
-			bRetry = false;
-
-			// read attributes of src file/folder
-			bool bExists = spFilesystem->GetFileInfo(pathCurrent, spFileInfo, spBasePath);
-			if(!bExists)
+			TFileInfoPtr spFileInfo(boost::make_shared<TFileInfo>());
+			bSkipInputPath = false;
+			// try to get some info about the input path; let user know if the path does not exist.
+			do
 			{
-				EFeedbackResult frResult = spFeedbackHandler->FileError(pathCurrent.ToWString(), TString(), EFileError::eFastMoveError, ERROR_FILE_NOT_FOUND);
-				switch(frResult)
+				bRetry = false;
+
+				// read attributes of src file/folder
+				bool bExists = spFilesystem->GetFileInfo(pathCurrent, spFileInfo, spBasePath);
+				if (!bExists)
 				{
-				case EFeedbackResult::eResult_Cancel:
-					return eSubResult_CancelRequest;
+					EFeedbackResult frResult = spFeedbackHandler->FileError(pathCurrent.ToWString(), TString(), EFileError::eFastMoveError, ERROR_FILE_NOT_FOUND);
+					switch (frResult)
+					{
+					case EFeedbackResult::eResult_Cancel:
+						return eSubResult_CancelRequest;
 
-				case EFeedbackResult::eResult_Retry:
-					bRetry = true;
-					break;
+					case EFeedbackResult::eResult_Retry:
+						bRetry = true;
+						break;
 
-				case EFeedbackResult::eResult_Pause:
-					return eSubResult_PauseRequest;
+					case EFeedbackResult::eResult_Pause:
+						return eSubResult_PauseRequest;
 
-				case EFeedbackResult::eResult_Skip:
-					bSkipInputPath = true;
-					break;		// just do nothing
+					case EFeedbackResult::eResult_Skip:
+						bSkipInputPath = true;
+						break;		// just do nothing
 
-				default:
-					BOOST_ASSERT(FALSE);		// unknown result
-					THROW_CORE_EXCEPTION(eErr_UnhandledCase);
+					default:
+						BOOST_ASSERT(FALSE);		// unknown result
+						THROW_CORE_EXCEPTION(eErr_UnhandledCase);
+					}
 				}
-			}
-		}
-		while(bRetry);
+			} while (bRetry);
 
-		// if we have chosen to skip the input path then there's nothing to do
-		if(bSkipInputPath)
-			continue;
+			// if we have chosen to skip the input path then there's nothing to do
+			if (bSkipInputPath)
+				continue;
 
-		// does it match the input filter?
-		if(!spFileInfo->IsDirectory() && !rafFilters.Match(spFileInfo))
-		{
-			spBasePath->SetSkipFurtherProcessing(true);
-			continue;
-		}
-
-		// try to fast move
-		bRetry = true;
-		bool bResult = true;
-		do
-		{
-			TSmartPath pathDestinationPath = CalculateDestinationPath(spFileInfo, pathDestination, 0);
-			TSmartPath pathSrc = spBasePath->GetSrcPath();
-			bResult = spFilesystem->FastMove(pathSrc, pathDestinationPath);
-			if(!bResult)
+			// does it match the input filter?
+			if (!spFileInfo->IsDirectory() && !rafFilters.Match(spFileInfo))
 			{
-				DWORD dwLastError = GetLastError();
+				spBasePath->SetSkipFurtherProcessing(true);
+				continue;
+			}
 
-				// check if this is one of the errors, that will just cause fast move to skip
-				if(dwLastError == ERROR_ACCESS_DENIED || dwLastError == ERROR_ALREADY_EXISTS)
+			// try to fast move
+			bRetry = true;
+			bool bResult = true;
+			do
+			{
+				TSmartPath pathDestinationPath = CalculateDestinationPath(spFileInfo, pathDestination, 0);
+				TSmartPath pathSrc = spBasePath->GetSrcPath();
+				bResult = spFilesystem->FastMove(pathSrc, pathDestinationPath);
+				if (!bResult)
 				{
-					bRetry = false;
-					bResult = true;
-				}
-				else
-				{
-					//log
-					strFormat = _T("Error %errno while calling fast move %srcpath -> %dstpath (TSubTaskFastMove)");
-					strFormat.Replace(_T("%errno"), boost::lexical_cast<std::wstring>(dwLastError).c_str());
-					strFormat.Replace(_T("%srcpath"), spFileInfo->GetFullFilePath().ToString());
-					strFormat.Replace(_T("%dstpath"), pathDestination.ToString());
-					rLog.loge(strFormat.c_str());
+					DWORD dwLastError = GetLastError();
 
-					EFeedbackResult frResult = spFeedbackHandler->FileError(pathSrc.ToWString(), pathDestinationPath.ToWString(), EFileError::eFastMoveError, dwLastError);
-					switch(frResult)
+					// check if this is one of the errors, that will just cause fast move to skip
+					if (dwLastError == ERROR_ACCESS_DENIED || dwLastError == ERROR_ALREADY_EXISTS)
 					{
-					case EFeedbackResult::eResult_Cancel:
-						return TSubTaskBase::eSubResult_CancelRequest;
+						bRetry = false;
+						bResult = true;
+					}
+					else
+					{
+						//log
+						strFormat = _T("Error %errno while calling fast move %srcpath -> %dstpath (TSubTaskFastMove)");
+						strFormat.Replace(_T("%errno"), boost::lexical_cast<std::wstring>(dwLastError).c_str());
+						strFormat.Replace(_T("%srcpath"), spFileInfo->GetFullFilePath().ToString());
+						strFormat.Replace(_T("%dstpath"), pathDestination.ToString());
+						rLog.loge(strFormat.c_str());
 
-					case EFeedbackResult::eResult_Retry:
-						continue;
+						EFeedbackResult frResult = spFeedbackHandler->FileError(pathSrc.ToWString(), pathDestinationPath.ToWString(), EFileError::eFastMoveError, dwLastError);
+						switch (frResult)
+						{
+						case EFeedbackResult::eResult_Cancel:
+							return TSubTaskBase::eSubResult_CancelRequest;
 
-					case EFeedbackResult::eResult_Pause:
-						return TSubTaskBase::eSubResult_PauseRequest;
+						case EFeedbackResult::eResult_Retry:
+							continue;
 
-					case EFeedbackResult::eResult_Skip:
-						//bSkipInputPath = true;		// not needed, since we will break the loop anyway and there is no other processing for this path either
-						bRetry = false;
-						break;		// just do nothing
+						case EFeedbackResult::eResult_Pause:
+							return TSubTaskBase::eSubResult_PauseRequest;
 
-					default:
-						BOOST_ASSERT(FALSE);		// unknown result
-						THROW_CORE_EXCEPTION(eErr_UnhandledCase);
+						case EFeedbackResult::eResult_Skip:
+							//bSkipInputPath = true;		// not needed, since we will break the loop anyway and there is no other processing for this path either
+							bRetry = false;
+							break;		// just do nothing
+
+						default:
+							BOOST_ASSERT(FALSE);		// unknown result
+							THROW_CORE_EXCEPTION(eErr_UnhandledCase);
+						}
 					}
 				}
+				else
+					spBasePath->SetSkipFurtherProcessing(true);		// mark that this path should not be processed any further
+			} while (!bResult && bRetry);
+
+			// check for kill need
+			if (rThreadController.KillRequested())
+			{
+				// log
+				rLog.logi(_T("Kill request while adding data to files array (RecurseDirectories)"));
+				return eSubResult_KillRequest;
 			}
-			else
-				spBasePath->SetSkipFurtherProcessing(true);		// mark that this path should not be processed any further
 		}
-		while(!bResult && bRetry);
 
-		// check for kill need
-		if(rThreadController.KillRequested())
-		{
-			// log
-			rLog.logi(_T("Kill request while adding data to files array (RecurseDirectories)"));
-			return eSubResult_KillRequest;
-		}
-	}
+		m_tSubTaskStats.SetCurrentIndex(fcIndex);
+		m_tSubTaskStats.SetProcessedCount(fcIndex);
+		m_tSubTaskStats.SetCurrentPath(TString());
 
-	m_tSubTaskStats.SetCurrentIndex(fcIndex);
-	m_tSubTaskStats.SetProcessedCount(fcIndex);
-	m_tSubTaskStats.SetCurrentPath(TString());
+		// log
+		rLog.logi(_T("Fast moving finished"));
 
-	// log
-	rLog.logi(_T("Fast moving finished"));
+		return eSubResult_Continue;
+	}
 
-	return eSubResult_Continue;
-}
+	void TSubTaskFastMove::GetStatsSnapshot(TSubTaskStatsSnapshotPtr& spStats) const
+	{
+		m_tSubTaskStats.GetSnapshot(spStats);
+	}
 
-void TSubTaskFastMove::GetStatsSnapshot(TSubTaskStatsSnapshotPtr& spStats) const
-{
-	m_tSubTaskStats.GetSnapshot(spStats);
-}
+	void TSubTaskFastMove::Store(const ISerializerPtr& spSerializer) const
+	{
+		ISerializerContainerPtr spContainer = spSerializer->GetContainer(_T("subtask_fastmove"));
 
-void TSubTaskFastMove::Store(const ISerializerPtr& spSerializer) const
-{
-	ISerializerContainerPtr spContainer = spSerializer->GetContainer(_T("subtask_fastmove"));
+		InitColumns(spContainer);
 
-	InitColumns(spContainer);
+		ISerializerRowData& rRow = spContainer->GetRow(0, m_tSubTaskStats.WasAdded());
 
-	ISerializerRowData& rRow = spContainer->GetRow(0, m_tSubTaskStats.WasAdded());
+		m_tSubTaskStats.Store(rRow);
+	}
 
-	m_tSubTaskStats.Store(rRow);
-}
+	void TSubTaskFastMove::Load(const ISerializerPtr& spSerializer)
+	{
+		ISerializerContainerPtr spContainer = spSerializer->GetContainer(_T("subtask_fastmove"));
 
-void TSubTaskFastMove::Load(const ISerializerPtr& spSerializer)
-{
-	ISerializerContainerPtr spContainer = spSerializer->GetContainer(_T("subtask_fastmove"));
+		InitColumns(spContainer);
 
-	InitColumns(spContainer);
+		ISerializerRowReaderPtr spRowReader = spContainer->GetRowReader();
+		if (spRowReader->Next())
+			m_tSubTaskStats.Load(spRowReader);
+	}
 
-	ISerializerRowReaderPtr spRowReader = spContainer->GetRowReader();
-	if(spRowReader->Next())
-		m_tSubTaskStats.Load(spRowReader);
+	void TSubTaskFastMove::InitColumns(const ISerializerContainerPtr& spContainer) const
+	{
+		IColumnsDefinition& rColumns = spContainer->GetColumnsDefinition();
+		if (rColumns.IsEmpty())
+			TSubTaskStatsInfo::InitColumns(rColumns);
+	}
 }
-
-void TSubTaskFastMove::InitColumns(const ISerializerContainerPtr& spContainer) const
-{
-	IColumnsDefinition& rColumns = spContainer->GetColumnsDefinition();
-	if(rColumns.IsEmpty())
-		TSubTaskStatsInfo::InitColumns(rColumns);
-}
-
-END_CHCORE_NAMESPACE