Index: src/libchcore/TBasePathData.cpp =================================================================== diff -u -r293e52b38d46653068006262172018a0f0d0a31c -ra7834ba278464cb62739f22d35f9bc16269706a1 --- src/libchcore/TBasePathData.cpp (.../TBasePathData.cpp) (revision 293e52b38d46653068006262172018a0f0d0a31c) +++ src/libchcore/TBasePathData.cpp (.../TBasePathData.cpp) (revision a7834ba278464cb62739f22d35f9bc16269706a1) @@ -28,26 +28,41 @@ #include "ErrorCodes.h" #include "TRowData.h" #include "ISerializerRowData.h" +#include +#include "TPathContainer.h" BEGIN_CHCORE_NAMESPACE ////////////////////////////////////////////////////////////////////////////// // TBasePathData TBasePathData::TBasePathData() : + m_stObjectID(0), + m_pathSrc(m_setModifications), m_bSkipFurtherProcessing(m_setModifications, false), m_pathDst(m_setModifications) { m_setModifications[eMod_Added] = true; } TBasePathData::TBasePathData(const TBasePathData& rEntry) : + m_stObjectID(rEntry.m_stObjectID), + m_pathSrc(rEntry.m_pathSrc), m_pathDst(rEntry.m_pathDst), m_bSkipFurtherProcessing(rEntry.m_bSkipFurtherProcessing), m_setModifications(rEntry.m_setModifications) { } +TBasePathData::TBasePathData(size_t stObjectID, const TSmartPath& spSrcPath) : + m_stObjectID(stObjectID), + m_pathSrc(m_setModifications, spSrcPath), + m_bSkipFurtherProcessing(m_setModifications, false), + m_pathDst(m_setModifications) +{ + m_setModifications[eMod_Added] = true; +} + void TBasePathData::SetDestinationPath(const TSmartPath& tPath) { m_pathDst = tPath; @@ -73,22 +88,26 @@ return !m_pathDst.Get().IsEmpty(); } -void TBasePathData::Store(const ISerializerContainerPtr& spContainer, size_t stObjectID) const +void TBasePathData::Store(const ISerializerContainerPtr& spContainer) const { if(!spContainer) THROW_CORE_EXCEPTION(eErr_InvalidPointer); ISerializerRowDataPtr spRow; - bool bAdded = m_setModifications.at(eMod_Added); + bool bAdded = m_setModifications[eMod_Added]; if(bAdded) - spRow = spContainer->AddRow(stObjectID); + spRow = spContainer->AddRow(m_stObjectID); else if(m_setModifications.any()) - spRow = spContainer->GetRow(stObjectID); + spRow = spContainer->GetRow(m_stObjectID); + else + return; - if(bAdded || m_setModifications.at(eMod_SkipProcessing)) + if(bAdded || m_setModifications[eMod_SrcPath]) + *spRow % TRowData(_T("src_path"), m_pathSrc); + if(bAdded || m_setModifications[eMod_SkipProcessing]) *spRow % TRowData(_T("skip_processing"), m_bSkipFurtherProcessing); - if(bAdded || m_setModifications.at(eMod_DstPath)) + if(bAdded || m_setModifications[eMod_DstPath]) *spRow % TRowData(_T("dst_path"), m_pathDst); m_setModifications.reset(); @@ -99,21 +118,43 @@ if(!spColumnDefs) THROW_CORE_EXCEPTION(eErr_InvalidPointer); - *spColumnDefs % _T("id") % _T("skip_processing") % _T("dst_path"); + *spColumnDefs % _T("id") % _T("src_path") % _T("skip_processing") % _T("dst_path"); } -void TBasePathData::Load(const ISerializerRowReaderPtr& spRowReader, size_t& stObjectID) +void TBasePathData::Load(const ISerializerRowReaderPtr& spRowReader) { - spRowReader->GetValue(_T("id"), stObjectID); + spRowReader->GetValue(_T("id"), m_stObjectID); + spRowReader->GetValue(_T("src_path"), m_pathSrc.Modify()); spRowReader->GetValue(_T("skip_processing"), m_bSkipFurtherProcessing.Modify()); spRowReader->GetValue(_T("dst_path"), m_pathDst.Modify()); m_setModifications.reset(); } +TSmartPath TBasePathData::GetSrcPath() const +{ + return m_pathSrc; +} + +void TBasePathData::SetSrcPath(const TSmartPath& pathSrc) +{ + m_pathSrc = pathSrc; +} + +size_t TBasePathData::GetObjectID() const +{ + return m_stObjectID; +} + +void TBasePathData::SetObjectID(size_t stObjectID) +{ + m_stObjectID = stObjectID; +} + ////////////////////////////////////////////////////////////////////////////// // TBasePathDataContainer -TBasePathDataContainer::TBasePathDataContainer() +TBasePathDataContainer::TBasePathDataContainer() : + m_stLastObjectID(0) { } @@ -123,130 +164,110 @@ Clear(); } -bool TBasePathDataContainer::Exists(size_t stObjectID) const +void TBasePathDataContainer::Store(const ISerializerContainerPtr& spContainer) const { + if(!spContainer) + THROW_CORE_EXCEPTION(eErr_InvalidPointer); + boost::shared_lock lock(m_lock); - bool bResult = m_mapEntries.find(stObjectID) != m_mapEntries.end(); - return bResult; + spContainer->DeleteRows(m_setRemovedObjects); + m_setRemovedObjects.Clear(); + + BOOST_FOREACH(const TBasePathDataPtr& spEntry, m_vEntries) + { + spEntry->Store(spContainer); + } } -TBasePathDataPtr TBasePathDataContainer::GetExisting(size_t stObjectID) const +void TBasePathDataContainer::Load(const ISerializerContainerPtr& spContainer) { - boost::shared_lock lock(m_lock); - - MapEntries::const_iterator iter = m_mapEntries.find(stObjectID); - if(iter == m_mapEntries.end()) - THROW_CORE_EXCEPTION(eErr_BoundsExceeded); + if(!spContainer) + THROW_CORE_EXCEPTION(eErr_InvalidPointer); - return iter->second; -} + boost::unique_lock lock(m_lock); + m_setRemovedObjects.Clear(); + m_vEntries.clear(); -chcore::TBasePathDataPtr TBasePathDataContainer::Get(size_t stObjectID) -{ - boost::upgrade_lock lock(m_lock); + ISerializerRowReaderPtr spRowReader = spContainer->GetRowReader(); + IColumnsDefinitionPtr spColumns = spRowReader->GetColumnsDefinitions(); + if(spColumns->IsEmpty()) + TBasePathData::InitLoader(spRowReader->GetColumnsDefinitions()); - MapEntries::iterator iter = m_mapEntries.find(stObjectID); - if(iter == m_mapEntries.end()) + while(spRowReader->Next()) { - boost::upgrade_to_unique_lock upgraded_lock(lock); - iter = m_mapEntries.insert(std::make_pair(stObjectID, TBasePathDataPtr(new TBasePathData))).first; - } + TBasePathDataPtr spPathData(new TBasePathData); - return iter->second; + spPathData->Load(spRowReader); + + m_vEntries.push_back(spPathData); + } } -void TBasePathDataContainer::Remove(size_t stObjectID) +void TBasePathDataContainer::Add(const TBasePathDataPtr& spEntry) { boost::unique_lock lock(m_lock); - m_mapEntries.erase(stObjectID); - m_setRemovedObjects.Add(stObjectID); + spEntry->SetObjectID(++m_stLastObjectID); + m_vEntries.push_back(spEntry); } -void TBasePathDataContainer::Clear() +void TBasePathDataContainer::RemoveAt(size_t stIndex) { boost::unique_lock lock(m_lock); - - BOOST_FOREACH(const MapEntries::value_type& rItem, m_mapEntries) - { - m_setRemovedObjects.Add(rItem.first); - } + if(stIndex >= m_vEntries.size()) + THROW_CORE_EXCEPTION(eErr_BoundsExceeded); - m_mapEntries.clear(); + m_setRemovedObjects.Add(m_vEntries[stIndex]->GetObjectID()); + m_vEntries.erase(m_vEntries.begin() + stIndex); } -bool TBasePathDataContainer::GetSkipFurtherProcessing(size_t stObjectID) const +chcore::TBasePathDataPtr TBasePathDataContainer::GetAt(size_t stIndex) const { boost::shared_lock lock(m_lock); - - MapEntries::const_iterator iter = m_mapEntries.find(stObjectID); - if(iter == m_mapEntries.end()) - return false; - - return iter->second->GetSkipFurtherProcessing(); + return m_vEntries.at(stIndex); } -chcore::TSmartPath TBasePathDataContainer::GetDestinationPath(size_t stObjectID) const +void TBasePathDataContainer::ClearNL() { - boost::shared_lock lock(m_lock); + BOOST_FOREACH(const TBasePathDataPtr& spItem, m_vEntries) + { + m_setRemovedObjects.Add(spItem->GetObjectID()); + } - MapEntries::const_iterator iter = m_mapEntries.find(stObjectID); - if(iter == m_mapEntries.end()) - return TSmartPath(); + m_vEntries.clear(); +} - return iter->second->GetDestinationPath(); +void TBasePathDataContainer::Clear() +{ + boost::unique_lock lock(m_lock); + ClearNL(); } -bool TBasePathDataContainer::IsDestinationPathSet(size_t stObjectID) const +bool TBasePathDataContainer::IsEmpty() const { boost::shared_lock lock(m_lock); - MapEntries::const_iterator iter = m_mapEntries.find(stObjectID); - if(iter == m_mapEntries.end()) - return false; - - return iter->second->IsDestinationPathSet(); + return m_vEntries.empty(); } -void TBasePathDataContainer::Store(const ISerializerContainerPtr& spContainer) const +size_t TBasePathDataContainer::GetCount() const { - if(!spContainer) - THROW_CORE_EXCEPTION(eErr_InvalidPointer); - boost::shared_lock lock(m_lock); - - spContainer->DeleteRows(m_setRemovedObjects); - m_setRemovedObjects.Clear(); - - BOOST_FOREACH(const MapEntries::value_type& rPair, m_mapEntries) - { - rPair.second->Store(spContainer, rPair.first); - } + return m_vEntries.size(); } -void TBasePathDataContainer::Load(const ISerializerContainerPtr& spContainer) +TBasePathDataContainer& TBasePathDataContainer::operator=(const TPathContainer& tPaths) { - if(!spContainer) - THROW_CORE_EXCEPTION(eErr_InvalidPointer); - boost::unique_lock lock(m_lock); - m_setRemovedObjects.Clear(); - m_mapEntries.clear(); + ClearNL(); - ISerializerRowReaderPtr spRowReader = spContainer->GetRowReader(); - IColumnsDefinitionPtr spColumns = spRowReader->GetColumnsDefinitions(); - if(spColumns->IsEmpty()) - TBasePathData::InitLoader(spRowReader->GetColumnsDefinitions()); - - while(spRowReader->Next()) + for(size_t stIndex = 0; stIndex < tPaths.GetCount(); ++stIndex) { - TBasePathDataPtr spPathData(new TBasePathData); - size_t stObjectID = 0; - - spPathData->Load(spRowReader, stObjectID); - - m_mapEntries.insert(std::make_pair(stObjectID, spPathData)); + TBasePathDataPtr spPathData = boost::make_shared(++m_stLastObjectID, tPaths.GetAt(stIndex)); + m_vEntries.push_back(spPathData); } + + return *this; } END_CHCORE_NAMESPACE Index: src/libchcore/TBasePathData.h =================================================================== diff -u -r293e52b38d46653068006262172018a0f0d0a31c -ra7834ba278464cb62739f22d35f9bc16269706a1 --- src/libchcore/TBasePathData.h (.../TBasePathData.h) (revision 293e52b38d46653068006262172018a0f0d0a31c) +++ src/libchcore/TBasePathData.h (.../TBasePathData.h) (revision a7834ba278464cb62739f22d35f9bc16269706a1) @@ -32,6 +32,8 @@ BEGIN_CHCORE_NAMESPACE +class TPathContainer; + ///////////////////////////////////////////////////////////////////////////// // TBasePathData class LIBCHCORE_API TBasePathData @@ -40,6 +42,7 @@ enum EModifications { eMod_Added, + eMod_SrcPath, eMod_SkipProcessing, eMod_DstPath, @@ -48,25 +51,36 @@ public: TBasePathData(); + TBasePathData(size_t stObjectID, const TSmartPath& spSrcPath); TBasePathData(const TBasePathData& rEntry); + size_t GetObjectID() const; + void SetObjectID(size_t stObjectID); + + TSmartPath GetSrcPath() const; + void SetSrcPath(const TSmartPath& pathSrc); + bool GetSkipFurtherProcessing() const; void SetSkipFurtherProcessing(bool bSkipFurtherProcessing); void SetDestinationPath(const TSmartPath& strPath); TSmartPath GetDestinationPath() const; bool IsDestinationPathSet() const; - void Store(const ISerializerContainerPtr& spContainer, size_t stObjectID) const; + void Store(const ISerializerContainerPtr& spContainer) const; static void InitLoader(const IColumnsDefinitionPtr& spColumnDefs); - void Load(const ISerializerRowReaderPtr& spRowReader, size_t& stObjectID); + void Load(const ISerializerRowReaderPtr& spRowReader); private: #pragma warning(push) #pragma warning(disable: 4251) + // modification management typedef std::bitset BitSet; mutable BitSet m_setModifications; + // attributes + size_t m_stObjectID; + TSharedModificationTracker m_pathSrc; TSharedModificationTracker m_bSkipFurtherProcessing; // specifies if the path should be (or not) processed further TSharedModificationTracker m_pathDst; #pragma warning(pop) @@ -84,18 +98,16 @@ TBasePathDataContainer(); ~TBasePathDataContainer(); - // standard access to data - bool Exists(size_t stObjectID) const; - TBasePathDataPtr GetExisting(size_t stObjectID) const; - TBasePathDataPtr Get(size_t stObjectID); + TBasePathDataContainer& operator=(const TPathContainer& tPaths); - void Remove(size_t stObjectID); + // standard access to data + void Add(const TBasePathDataPtr& spEntry); + void RemoveAt(size_t stIndex); + TBasePathDataPtr GetAt(size_t stIndex) const; void Clear(); - // inner object read interface (to not create new inner objects when reading non-existent data) - bool GetSkipFurtherProcessing(size_t stObjectID) const; - TSmartPath GetDestinationPath(size_t stObjectID) const; - bool IsDestinationPathSet(size_t stObjectID) const; + bool IsEmpty() const; + size_t GetCount() const; void Store(const ISerializerContainerPtr& spContainer) const; void Load(const ISerializerContainerPtr& spContainer); @@ -104,17 +116,22 @@ TBasePathDataContainer(const TBasePathDataContainer& rSrc); TBasePathDataContainer& operator=(const TBasePathDataContainer& rSrc); + void ClearNL(); + protected: #pragma warning(push) #pragma warning(disable: 4251) - typedef std::map MapEntries; - MapEntries m_mapEntries; + typedef std::vector VecEntries; + VecEntries m_vEntries; mutable TRemovedObjects m_setRemovedObjects; mutable boost::shared_mutex m_lock; #pragma warning(pop) + size_t m_stLastObjectID; }; +typedef boost::shared_ptr TBasePathDataContainerPtr; + END_CHCORE_NAMESPACE #endif // __TBASEPATHDATA_H__ Index: src/libchcore/TFileInfo.cpp =================================================================== diff -u -r2efd22688b8d12be34c87bf2b024d8db6e317d60 -ra7834ba278464cb62739f22d35f9bc16269706a1 --- src/libchcore/TFileInfo.cpp (.../TFileInfo.cpp) (revision 2efd22688b8d12be34c87bf2b024d8db6e317d60) +++ src/libchcore/TFileInfo.cpp (.../TFileInfo.cpp) (revision a7834ba278464cb62739f22d35f9bc16269706a1) @@ -33,9 +33,7 @@ ////////////////////////////////////////////////////////////////////// TFileInfo::TFileInfo() : - m_pBasePaths(NULL), m_pathFile(), - m_stSrcIndex(std::numeric_limits::max()), m_dwAttributes(0), m_uhFileSize(0), m_uiFlags(0) @@ -45,47 +43,44 @@ m_ftLastWrite.dwHighDateTime = m_ftLastWrite.dwLowDateTime = 0; } -TFileInfo::TFileInfo(const TFileInfo& finf) : - m_pathFile(finf.m_pathFile), - m_stSrcIndex(finf.m_stSrcIndex), - m_dwAttributes(finf.m_dwAttributes), - m_uhFileSize(finf.m_uhFileSize), - m_ftCreation(finf.m_ftCreation), - m_ftLastAccess(finf.m_ftLastAccess), - m_ftLastWrite(finf.m_ftLastWrite), - m_uiFlags(finf.m_uiFlags), - m_pBasePaths(finf.m_pBasePaths) +TFileInfo::TFileInfo(const TFileInfo& rSrc) : + m_pathFile(rSrc.m_pathFile), + m_spBasePathData(rSrc.m_spBasePathData), + m_dwAttributes(rSrc.m_dwAttributes), + m_uhFileSize(rSrc.m_uhFileSize), + m_ftCreation(rSrc.m_ftCreation), + m_ftLastAccess(rSrc.m_ftLastAccess), + m_ftLastWrite(rSrc.m_ftLastWrite), + m_uiFlags(rSrc.m_uiFlags) { } TFileInfo::~TFileInfo() { } -void TFileInfo::Init(const TSmartPath& rpathFile, size_t stSrcIndex, const TModPathContainer* pBasePaths, - DWORD dwAttributes, ULONGLONG uhFileSize, FILETIME ftCreation, FILETIME ftLastAccess, FILETIME ftLastWrite, - uint_t uiFlags) +void TFileInfo::Init(const TBasePathDataPtr& spBasePathData, const TSmartPath& rpathFile, + DWORD dwAttributes, ULONGLONG uhFileSize, FILETIME ftCreation, FILETIME ftLastAccess, FILETIME ftLastWrite, + uint_t uiFlags) { m_pathFile = rpathFile; - m_stSrcIndex = stSrcIndex; - m_pBasePaths = pBasePaths; + m_spBasePathData = spBasePathData; m_dwAttributes = dwAttributes; m_uhFileSize = uhFileSize; m_ftCreation = ftCreation; m_ftLastAccess = ftLastAccess; m_ftLastWrite = ftLastWrite; m_uiFlags = uiFlags; - if(m_pBasePaths && m_stSrcIndex != std::numeric_limits::max()) - m_pathFile.MakeRelativePath(m_pBasePaths->GetAt(m_stSrcIndex)); // cut path from clipboard + if(m_spBasePathData) + m_pathFile.MakeRelativePath(m_spBasePathData->GetSrcPath()); } void TFileInfo::Init(const TSmartPath& rpathFile, DWORD dwAttributes, ULONGLONG uhFileSize, FILETIME ftCreation, FILETIME ftLastAccess, FILETIME ftLastWrite, uint_t uiFlags) { m_pathFile = rpathFile; - m_stSrcIndex = std::numeric_limits::max(); - m_pBasePaths = NULL; + m_spBasePathData.reset(); m_dwAttributes = dwAttributes; m_uhFileSize = uhFileSize; m_ftCreation = ftCreation; @@ -94,17 +89,15 @@ m_uiFlags = uiFlags; } -void TFileInfo::SetParentObject(size_t stIndex, const TModPathContainer* pBasePaths) +void TFileInfo::SetParentObject(const TBasePathDataPtr& spBasePathData) { // cannot set parent object if there is already one specified - if(m_pBasePaths && m_stSrcIndex != std::numeric_limits::max()) + if(m_spBasePathData) THROW_CORE_EXCEPTION(eErr_InvalidArgument); - m_stSrcIndex = stIndex; - m_pBasePaths = pBasePaths; - - if(m_pBasePaths && m_stSrcIndex != std::numeric_limits::max()) - m_pathFile.MakeRelativePath(m_pBasePaths->GetAt(m_stSrcIndex)); + m_spBasePathData = spBasePathData; + if(m_spBasePathData) + m_pathFile.MakeRelativePath(m_spBasePathData->GetSrcPath()); } bool TFileInfo::operator==(const TFileInfo& rInfo) @@ -115,59 +108,26 @@ TSmartPath TFileInfo::GetFullFilePath() const { - if(m_stSrcIndex != std::numeric_limits::max()) + if(m_spBasePathData) { - BOOST_ASSERT(m_pBasePaths); - if(!m_pBasePaths) - THROW_CORE_EXCEPTION(eErr_InvalidPointer); - - TSmartPath pathCombined = m_pBasePaths->GetAt(m_stSrcIndex); + TSmartPath pathCombined = m_spBasePathData->GetSrcPath(); pathCombined += m_pathFile; return pathCombined; } else return m_pathFile; } -void TFileInfo::Serialize(TReadBinarySerializer& rSerializer) +size_t TFileInfo::GetSrcObjectID() const { - using Serializers::Serialize; - - Serialize(rSerializer, m_pathFile); - Serialize(rSerializer, m_stSrcIndex); - Serialize(rSerializer, m_dwAttributes); - Serialize(rSerializer, m_uhFileSize); - Serialize(rSerializer, m_ftCreation.dwHighDateTime); - Serialize(rSerializer, m_ftCreation.dwLowDateTime); - Serialize(rSerializer, m_ftLastAccess.dwHighDateTime); - Serialize(rSerializer, m_ftLastAccess.dwLowDateTime); - Serialize(rSerializer, m_ftLastWrite.dwHighDateTime); - Serialize(rSerializer, m_ftLastWrite.dwLowDateTime); - Serialize(rSerializer, m_uiFlags); + if(m_spBasePathData) + return m_spBasePathData->GetObjectID(); + return std::numeric_limits::max(); } -void TFileInfo::Serialize(TWriteBinarySerializer& rSerializer) const +TBasePathDataPtr TFileInfo::GetBasePathData() const { - using Serializers::Serialize; - - Serialize(rSerializer, m_pathFile); - Serialize(rSerializer, m_stSrcIndex); - Serialize(rSerializer, m_dwAttributes); - Serialize(rSerializer, m_uhFileSize); - Serialize(rSerializer, m_ftCreation.dwHighDateTime); - Serialize(rSerializer, m_ftCreation.dwLowDateTime); - Serialize(rSerializer, m_ftLastAccess.dwHighDateTime); - Serialize(rSerializer, m_ftLastAccess.dwLowDateTime); - Serialize(rSerializer, m_ftLastWrite.dwHighDateTime); - Serialize(rSerializer, m_ftLastWrite.dwLowDateTime); - Serialize(rSerializer, m_uiFlags); + return m_spBasePathData; } -size_t TFileInfo::GetSrcObjectID() const -{ - if(m_pBasePaths) - return m_pBasePaths->GetOidAt(m_stSrcIndex); - return std::numeric_limits::max(); -} - END_CHCORE_NAMESPACE Index: src/libchcore/TFileInfo.h =================================================================== diff -u -r2efd22688b8d12be34c87bf2b024d8db6e317d60 -ra7834ba278464cb62739f22d35f9bc16269706a1 --- src/libchcore/TFileInfo.h (.../TFileInfo.h) (revision 2efd22688b8d12be34c87bf2b024d8db6e317d60) +++ src/libchcore/TFileInfo.h (.../TFileInfo.h) (revision a7834ba278464cb62739f22d35f9bc16269706a1) @@ -24,6 +24,7 @@ #include "libchcore.h" #include "TPath.h" +#include "TBasePathData.h" BEGIN_CHCORE_NAMESPACE @@ -36,14 +37,14 @@ #define FIF_PROCESSED 0x00000001 class LIBCHCORE_API TFileInfo -{ +{ public: TFileInfo(); TFileInfo(const TFileInfo& finf); ~TFileInfo(); // with base path - void Init(const TSmartPath& rpathFile, size_t stSrcIndex, const TModPathContainer* pBasePaths, + void Init(const TBasePathDataPtr& spBasePathData, const TSmartPath& rpathFile, DWORD dwAttributes, ULONGLONG uhFileSize, FILETIME ftCreation, FILETIME ftLastAccess, FILETIME ftLastWrite, uint_t uiFlags); @@ -52,8 +53,10 @@ FILETIME ftLastAccess, FILETIME ftLastWrite, uint_t uiFlags); // setting parent object - void SetParentObject(size_t stIndex, const TModPathContainer* pBasePaths); + TBasePathDataPtr GetBasePathData() const; + void SetParentObject(const TBasePathDataPtr& spBasePathData); + ULONGLONG GetLength64() const { return m_uhFileSize; } void SetLength64(ULONGLONG uhSize) { m_uhFileSize=uhSize; } @@ -80,25 +83,18 @@ uint_t GetFlags() const { return m_uiFlags; } void SetFlags(uint_t uiFlags, uint_t uiMask = 0xffffffff) { m_uiFlags = (m_uiFlags & ~(uiFlags & uiMask)) | (uiFlags & uiMask); } - // operations - void SetBasePaths(const TModPathContainer* pBasePaths) { m_pBasePaths = pBasePaths; } - - void SetSrcIndex(size_t stIndex) { m_stSrcIndex = stIndex; }; - size_t GetSrcIndex() const { return m_stSrcIndex; }; - size_t GetSrcObjectID() const; // operators bool operator==(const TFileInfo& rInfo); - void Serialize(TReadBinarySerializer& rSerializer); - void Serialize(TWriteBinarySerializer& rSerializer) const; - private: TSmartPath m_pathFile; // contains relative path (first path is in CClipboardArray) - size_t m_stSrcIndex; // index in CClipboardArray table (which contains the first part of the path) - const TModPathContainer* m_pBasePaths; +#pragma warning(push) +#pragma warning(disable: 4251) + TBasePathDataPtr m_spBasePathData; +#pragma warning(pop) DWORD m_dwAttributes; // attributes ULONGLONG m_uhFileSize; Index: src/libchcore/TFileInfoArray.cpp =================================================================== diff -u -r73583f2ca01fa1b2eae49bbc63bce46b9ecff5db -ra7834ba278464cb62739f22d35f9bc16269706a1 --- src/libchcore/TFileInfoArray.cpp (.../TFileInfoArray.cpp) (revision 73583f2ca01fa1b2eae49bbc63bce46b9ecff5db) +++ src/libchcore/TFileInfoArray.cpp (.../TFileInfoArray.cpp) (revision a7834ba278464cb62739f22d35f9bc16269706a1) @@ -30,8 +30,7 @@ /////////////////////////////////////////////////////////////////////// // Array -TFileInfoArray::TFileInfoArray(const TModPathContainer& rBasePaths) : - m_rBasePaths(rBasePaths), +TFileInfoArray::TFileInfoArray() : m_bComplete(false) { } @@ -107,72 +106,6 @@ return m_bComplete; } -void TFileInfoArray::Serialize(TReadBinarySerializer& rSerializer, bool bOnlyFlags) -{ - using Serializers::Serialize; - - boost::unique_lock lock(m_lock); - - size_t stCount; - Serialize(rSerializer, stCount); - - if(!bOnlyFlags) - { - m_vFiles.clear(); - m_vFiles.reserve(stCount); - } - else if(stCount != m_vFiles.size()) - THROW(_T("Invalid count of flags received"), 0, 0, 0); - - TFileInfoPtr spFileInfo; - - uint_t uiFlags = 0; - for(size_t stIndex = 0; stIndex < stCount; stIndex++) - { - if(bOnlyFlags) - { - TFileInfoPtr& rspFileInfo = m_vFiles.at(stIndex); - Serialize(rSerializer, uiFlags); - rspFileInfo->SetFlags(uiFlags); - } - else - { - spFileInfo.reset(new TFileInfo); - spFileInfo->SetBasePaths(&m_rBasePaths); - Serialize(rSerializer, *spFileInfo); - m_vFiles.push_back(spFileInfo); - } - } - - // we assume here that if the array was saved with at least one item, then it must have been complete at the time of writing - if(!bOnlyFlags && stCount > 0) - m_bComplete = true; -} - -void TFileInfoArray::Serialize(TWriteBinarySerializer& rSerializer, bool bOnlyFlags) const -{ - using Serializers::Serialize; - - boost::shared_lock lock(m_lock); - - size_t stCount = m_bComplete ? m_vFiles.size() : 0; - Serialize(rSerializer, stCount); - - if(m_bComplete) - { - for(std::vector::const_iterator iterFile = m_vFiles.begin(); iterFile != m_vFiles.end(); ++iterFile) - { - if(bOnlyFlags) - { - uint_t uiFlags = (*iterFile)->GetFlags(); - Serialize(rSerializer, uiFlags); - } - else - Serialize(rSerializer, *(*iterFile)); - } - } -} - unsigned long long TFileInfoArray::CalculatePartialSize(size_t stCount) { unsigned long long ullSize = 0; Index: src/libchcore/TFileInfoArray.h =================================================================== diff -u -r73583f2ca01fa1b2eae49bbc63bce46b9ecff5db -ra7834ba278464cb62739f22d35f9bc16269706a1 --- src/libchcore/TFileInfoArray.h (.../TFileInfoArray.h) (revision 73583f2ca01fa1b2eae49bbc63bce46b9ecff5db) +++ src/libchcore/TFileInfoArray.h (.../TFileInfoArray.h) (revision a7834ba278464cb62739f22d35f9bc16269706a1) @@ -24,7 +24,6 @@ #include "libchcore.h" #include "TPath.h" -#include "TModPathContainer.h" BEGIN_CHCORE_NAMESPACE @@ -38,7 +37,7 @@ class LIBCHCORE_API TFileInfoArray { public: - TFileInfoArray(const TModPathContainer& rBasePaths); + TFileInfoArray(); ~TFileInfoArray(); // Adds a new object info to this container @@ -71,7 +70,6 @@ void Serialize(TWriteBinarySerializer& rSerializer, bool bOnlyFlags) const; protected: - const TModPathContainer& m_rBasePaths; bool m_bComplete; #pragma warning(push) Index: src/libchcore/TLocalFilesystem.cpp =================================================================== diff -u -r73583f2ca01fa1b2eae49bbc63bce46b9ecff5db -ra7834ba278464cb62739f22d35f9bc16269706a1 --- src/libchcore/TLocalFilesystem.cpp (.../TLocalFilesystem.cpp) (revision 73583f2ca01fa1b2eae49bbc63bce46b9ecff5db) +++ src/libchcore/TLocalFilesystem.cpp (.../TLocalFilesystem.cpp) (revision a7834ba278464cb62739f22d35f9bc16269706a1) @@ -148,7 +148,7 @@ return ::DeleteFile(PrependPathExtensionIfNeeded(pathFile).ToString()) != FALSE; } -bool TLocalFilesystem::GetFileInfo(const TSmartPath& pathFile, TFileInfoPtr& rFileInfo, size_t stSrcIndex, const TModPathContainer* pBasePaths) +bool TLocalFilesystem::GetFileInfo(const TSmartPath& pathFile, TFileInfoPtr& rFileInfo, const TBasePathDataPtr& spBasePathData) { if(!rFileInfo) THROW_CORE_EXCEPTION(eErr_InvalidArgument); @@ -166,7 +166,7 @@ pathNew.DeleteFileName(); // copy data from W32_F_D - rFileInfo->Init(pathNew + PathFromString(wfd.cFileName), stSrcIndex, pBasePaths, + rFileInfo->Init(spBasePathData, pathNew + PathFromString(wfd.cFileName), wfd.dwFileAttributes, (((ULONGLONG) wfd.nFileSizeHigh) << 32) + wfd.nFileSizeLow, wfd.ftCreationTime, wfd.ftLastAccessTime, wfd.ftLastWriteTime, 0); @@ -175,7 +175,7 @@ else { FILETIME fi = { 0, 0 }; - rFileInfo->Init(TSmartPath(), std::numeric_limits::max(), NULL, (DWORD)-1, 0, fi, fi, fi, 0); + rFileInfo->Init(TSmartPath(), (DWORD)-1, 0, fi, fi, fi, 0); return false; } } Index: src/libchcore/TLocalFilesystem.h =================================================================== diff -u -r73583f2ca01fa1b2eae49bbc63bce46b9ecff5db -ra7834ba278464cb62739f22d35f9bc16269706a1 --- src/libchcore/TLocalFilesystem.h (.../TLocalFilesystem.h) (revision 73583f2ca01fa1b2eae49bbc63bce46b9ecff5db) +++ src/libchcore/TLocalFilesystem.h (.../TLocalFilesystem.h) (revision a7834ba278464cb62739f22d35f9bc16269706a1) @@ -25,6 +25,7 @@ #include "libchcore.h" #include "TPath.h" +#include "TBasePathData.h" BEGIN_CHCORE_NAMESPACE @@ -59,7 +60,7 @@ 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 TModPathContainer* pBasePaths = NULL); + static bool GetFileInfo(const TSmartPath& pathFile, TFileInfoPtr& rFileInfo, const TBasePathDataPtr& spBasePathData = TBasePathDataPtr()); static bool FastMove(const TSmartPath& pathSource, const TSmartPath& pathDestination); static TLocalFilesystemFind CreateFinderObject(const TSmartPath& pathDir, const TSmartPath& pathMask); Index: src/libchcore/TSQLiteTaskSchema.cpp =================================================================== diff -u -r293e52b38d46653068006262172018a0f0d0a31c -ra7834ba278464cb62739f22d35f9bc16269706a1 --- src/libchcore/TSQLiteTaskSchema.cpp (.../TSQLiteTaskSchema.cpp) (revision 293e52b38d46653068006262172018a0f0d0a31c) +++ src/libchcore/TSQLiteTaskSchema.cpp (.../TSQLiteTaskSchema.cpp) (revision a7834ba278464cb62739f22d35f9bc16269706a1) @@ -46,12 +46,9 @@ tStatement.Prepare(_T("CREATE TABLE task(id BIGINT UNIQUE, name varchar(256) NOT NULL, log_path VARCHAR(32768), current_state INT NOT NULL, destination_path varchar(32768) NOT NULL)")); tStatement.Step(); - tStatement.Prepare(_T("CREATE TABLE base_paths(id BIGINT UNIQUE, path varchar(32768) NOT NULL)")); + tStatement.Prepare(_T("CREATE TABLE base_paths(id BIGINT UNIQUE, src_path varchar(32768) NOT NULL, skip_processing boolean NOT NULL, dst_path varchar(32768) NOT NULL)")); tStatement.Step(); - tStatement.Prepare(_T("CREATE TABLE base_paths_data(id BIGINT UNIQUE REFERENCES base_paths(id), skip_processing boolean NOT NULL, dst_path varchar(32768) NOT NULL)")); - tStatement.Step(); - // and finally set the database version to current one tVersion.SetVersion(1); } Index: src/libchcore/TSubTaskBase.cpp =================================================================== diff -u -r2efd22688b8d12be34c87bf2b024d8db6e317d60 -ra7834ba278464cb62739f22d35f9bc16269706a1 --- src/libchcore/TSubTaskBase.cpp (.../TSubTaskBase.cpp) (revision 2efd22688b8d12be34c87bf2b024d8db6e317d60) +++ src/libchcore/TSubTaskBase.cpp (.../TSubTaskBase.cpp) (revision a7834ba278464cb62739f22d35f9bc16269706a1) @@ -47,8 +47,6 @@ TSmartPath TSubTaskBase::CalculateDestinationPath(const TFileInfoPtr& spFileInfo, TSmartPath pathDst, int iFlags) { - TBasePathDataContainer& rSourcePathsInfo = GetContext().GetBasePathDataContainer(); - if(!spFileInfo) THROW_CORE_EXCEPTION(eErr_InvalidArgument); @@ -65,12 +63,11 @@ } else { - size_t stSrcObjectID = spFileInfo->GetSrcObjectID(); + TBasePathDataPtr spPathData = spFileInfo->GetBasePathData(); - if(!(iFlags & 0x01) && stSrcObjectID != std::numeric_limits::max()) + if(!(iFlags & 0x01) && spPathData) { // generate new dest name - TBasePathDataPtr spPathData = rSourcePathsInfo.Get(stSrcObjectID); if(!spPathData->IsDestinationPathSet()) { // generate something - if dest folder == src folder - search for copy Index: src/libchcore/TSubTaskContext.cpp =================================================================== diff -u -r2efd22688b8d12be34c87bf2b024d8db6e317d60 -ra7834ba278464cb62739f22d35f9bc16269706a1 --- src/libchcore/TSubTaskContext.cpp (.../TSubTaskContext.cpp) (revision 2efd22688b8d12be34c87bf2b024d8db6e317d60) +++ src/libchcore/TSubTaskContext.cpp (.../TSubTaskContext.cpp) (revision a7834ba278464cb62739f22d35f9bc16269706a1) @@ -27,14 +27,12 @@ BEGIN_CHCORE_NAMESPACE -TSubTaskContext::TSubTaskContext(TConfig& rConfig, TModPathContainer& rBasePaths, - TBasePathDataContainer& rBasePathDataContainer, TFileInfoArray& rFilesCache, - TTaskConfigTracker& rCfgTracker, icpf::log_file& rLog, const IFeedbackHandlerPtr& spFeedbackHandler, - TWorkerThreadController& rThreadController, TLocalFilesystem& rfsLocal) : +TSubTaskContext::TSubTaskContext(TConfig& rConfig, const TBasePathDataContainerPtr& spBasePaths, TFileInfoArray& rFilesCache, + TTaskConfigTracker& rCfgTracker, icpf::log_file& rLog, const IFeedbackHandlerPtr& spFeedbackHandler, + TWorkerThreadController& rThreadController, TLocalFilesystem& rfsLocal) : m_rConfig(rConfig), m_eOperationType(eOperation_None), - m_rBasePaths(rBasePaths), - m_rBasePathDataContainer(rBasePathDataContainer), + m_spBasePaths(spBasePaths), m_rFilesCache(rFilesCache), m_pathDestination(), m_rCfgTracker(rCfgTracker), @@ -69,16 +67,11 @@ m_eOperationType = eOperationType; } -TBasePathDataContainer& TSubTaskContext::GetBasePathDataContainer() +TBasePathDataContainerPtr TSubTaskContext::GetBasePaths() const { - return m_rBasePathDataContainer; + return m_spBasePaths; } -const TBasePathDataContainer& TSubTaskContext::GetBasePathDataContainer() const -{ - return m_rBasePathDataContainer; -} - TFileInfoArray& TSubTaskContext::GetFilesCache() { return m_rFilesCache; @@ -147,14 +140,4 @@ return m_rfsLocal; } -TModPathContainer& TSubTaskContext::GetBasePaths() -{ - return m_rBasePaths; -} - -const TModPathContainer& TSubTaskContext::GetBasePaths() const -{ - return m_rBasePaths; -} - END_CHCORE_NAMESPACE Index: src/libchcore/TSubTaskContext.h =================================================================== diff -u -r2efd22688b8d12be34c87bf2b024d8db6e317d60 -ra7834ba278464cb62739f22d35f9bc16269706a1 --- src/libchcore/TSubTaskContext.h (.../TSubTaskContext.h) (revision 2efd22688b8d12be34c87bf2b024d8db6e317d60) +++ src/libchcore/TSubTaskContext.h (.../TSubTaskContext.h) (revision a7834ba278464cb62739f22d35f9bc16269706a1) @@ -27,6 +27,7 @@ #include "TPath.h" #include "EOperationTypes.h" #include "IFeedbackHandler.h" +#include "TBasePathData.h" namespace icpf { @@ -37,7 +38,6 @@ class TWorkerThreadController; class TModPathContainer; -class TBasePathDataContainer; class TTaskConfigTracker; class TLocalFilesystem; class TTaskLocalStatsInfo; @@ -51,10 +51,9 @@ class LIBCHCORE_API TSubTaskContext { public: - TSubTaskContext(TConfig& rConfig, TModPathContainer& rBasePaths, - TBasePathDataContainer& rBasePathDataContainer, TFileInfoArray& rFilesCache, - TTaskConfigTracker& rCfgTracker, icpf::log_file& rLog, - const IFeedbackHandlerPtr& spFeedbackHandler, TWorkerThreadController& rThreadController, TLocalFilesystem& rfsLocal); + TSubTaskContext(TConfig& rConfig, const TBasePathDataContainerPtr& spBasePaths, TFileInfoArray& rFilesCache, + TTaskConfigTracker& rCfgTracker, icpf::log_file& rLog, const IFeedbackHandlerPtr& spFeedbackHandler, + TWorkerThreadController& rThreadController, TLocalFilesystem& rfsLocal); ~TSubTaskContext(); TConfig& GetConfig(); @@ -63,12 +62,8 @@ chcore::EOperationType GetOperationType() const; void SetOperationType(chcore::EOperationType eOperationType); - TBasePathDataContainer& GetBasePathDataContainer(); - const TBasePathDataContainer& GetBasePathDataContainer() const; + TBasePathDataContainerPtr GetBasePaths() const; - TModPathContainer& GetBasePaths(); - const TModPathContainer& GetBasePaths() const; - TFileInfoArray& GetFilesCache(); const TFileInfoArray& GetFilesCache() const; @@ -99,8 +94,10 @@ EOperationType m_eOperationType; // information about input paths - TModPathContainer& m_rBasePaths; - TBasePathDataContainer& m_rBasePathDataContainer; +#pragma warning(push) +#pragma warning(disable: 4251) + TBasePathDataContainerPtr m_spBasePaths; +#pragma warning(pop) // data on which to operate TFileInfoArray& m_rFilesCache; Index: src/libchcore/TSubTaskCopyMove.cpp =================================================================== diff -u -r2efd22688b8d12be34c87bf2b024d8db6e317d60 -ra7834ba278464cb62739f22d35f9bc16269706a1 --- src/libchcore/TSubTaskCopyMove.cpp (.../TSubTaskCopyMove.cpp) (revision 2efd22688b8d12be34c87bf2b024d8db6e317d60) +++ src/libchcore/TSubTaskCopyMove.cpp (.../TSubTaskCopyMove.cpp) (revision a7834ba278464cb62739f22d35f9bc16269706a1) @@ -1230,7 +1230,7 @@ IFeedbackHandlerPtr spFeedbackHandler = GetContext().GetFeedbackHandler(); TLocalFilesystem& rLocalFilesystem = GetContext().GetLocalFilesystem(); TFileInfoArray& rFilesCache = GetContext().GetFilesCache(); - const TModPathContainer& rSrcPaths = GetContext().GetBasePaths(); + TBasePathDataContainerPtr spSrcPaths = GetContext().GetBasePaths(); TSmartPath pathDestination = GetContext().GetDestinationPath(); ull_t ullNeededSize = 0, ullAvailableSize = 0; @@ -1253,9 +1253,9 @@ strFormat.Replace(_t("%availablesize"), boost::lexical_cast(ullAvailableSize).c_str()); rLog.logw(strFormat); - if(!rSrcPaths.IsEmpty()) + if(!spSrcPaths->IsEmpty()) { - FEEDBACK_NOTENOUGHSPACE feedStruct = { ullNeededSize, rSrcPaths.GetAt(0).ToString(), pathDestination.ToString() }; + FEEDBACK_NOTENOUGHSPACE feedStruct = { ullNeededSize, spSrcPaths->GetAt(0)->GetSrcPath().ToString(), pathDestination.ToString() }; IFeedbackHandler::EFeedbackResult frResult = (IFeedbackHandler::EFeedbackResult)spFeedbackHandler->RequestFeedback(IFeedbackHandler::eFT_NotEnoughSpace, &feedStruct); // default Index: src/libchcore/TSubTaskFastMove.cpp =================================================================== diff -u -r2efd22688b8d12be34c87bf2b024d8db6e317d60 -ra7834ba278464cb62739f22d35f9bc16269706a1 --- src/libchcore/TSubTaskFastMove.cpp (.../TSubTaskFastMove.cpp) (revision 2efd22688b8d12be34c87bf2b024d8db6e317d60) +++ src/libchcore/TSubTaskFastMove.cpp (.../TSubTaskFastMove.cpp) (revision a7834ba278464cb62739f22d35f9bc16269706a1) @@ -117,16 +117,15 @@ icpf::log_file& rLog = GetContext().GetLog(); IFeedbackHandlerPtr spFeedbackHandler = GetContext().GetFeedbackHandler(); TWorkerThreadController& rThreadController = GetContext().GetThreadController(); - TBasePathDataContainer& rBasePathDataContainer = GetContext().GetBasePathDataContainer(); - TModPathContainer& rBasePaths = GetContext().GetBasePaths(); + TBasePathDataContainerPtr spBasePaths = GetContext().GetBasePaths(); const TConfig& rConfig = GetContext().GetConfig(); TSmartPath pathDestination = GetContext().GetDestinationPath(); rLog.logi(_T("Performing initial fast-move operation...")); // new stats m_tSubTaskStats.SetCurrentBufferIndex(TBufferSizes::eBuffer_Default); - m_tSubTaskStats.SetTotalCount(rBasePaths.GetCount()); + m_tSubTaskStats.SetTotalCount(spBasePaths->GetCount()); m_tSubTaskStats.SetProcessedCount(0); m_tSubTaskStats.SetTotalSize(0); m_tSubTaskStats.SetProcessedSize(0); @@ -149,14 +148,13 @@ bool bRetry = true; bool bSkipInputPath = false; - size_t stSize = rBasePaths.GetCount(); + size_t stSize = spBasePaths->GetCount(); size_t stIndex = m_tProgressInfo.GetCurrentIndex(); for(; stIndex < stSize ; stIndex++) { - size_t stSrcObjectID = rBasePaths.GetOidAt(stIndex); + TBasePathDataPtr spBasePath = spBasePaths->GetAt(stIndex); + TSmartPath pathCurrent = spBasePath->GetSrcPath(); - TSmartPath pathCurrent = rBasePaths.GetAt(stIndex); - // store currently processed index m_tProgressInfo.SetCurrentIndex(stIndex); @@ -166,7 +164,7 @@ // retrieve base path data // check if we want to process this path at all - if(rBasePathDataContainer.GetSkipFurtherProcessing(stSrcObjectID)) + if(spBasePath->GetSkipFurtherProcessing()) continue; TFileInfoPtr spFileInfo(boost::make_shared()); @@ -177,7 +175,7 @@ bRetry = false; // read attributes of src file/folder - bool bExists = TLocalFilesystem::GetFileInfo(pathCurrent, spFileInfo, stIndex, &rBasePaths); + bool bExists = TLocalFilesystem::GetFileInfo(pathCurrent, spFileInfo, spBasePath); if(!bExists) { FEEDBACK_FILEERROR ferr = { pathCurrent.ToString(), NULL, eFastMoveError, ERROR_FILE_NOT_FOUND }; @@ -213,17 +211,17 @@ // does it match the input filter? if(!spFileInfo->IsDirectory() && !afFilters.Match(spFileInfo)) { - rBasePathDataContainer.Get(stSrcObjectID)->SetSkipFurtherProcessing(true); + spBasePath->SetSkipFurtherProcessing(true); continue; } // try to fast move bRetry = true; bool bResult = true; - do + do { TSmartPath pathDestinationPath = CalculateDestinationPath(spFileInfo, pathDestination, 0); - TSmartPath pathSrc = rBasePaths.GetAt(stIndex); + TSmartPath pathSrc = spBasePath->GetSrcPath(); bResult = TLocalFilesystem::FastMove(pathSrc, pathDestinationPath); if(!bResult) { @@ -268,7 +266,7 @@ } } else - rBasePathDataContainer.Get(stSrcObjectID)->SetSkipFurtherProcessing(true); // mark that this path should not be processed any further + spBasePath->SetSkipFurtherProcessing(true); // mark that this path should not be processed any further } while(!bResult && bRetry); Index: src/libchcore/TSubTaskScanDirectory.cpp =================================================================== diff -u -r2efd22688b8d12be34c87bf2b024d8db6e317d60 -ra7834ba278464cb62739f22d35f9bc16269706a1 --- src/libchcore/TSubTaskScanDirectory.cpp (.../TSubTaskScanDirectory.cpp) (revision 2efd22688b8d12be34c87bf2b024d8db6e317d60) +++ src/libchcore/TSubTaskScanDirectory.cpp (.../TSubTaskScanDirectory.cpp) (revision a7834ba278464cb62739f22d35f9bc16269706a1) @@ -120,8 +120,7 @@ TFileInfoArray& rFilesCache = GetContext().GetFilesCache(); IFeedbackHandlerPtr spFeedbackHandler = GetContext().GetFeedbackHandler(); TWorkerThreadController& rThreadController = GetContext().GetThreadController(); - TBasePathDataContainer& rBasePathDataContainer = GetContext().GetBasePathDataContainer(); - const TModPathContainer& rBasePaths = GetContext().GetBasePaths(); + TBasePathDataContainerPtr spBasePaths = GetContext().GetBasePaths(); const TConfig& rConfig = GetContext().GetConfig(); rLog.logi(_T("Searching for files...")); @@ -131,7 +130,7 @@ // new stats m_tSubTaskStats.SetCurrentBufferIndex(TBufferSizes::eBuffer_Default); - m_tSubTaskStats.SetTotalCount(rBasePaths.GetCount()); + m_tSubTaskStats.SetTotalCount(spBasePaths->GetCount()); m_tSubTaskStats.SetProcessedCount(0); m_tSubTaskStats.SetTotalSize(0); m_tSubTaskStats.SetProcessedSize(0); @@ -152,13 +151,13 @@ bool bRetry = true; bool bSkipInputPath = false; - size_t stSize = rBasePaths.GetCount(); + size_t stSize = spBasePaths->GetCount(); // NOTE: in theory, we should resume the scanning, but in practice we are always restarting scanning if interrupted. size_t stIndex = 0; // m_tProgressInfo.GetCurrentIndex() for(; stIndex < stSize; stIndex++) { - size_t stObjectID = rBasePaths.GetOidAt(stIndex); - TSmartPath pathCurrent = rBasePaths.GetAt(stIndex); + TBasePathDataPtr spBasePath = spBasePaths->GetAt(stIndex); + TSmartPath pathCurrent = spBasePath->GetSrcPath(); m_tProgressInfo.SetCurrentIndex(stIndex); @@ -170,7 +169,7 @@ TFileInfoPtr spFileInfo(boost::make_shared()); // check if we want to process this path at all (might be already fast moved) - if(rBasePathDataContainer.GetSkipFurtherProcessing(stObjectID)) + if(spBasePath->GetSkipFurtherProcessing()) continue; // try to get some info about the input path; let user know if the path does not exist. @@ -179,10 +178,10 @@ bRetry = false; // read attributes of src file/folder - bool bExists = TLocalFilesystem::GetFileInfo(pathCurrent, spFileInfo, stIndex, &rBasePaths); + bool bExists = TLocalFilesystem::GetFileInfo(pathCurrent, spFileInfo, spBasePath); if(!bExists) { - FEEDBACK_FILEERROR ferr = { rBasePaths.GetAt(stIndex).ToString(), NULL, eFastMoveError, ERROR_FILE_NOT_FOUND }; + FEEDBACK_FILEERROR ferr = { pathCurrent.ToString(), NULL, eFastMoveError, ERROR_FILE_NOT_FOUND }; IFeedbackHandler::EFeedbackResult frResult = (IFeedbackHandler::EFeedbackResult)spFeedbackHandler->RequestFeedback(IFeedbackHandler::eFT_FileError, &ferr); switch(frResult) { @@ -216,7 +215,7 @@ // log strFormat = _T("Adding file/folder (clipboard) : %path ..."); - strFormat.Replace(_T("%path"), rBasePaths.GetAt(stIndex).ToString()); + strFormat.Replace(_T("%path"), pathCurrent.ToString()); rLog.logi(strFormat); // add if needed @@ -240,7 +239,7 @@ strFormat.Replace(_t("%path"), spFileInfo->GetFullFilePath().ToString()); rLog.logi(strFormat); - ScanDirectory(spFileInfo->GetFullFilePath(), stIndex, true, !bIgnoreDirs || bForceDirectories, afFilters); + ScanDirectory(spFileInfo->GetFullFilePath(), spBasePath, true, !bIgnoreDirs || bForceDirectories, afFilters); // check for kill need if(rThreadController.KillRequested()) @@ -284,11 +283,11 @@ m_tSubTaskStats.GetSnapshot(spStats); } -int TSubTaskScanDirectories::ScanDirectory(TSmartPath pathDirName, size_t stSrcIndex, bool bRecurse, bool bIncludeDirs, TFileFiltersArray& afFilters) +int TSubTaskScanDirectories::ScanDirectory(TSmartPath pathDirName, const TBasePathDataPtr& spBasePathData, bool bRecurse, bool bIncludeDirs, TFileFiltersArray& afFilters) { TFileInfoArray& rFilesCache = GetContext().GetFilesCache(); TWorkerThreadController& rThreadController = GetContext().GetThreadController(); - const TModPathContainer& rBasePaths = GetContext().GetBasePaths(); + TBasePathDataContainerPtr spBasePaths = GetContext().GetBasePaths(); TLocalFilesystemFind finder = TLocalFilesystem::CreateFinderObject(pathDirName, PathFromString(_T("*"))); TFileInfoPtr spFileInfo(boost::make_shared()); @@ -302,7 +301,7 @@ { if(afFilters.Match(spFileInfo)) { - spFileInfo->SetParentObject(stSrcIndex, &rBasePaths); + spFileInfo->SetParentObject(spBasePathData); rFilesCache.AddFileInfo(spFileInfo); spFileInfo = boost::make_shared(); } @@ -312,13 +311,13 @@ TSmartPath pathCurrent = spFileInfo->GetFullFilePath(); if(bIncludeDirs) { - spFileInfo->SetParentObject(stSrcIndex, &rBasePaths); + spFileInfo->SetParentObject(spBasePathData); rFilesCache.AddFileInfo(spFileInfo); spFileInfo = boost::make_shared(); } if(bRecurse) - ScanDirectory(pathCurrent, stSrcIndex, bRecurse, bIncludeDirs, afFilters); + ScanDirectory(pathCurrent, spBasePathData, bRecurse, bIncludeDirs, afFilters); } } Index: src/libchcore/TSubTaskScanDirectory.h =================================================================== diff -u -ra5f396da5ed5ffb3fcd9fdf22afb5a7fd07e1ab8 -ra7834ba278464cb62739f22d35f9bc16269706a1 --- src/libchcore/TSubTaskScanDirectory.h (.../TSubTaskScanDirectory.h) (revision a5f396da5ed5ffb3fcd9fdf22afb5a7fd07e1ab8) +++ src/libchcore/TSubTaskScanDirectory.h (.../TSubTaskScanDirectory.h) (revision a7834ba278464cb62739f22d35f9bc16269706a1) @@ -26,6 +26,7 @@ #include "libchcore.h" #include "TSubTaskBase.h" #include "TPath.h" +#include "TBasePathData.h" BEGIN_CHCORE_NAMESPACE @@ -77,7 +78,7 @@ virtual void GetStatsSnapshot(TSubTaskStatsSnapshotPtr& spStats) const; private: - int ScanDirectory(TSmartPath pathDirName, size_t stSrcIndex, bool bRecurse, bool bIncludeDirs, TFileFiltersArray& afFilters); + int ScanDirectory(TSmartPath pathDirName, const TBasePathDataPtr& spBasePathData, bool bRecurse, bool bIncludeDirs, TFileFiltersArray& afFilters); private: #pragma warning(push) Index: src/libchcore/TTask.cpp =================================================================== diff -u -r293e52b38d46653068006262172018a0f0d0a31c -ra7834ba278464cb62739f22d35f9bc16269706a1 --- src/libchcore/TTask.cpp (.../TTask.cpp) (revision 293e52b38d46653068006262172018a0f0d0a31c) +++ src/libchcore/TTask.cpp (.../TTask.cpp) (revision a7834ba278464cb62739f22d35f9bc16269706a1) @@ -45,11 +45,11 @@ TTask::TTask(const ISerializerPtr& spSerializer, const IFeedbackHandlerPtr& spFeedbackHandler) : m_log(), m_spFeedbackHandler(spFeedbackHandler), - m_arrSourcePathsInfo(), - m_files(m_vSourcePaths), + m_spSrcPaths(new TBasePathDataContainer), + m_files(), m_bForce(false), m_bContinue(false), - m_tSubTaskContext(m_tConfiguration, m_vSourcePaths, m_arrSourcePathsInfo, m_files, m_cfgTracker, m_log, spFeedbackHandler, m_workerThread, m_fsLocal), + m_tSubTaskContext(m_tConfiguration, m_spSrcPaths, m_files, m_cfgTracker, m_log, spFeedbackHandler, m_workerThread, m_fsLocal), m_tSubTasksArray(), m_spSerializer(spSerializer) { @@ -66,7 +66,7 @@ { m_tBaseData.SetDestinationPath(rTaskDefinition.GetDestinationPath()); m_tConfiguration = rTaskDefinition.GetConfiguration(); - m_vSourcePaths = rTaskDefinition.GetSourcePaths(); + *m_spSrcPaths = rTaskDefinition.GetSourcePaths(); m_tBaseData.SetTaskName(rTaskDefinition.GetTaskName()); m_tSubTasksArray.Init(rTaskDefinition.GetOperationPlan(), m_tSubTaskContext); @@ -135,10 +135,7 @@ m_tBaseData.Load(spContainer); spContainer = m_spSerializer->GetContainer(_T("base_paths")); - m_vSourcePaths.Load(spContainer); - - spContainer = m_spSerializer->GetContainer(_T("base_paths_data")); - m_arrSourcePathsInfo.Load(spContainer); + m_spSrcPaths->Load(spContainer); } } @@ -154,10 +151,7 @@ // base paths spContainer = m_spSerializer->GetContainer(_T("base_paths")); - m_vSourcePaths.Store(spContainer); - - spContainer = m_spSerializer->GetContainer(_T("base_paths_data")); - m_arrSourcePathsInfo.Store(spContainer); + m_spSrcPaths->Store(spContainer); } m_spSerializer->Flush(); Index: src/libchcore/TTask.h =================================================================== diff -u -r293e52b38d46653068006262172018a0f0d0a31c -ra7834ba278464cb62739f22d35f9bc16269706a1 --- src/libchcore/TTask.h (.../TTask.h) (revision 293e52b38d46653068006262172018a0f0d0a31c) +++ src/libchcore/TTask.h (.../TTask.h) (revision a7834ba278464cb62739f22d35f9bc16269706a1) @@ -139,8 +139,10 @@ TTaskBaseData m_tBaseData; // basic information - TModPathContainer m_vSourcePaths; - TBasePathDataContainer m_arrSourcePathsInfo; +#pragma warning(push) +#pragma warning(disable: 4251) + TBasePathDataContainerPtr m_spSrcPaths; +#pragma warning(pop) // Global task settings TConfig m_tConfiguration; Index: src/libchcore/TTaskManager.cpp =================================================================== diff -u -r293e52b38d46653068006262172018a0f0d0a31c -ra7834ba278464cb62739f22d35f9bc16269706a1 --- src/libchcore/TTaskManager.cpp (.../TTaskManager.cpp) (revision 293e52b38d46653068006262172018a0f0d0a31c) +++ src/libchcore/TTaskManager.cpp (.../TTaskManager.cpp) (revision a7834ba278464cb62739f22d35f9bc16269706a1) @@ -25,6 +25,7 @@ #include "TCoreException.h" #include "ErrorCodes.h" #include "TTaskInfo.h" +#include BEGIN_CHCORE_NAMESPACE @@ -486,7 +487,6 @@ TTaskInfoEntry& rInfoEntry = m_tTasks.GetAtOid(rInfo.first); rInfoEntry.SetTask(spTask); } - } TSmartPath TTaskManager::CreateTaskLogPath(const TString& strTaskUuid) const