Index: src/libchengine/TDestinationPathProvider.cpp =================================================================== diff -u -N -rb9453afbc6264bc3f3c6a7f86fadab7744e0fb16 -re9f05a628a169c449e335bd95ea418a4451ba04c --- src/libchengine/TDestinationPathProvider.cpp (.../TDestinationPathProvider.cpp) (revision b9453afbc6264bc3f3c6a7f86fadab7744e0fb16) +++ src/libchengine/TDestinationPathProvider.cpp (.../TDestinationPathProvider.cpp) (revision e9f05a628a169c449e335bd95ea418a4451ba04c) @@ -32,55 +32,23 @@ if(!spFileInfo) throw TCoreException(eErr_InvalidArgument, L"spFileInfo", LOCATION); + TSmartPath plannedDestinationPath; if (m_bForceDirectories) - return CalculateForceDirectories(spFileInfo); + plannedDestinationPath = CalculateForceDirectories(spFileInfo); + else if (m_bIgnoreFolders) + plannedDestinationPath = CalculateIgnoreDirectories(spFileInfo); + else + plannedDestinationPath = CalculateNormalDestination(spFileInfo); - if (m_bIgnoreFolders) - return CalculateIgnoreDirectories(spFileInfo); - - TBasePathDataPtr spPathData = spFileInfo->GetBasePathData(); - if(!spPathData) - return m_pathDestinationBase + spFileInfo->GetFilePath(); - - // generate new dest name - if(!spPathData->IsDestinationPathSet()) - { - // generate something - if dest folder == src folder - search for copy - if(m_pathDestinationBase == spFileInfo->GetFullFilePath().GetFileRoot()) - { - TSmartPath pathSubst = FindFreeSubstituteName(spFileInfo->GetFullFilePath()); - spPathData->SetDestinationPath(pathSubst); - } - else - { - TSmartPath pathFilename = spPathData->GetSrcPath(); - pathFilename.StripSeparatorAtEnd(); - pathFilename.StripPath(L":"); - - spPathData->SetDestinationPath(pathFilename.GetFileName()); - } - } - + // adjust the calculated path with different filename if set previously by renaming TSmartPath pathDstReplacement = spFileInfo->GetDstRelativePath(); - - TSmartPath pathResult = m_pathDestinationBase + spPathData->GetDestinationPath(); - if(pathDstReplacement.IsEmpty()) - pathResult += spFileInfo->GetFilePath(); - else + if(!pathDstReplacement.IsEmpty()) { - if(spFileInfo->GetFilePath().IsEmpty()) - { - pathResult.DeleteFileName(); - pathResult += pathDstReplacement; - } - else - pathResult += pathDstReplacement; - + plannedDestinationPath.DeleteFileName(); + plannedDestinationPath += pathDstReplacement; } - pathResult.StripSeparatorAtEnd(); - - return pathResult; + return plannedDestinationPath; } chcore::TSmartPath TDestinationPathProvider::CalculateSuggestedDestinationPath(chcore::TSmartPath pathDst) const @@ -146,6 +114,39 @@ return pathResult; } + chcore::TSmartPath TDestinationPathProvider::CalculateNormalDestination(const TFileInfoPtr& spFileInfo) const + { + TBasePathDataPtr spPathData = spFileInfo->GetBasePathData(); + if(!spPathData) + throw TCoreException(eErr_InvalidArgument, L"FileInfo object does not contain base path data", LOCATION); + + TSmartPath plannedDestinationPath; + + // generate new top-level dest name for base path + if(!spPathData->IsDestinationPathSet()) + { + // generate something - if dest folder == src folder - search for copy + if(m_pathDestinationBase == spFileInfo->GetFullFilePath().GetFileRoot()) + { + TSmartPath pathSubst = FindFreeSubstituteName(spFileInfo->GetFullFilePath()); + spPathData->SetDestinationPath(pathSubst); + } + else + { + TSmartPath pathFilename = spPathData->GetSrcPath(); + pathFilename.StripSeparatorAtEnd(); + pathFilename.StripPath(L":"); + + spPathData->SetDestinationPath(pathFilename.GetFileName()); + } + } + + + TSmartPath pathResult = m_pathDestinationBase + spPathData->GetDestinationPath() + spFileInfo->GetFilePath(); + pathResult.StripSeparatorAtEnd(); + return pathResult; + } + // finds another name for a copy of src file(folder) in dest location; works only for paths that ends up directly in m_pathDestinationBase (without sub-directories) TSmartPath TDestinationPathProvider::FindFreeSubstituteName(TSmartPath pathSrcPath) const { Index: src/libchengine/TDestinationPathProvider.h =================================================================== diff -u -N -rb9453afbc6264bc3f3c6a7f86fadab7744e0fb16 -re9f05a628a169c449e335bd95ea418a4451ba04c --- src/libchengine/TDestinationPathProvider.h (.../TDestinationPathProvider.h) (revision b9453afbc6264bc3f3c6a7f86fadab7744e0fb16) +++ src/libchengine/TDestinationPathProvider.h (.../TDestinationPathProvider.h) (revision e9f05a628a169c449e335bd95ea418a4451ba04c) @@ -37,6 +37,7 @@ private: chcore::TSmartPath CalculateForceDirectories(const TFileInfoPtr& spFileInfo) const; chcore::TSmartPath CalculateIgnoreDirectories(const TFileInfoPtr& spFileInfo) const; + chcore::TSmartPath CalculateNormalDestination(const TFileInfoPtr& spFileInfo) const; chcore::TSmartPath FindFreeSubstituteName(chcore::TSmartPath pathSrcPath) const; private: