Index: src/ch/CustomCopyDlg.cpp =================================================================== diff -u -N -r10d4c73f3589c377ec0b60a2a053ff6aafeb507f -rd12e49decb8a3df3e28f6786d38542390484ac07 --- src/ch/CustomCopyDlg.cpp (.../CustomCopyDlg.cpp) (revision 10d4c73f3589c377ec0b60a2a053ff6aafeb507f) +++ src/ch/CustomCopyDlg.cpp (.../CustomCopyDlg.cpp) (revision d12e49decb8a3df3e28f6786d38542390484ac07) @@ -19,7 +19,7 @@ #include "stdafx.h" #include #include "resource.h" -#include "FileInfo.h" +#include "../libchcore/FileInfo.h" #include "CustomCopyDlg.h" #include "structs.h" #include "dialogs.h" @@ -278,7 +278,7 @@ lvc.cx=static_cast(0.1*rc.Width()); m_ctlFilters.InsertColumn(6, &lvc); - CFiltersArray afFilters; + chcore::CFiltersArray afFilters; GetTaskPropValue(m_tTaskDefinition.GetConfiguration(), afFilters); m_bFilters = !afFilters.IsEmpty(); @@ -379,11 +379,11 @@ m_ctlFilters.InsertColumn(6, &lvc); // refresh the entries in filters' list - CFiltersArray afFilters = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); + chcore::CFiltersArray afFilters = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); m_ctlFilters.DeleteAllItems(); for(size_t stIndex = 0; stIndex < afFilters.GetSize(); ++stIndex) { - const CFileFilter* pFilter = afFilters.GetAt(stIndex); + const chcore::CFileFilter* pFilter = afFilters.GetAt(stIndex); if(pFilter) AddFilter(*pFilter, boost::numeric_cast(stIndex)); } @@ -593,10 +593,10 @@ CFilterDlg dlg; chcore::TString strData; - CFiltersArray afFilters = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); + chcore::CFiltersArray afFilters = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); for (size_t i = 0; i < afFilters.GetSize(); i++) { - const CFileFilter* pFilter = afFilters.GetAt(i); + const chcore::CFileFilter* pFilter = afFilters.GetAt(i); BOOST_ASSERT(pFilter); if(pFilter) { @@ -620,7 +620,7 @@ } } -void CCustomCopyDlg::AddFilter(const CFileFilter &rFilter, int iPos) +void CCustomCopyDlg::AddFilter(const chcore::CFileFilter &rFilter, int iPos) { LVITEM lvi; TCHAR szLoaded[1024]; @@ -763,7 +763,7 @@ void CCustomCopyDlg::OnRemovefilterButton() { - CFiltersArray afFilters = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); + chcore::CFiltersArray afFilters = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); POSITION pos; int iItem; @@ -824,11 +824,11 @@ POSITION pos = m_ctlFilters.GetFirstSelectedItemPosition(); if(pos != NULL) { - CFiltersArray afFilters = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); + chcore::CFiltersArray afFilters = GetTaskPropValue(m_tTaskDefinition.GetConfiguration()); int iItem = m_ctlFilters.GetNextSelectedItem(pos); CFilterDlg dlg; - const CFileFilter* pFilter = afFilters.GetAt(iItem); + const chcore::CFileFilter* pFilter = afFilters.GetAt(iItem); BOOST_ASSERT(pFilter); if(pFilter) dlg.m_ffFilter = *pFilter; Index: src/ch/CustomCopyDlg.h =================================================================== diff -u -N -r6df9b4cff81dedf8c5571a98702b584b061eac09 -rd12e49decb8a3df3e28f6786d38542390484ac07 --- src/ch/CustomCopyDlg.h (.../CustomCopyDlg.h) (revision 6df9b4cff81dedf8c5571a98702b584b061eac09) +++ src/ch/CustomCopyDlg.h (.../CustomCopyDlg.h) (revision d12e49decb8a3df3e28f6786d38542390484ac07) @@ -20,7 +20,7 @@ #define __CUSTOMCOPYDLG_H__ #include "../libchcore/DataBuffer.h" -#include "FileFilter.h" +#include "../libchcore/FileFilter.h" #include "../libchcore/TTaskDefinition.h" ///////////////////////////////////////////////////////////////////////////// @@ -47,7 +47,7 @@ void UpdateComboIcon(); void SetComboPath(LPCTSTR lpszText); void EnableControls(); - void AddFilter(const CFileFilter& rFilter, int iPos=-1); + void AddFilter(const chcore::CFileFilter& rFilter, int iPos=-1); void AddPath(CString strPath); void SetBuffersizesString(); Index: src/ch/FeedbackFileErrorDlg.cpp =================================================================== diff -u -N -r22bbc4a87fa0b249e1e02ba385f28da9d77a4aa1 -rd12e49decb8a3df3e28f6786d38542390484ac07 --- src/ch/FeedbackFileErrorDlg.cpp (.../FeedbackFileErrorDlg.cpp) (revision 22bbc4a87fa0b249e1e02ba385f28da9d77a4aa1) +++ src/ch/FeedbackFileErrorDlg.cpp (.../FeedbackFileErrorDlg.cpp) (revision d12e49decb8a3df3e28f6786d38542390484ac07) @@ -3,7 +3,7 @@ #include "stdafx.h" #include "ch.h" -#include "FileInfo.h" +#include "../libchcore/FileInfo.h" #include "FeedbackFileErrorDlg.h" #include "FeedbackHandler.h" Index: src/ch/FeedbackHandler.cpp =================================================================== diff -u -N -r9ea1e103b5fa4ddfebf8028f121ce16e917eec04 -rd12e49decb8a3df3e28f6786d38542390484ac07 --- src/ch/FeedbackHandler.cpp (.../FeedbackHandler.cpp) (revision 9ea1e103b5fa4ddfebf8028f121ce16e917eec04) +++ src/ch/FeedbackHandler.cpp (.../FeedbackHandler.cpp) (revision d12e49decb8a3df3e28f6786d38542390484ac07) @@ -17,7 +17,7 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include "stdafx.h" -#include "FileInfo.h" +#include "../libchcore/FileInfo.h" #include "FeedbackHandler.h" #include "FeedbackReplaceDlg.h" #include "FeedbackFileErrorDlg.h" Index: src/ch/FeedbackHandler.h =================================================================== diff -u -N -rcac4819aa32d29c9feab400cadc083d713459a82 -rd12e49decb8a3df3e28f6786d38542390484ac07 --- src/ch/FeedbackHandler.h (.../FeedbackHandler.h) (revision cac4819aa32d29c9feab400cadc083d713459a82) +++ src/ch/FeedbackHandler.h (.../FeedbackHandler.h) (revision d12e49decb8a3df3e28f6786d38542390484ac07) @@ -23,8 +23,8 @@ struct FEEDBACK_ALREADYEXISTS { - CFileInfoPtr spSrcFileInfo; - CFileInfoPtr spDstFileInfo; + chcore::CFileInfoPtr spSrcFileInfo; + chcore::CFileInfoPtr spDstFileInfo; }; struct FEEDBACK_FILEERROR Index: src/ch/FeedbackNotEnoughSpaceDlg.cpp =================================================================== diff -u -N -r633a533cb6e741d44fe28aa56339e1d2709b1b27 -rd12e49decb8a3df3e28f6786d38542390484ac07 --- src/ch/FeedbackNotEnoughSpaceDlg.cpp (.../FeedbackNotEnoughSpaceDlg.cpp) (revision 633a533cb6e741d44fe28aa56339e1d2709b1b27) +++ src/ch/FeedbackNotEnoughSpaceDlg.cpp (.../FeedbackNotEnoughSpaceDlg.cpp) (revision d12e49decb8a3df3e28f6786d38542390484ac07) @@ -18,7 +18,7 @@ ***************************************************************************/ #include "stdafx.h" #include "ch.h" -#include "FileInfo.h" +#include "../libchcore/FileInfo.h" #include "FeedbackNotEnoughSpaceDlg.h" #include "StringHelpers.h" #include "FeedbackHandler.h" Index: src/ch/FeedbackReplaceDlg.cpp =================================================================== diff -u -N -r69b48f0b4d7fad78f95854e95fca166014311474 -rd12e49decb8a3df3e28f6786d38542390484ac07 --- src/ch/FeedbackReplaceDlg.cpp (.../FeedbackReplaceDlg.cpp) (revision 69b48f0b4d7fad78f95854e95fca166014311474) +++ src/ch/FeedbackReplaceDlg.cpp (.../FeedbackReplaceDlg.cpp) (revision d12e49decb8a3df3e28f6786d38542390484ac07) @@ -3,17 +3,17 @@ #include "stdafx.h" #include "ch.h" -#include "FileInfo.h" +#include "../libchcore/FileInfo.h" #include "FeedbackReplaceDlg.h" #include "../libictranslate/ResourceManager.h" -#include "FileInfo.h" +#include "../libchcore/FileInfo.h" #include "FeedbackHandler.h" // CFeedbackReplaceDlg dialog IMPLEMENT_DYNAMIC(CFeedbackReplaceDlg, ictranslate::CLanguageDialog) -CFeedbackReplaceDlg::CFeedbackReplaceDlg(const CFileInfoPtr& spSrcFile, const CFileInfoPtr& spDstFile, CWnd* pParent /*=NULL*/) +CFeedbackReplaceDlg::CFeedbackReplaceDlg(const chcore::CFileInfoPtr& spSrcFile, const chcore::CFileInfoPtr& spDstFile, CWnd* pParent /*=NULL*/) : ictranslate::CLanguageDialog(IDD_FEEDBACK_REPLACE_DIALOG, pParent), m_spSrcFile(spSrcFile), m_spDstFile(spDstFile), Index: src/ch/FeedbackReplaceDlg.h =================================================================== diff -u -N -r22bbc4a87fa0b249e1e02ba385f28da9d77a4aa1 -rd12e49decb8a3df3e28f6786d38542390484ac07 --- src/ch/FeedbackReplaceDlg.h (.../FeedbackReplaceDlg.h) (revision 22bbc4a87fa0b249e1e02ba385f28da9d77a4aa1) +++ src/ch/FeedbackReplaceDlg.h (.../FeedbackReplaceDlg.h) (revision d12e49decb8a3df3e28f6786d38542390484ac07) @@ -24,7 +24,7 @@ DECLARE_DYNAMIC(CFeedbackReplaceDlg) public: - CFeedbackReplaceDlg(const CFileInfoPtr& spSrcFile, const CFileInfoPtr& spDstFile, CWnd* pParent = NULL); // standard constructor + CFeedbackReplaceDlg(const chcore::CFileInfoPtr& spSrcFile, const chcore::CFileInfoPtr& spDstFile, CWnd* pParent = NULL); // standard constructor virtual ~CFeedbackReplaceDlg(); virtual BOOL OnInitDialog(); @@ -45,8 +45,8 @@ BOOL m_bAllItems; protected: - const CFileInfoPtr m_spSrcFile; - const CFileInfoPtr m_spDstFile; + const chcore::CFileInfoPtr m_spSrcFile; + const chcore::CFileInfoPtr m_spDstFile; public: afx_msg void OnBnClickedReplaceButton(); Index: src/ch/FilterDlg.cpp =================================================================== diff -u -N -r10d4c73f3589c377ec0b60a2a053ff6aafeb507f -rd12e49decb8a3df3e28f6786d38542390484ac07 --- src/ch/FilterDlg.cpp (.../FilterDlg.cpp) (revision 10d4c73f3589c377ec0b60a2a053ff6aafeb507f) +++ src/ch/FilterDlg.cpp (.../FilterDlg.cpp) (revision d12e49decb8a3df3e28f6786d38542390484ac07) @@ -17,8 +17,8 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include "stdafx.h" -#include "FileInfo.h" -#include "FileFilter.h" +#include "../libchcore/FileInfo.h" +#include "../libchcore/FileFilter.h" #include "ch.h" #include "FilterDlg.h" @@ -348,17 +348,17 @@ m_ffFilter.SetUseSize1(m_bSize != 0); m_ffFilter.SetUseSize2(m_bSize2 != 0); - m_ffFilter.SetSizeType1((CFileFilter::ESizeCompareType)m_ctlSizeType1.GetCurSel()); - m_ffFilter.SetSizeType2((CFileFilter::ESizeCompareType)m_ctlSizeType2.GetCurSel()); + m_ffFilter.SetSizeType1((chcore::CFileFilter::ESizeCompareType)m_ctlSizeType1.GetCurSel()); + m_ffFilter.SetSizeType2((chcore::CFileFilter::ESizeCompareType)m_ctlSizeType2.GetCurSel()); m_ffFilter.SetSize1(static_cast(m_uiSize1)*static_cast(GetMultiplier(m_ctlSize1Multi.GetCurSel()))); m_ffFilter.SetSize2(static_cast(m_uiSize2)*static_cast(GetMultiplier(m_ctlSize2Multi.GetCurSel()))); // date - m_ffFilter.SetDateType((CFileFilter::EDateType)m_ctlDateType.GetCurSel()); + m_ffFilter.SetDateType((chcore::CFileFilter::EDateType)m_ctlDateType.GetCurSel()); - m_ffFilter.SetDateCmpType1((CFileFilter::EDateCompareType)m_ctlDateType1.GetCurSel()); - m_ffFilter.SetDateCmpType2((CFileFilter::EDateCompareType)m_ctlDateType2.GetCurSel()); + m_ffFilter.SetDateCmpType1((chcore::CFileFilter::EDateCompareType)m_ctlDateType1.GetCurSel()); + m_ffFilter.SetDateCmpType2((chcore::CFileFilter::EDateCompareType)m_ctlDateType2.GetCurSel()); CTime tDateTime; m_ffFilter.SetUseDate1(m_ctlDate1.GetTime(tDateTime) == GDT_VALID); Index: src/ch/FilterDlg.h =================================================================== diff -u -N -r10d4c73f3589c377ec0b60a2a053ff6aafeb507f -rd12e49decb8a3df3e28f6786d38542390484ac07 --- src/ch/FilterDlg.h (.../FilterDlg.h) (revision 10d4c73f3589c377ec0b60a2a053ff6aafeb507f) +++ src/ch/FilterDlg.h (.../FilterDlg.h) (revision d12e49decb8a3df3e28f6786d38542390484ac07) @@ -73,9 +73,9 @@ // Implementation public: void SetSize2(unsigned __int64 ullSize); - CFileFilter m_ffFilter; - CStringArray m_astrAddMask; - CStringArray m_astrAddExcludeMask; + chcore::CFileFilter m_ffFilter; + CStringArray m_astrAddMask; + CStringArray m_astrAddExcludeMask; protected: virtual void OnLanguageChanged(); Index: src/ch/TLocalFilesystem.cpp =================================================================== diff -u -N -r6df9b4cff81dedf8c5571a98702b584b061eac09 -rd12e49decb8a3df3e28f6786d38542390484ac07 --- src/ch/TLocalFilesystem.cpp (.../TLocalFilesystem.cpp) (revision 6df9b4cff81dedf8c5571a98702b584b061eac09) +++ src/ch/TLocalFilesystem.cpp (.../TLocalFilesystem.cpp) (revision d12e49decb8a3df3e28f6786d38542390484ac07) @@ -24,7 +24,7 @@ #include "TLocalFilesystem.h" #include #include "TAutoHandles.h" -#include "FileInfo.h" +#include "../libchcore/FileInfo.h" #include "../libchcore/DataBuffer.h" #include @@ -133,7 +133,7 @@ return ::DeleteFile(PrependPathExtensionIfNeeded(pathFile).ToString()) != FALSE; } -bool TLocalFilesystem::GetFileInfo(const chcore::TSmartPath& pathFile, CFileInfoPtr& rFileInfo, size_t stSrcIndex, const chcore::TPathContainer* pBasePaths) +bool TLocalFilesystem::GetFileInfo(const chcore::TSmartPath& pathFile, chcore::CFileInfoPtr& rFileInfo, size_t stSrcIndex, const chcore::TPathContainer* pBasePaths) { if(!rFileInfo) THROW(_T("Invalid argument"), 0, 0, 0); @@ -313,7 +313,7 @@ Close(); } -bool TLocalFilesystemFind::FindNext(CFileInfoPtr& rspFileInfo) +bool TLocalFilesystemFind::FindNext(chcore::CFileInfoPtr& rspFileInfo) { WIN32_FIND_DATA wfd; chcore::TSmartPath pathCurrent = m_pathDir + m_pathMask; Index: src/ch/TLocalFilesystem.h =================================================================== diff -u -N -r6df9b4cff81dedf8c5571a98702b584b061eac09 -rd12e49decb8a3df3e28f6786d38542390484ac07 --- src/ch/TLocalFilesystem.h (.../TLocalFilesystem.h) (revision 6df9b4cff81dedf8c5571a98702b584b061eac09) +++ src/ch/TLocalFilesystem.h (.../TLocalFilesystem.h) (revision d12e49decb8a3df3e28f6786d38542390484ac07) @@ -26,8 +26,11 @@ #include "../libchcore/TPath.h" #include -class CFileInfo; -typedef boost::shared_ptr CFileInfoPtr; +namespace chcore +{ + class CFileInfo; + typedef boost::shared_ptr CFileInfoPtr; +} class TAutoFileHandle; class TLocalFilesystemFind; @@ -60,7 +63,7 @@ static bool RemoveDirectory(const chcore::TSmartPath& pathFile); static bool DeleteFile(const chcore::TSmartPath& pathFile); - static bool GetFileInfo(const chcore::TSmartPath& pathFile, CFileInfoPtr& rFileInfo, size_t stSrcIndex = std::numeric_limits::max(), const chcore::TPathContainer* pBasePaths = NULL); + static bool GetFileInfo(const chcore::TSmartPath& pathFile, chcore::CFileInfoPtr& rFileInfo, size_t stSrcIndex = std::numeric_limits::max(), const chcore::TPathContainer* pBasePaths = NULL); static bool FastMove(const chcore::TSmartPath& pathSource, const chcore::TSmartPath& pathDestination); static TLocalFilesystemFind CreateFinderObject(const chcore::TSmartPath& pathDir, const chcore::TSmartPath& pathMask); @@ -88,7 +91,7 @@ public: ~TLocalFilesystemFind(); - bool FindNext(CFileInfoPtr& rspFileInfo); + bool FindNext(chcore::CFileInfoPtr& rspFileInfo); void Close(); private: Index: src/ch/TSubTaskBase.cpp =================================================================== diff -u -N -rd345f15636dc88c4c40fe310ac7777bd024e12d9 -rd12e49decb8a3df3e28f6786d38542390484ac07 --- src/ch/TSubTaskBase.cpp (.../TSubTaskBase.cpp) (revision d345f15636dc88c4c40fe310ac7777bd024e12d9) +++ src/ch/TSubTaskBase.cpp (.../TSubTaskBase.cpp) (revision d12e49decb8a3df3e28f6786d38542390484ac07) @@ -40,7 +40,7 @@ { } -chcore::TSmartPath TSubTaskBase::CalculateDestinationPath(const CFileInfoPtr& spFileInfo, chcore::TSmartPath pathDst, int iFlags) const +chcore::TSmartPath TSubTaskBase::CalculateDestinationPath(const chcore::CFileInfoPtr& spFileInfo, chcore::TSmartPath pathDst, int iFlags) const { const chcore::TBasePathDataContainer& rSourcePathsInfo = GetContext().GetBasePathDataContainer(); Index: src/ch/TSubTaskBase.h =================================================================== diff -u -N -r9a171c5d46f2bc029d99a698d88eeff60497cd3b -rd12e49decb8a3df3e28f6786d38542390484ac07 --- src/ch/TSubTaskBase.h (.../TSubTaskBase.h) (revision 9a171c5d46f2bc029d99a698d88eeff60497cd3b) +++ src/ch/TSubTaskBase.h (.../TSubTaskBase.h) (revision d12e49decb8a3df3e28f6786d38542390484ac07) @@ -23,7 +23,7 @@ #ifndef __TSUBTASKBASE_H__ #define __TSUBTASKBASE_H__ -#include "FileInfo.h" +#include "../libchcore/FileInfo.h" class TSubTaskContext; class TBasePathDataContainer; @@ -54,7 +54,7 @@ protected: // some common operations - chcore::TSmartPath CalculateDestinationPath(const CFileInfoPtr& spFileInfo, chcore::TSmartPath strPath, int iFlags) const; + chcore::TSmartPath CalculateDestinationPath(const chcore::CFileInfoPtr& spFileInfo, chcore::TSmartPath strPath, int iFlags) const; chcore::TSmartPath FindFreeSubstituteName(chcore::TSmartPath pathSrcPath, chcore::TSmartPath pathDstPath) const; private: Index: src/ch/TSubTaskContext.cpp =================================================================== diff -u -N -rd345f15636dc88c4c40fe310ac7777bd024e12d9 -rd12e49decb8a3df3e28f6786d38542390484ac07 --- src/ch/TSubTaskContext.cpp (.../TSubTaskContext.cpp) (revision d345f15636dc88c4c40fe310ac7777bd024e12d9) +++ src/ch/TSubTaskContext.cpp (.../TSubTaskContext.cpp) (revision d12e49decb8a3df3e28f6786d38542390484ac07) @@ -23,7 +23,7 @@ #include "stdafx.h" #include "TSubTaskContext.h" -TSubTaskContext::TSubTaskContext(chcore::TTaskDefinition& rTaskDefinition, chcore::TBasePathDataContainer& rBasePathDataContainer, CFileInfoArray& rFilesCache, TTaskLocalStats& rTaskLocalStats, +TSubTaskContext::TSubTaskContext(chcore::TTaskDefinition& rTaskDefinition, chcore::TBasePathDataContainer& rBasePathDataContainer, chcore::CFileInfoArray& rFilesCache, TTaskLocalStats& rTaskLocalStats, TTaskBasicProgressInfo& rTaskBasicProgressInfo, TTaskConfigTracker& rCfgTracker, icpf::log_file& rLog, chcore::IFeedbackHandler* piFeedbackHandler, chcore::TWorkerThreadController& rThreadController, TLocalFilesystem& rfsLocal) : m_rTaskDefinition(rTaskDefinition), Index: src/ch/TSubTaskContext.h =================================================================== diff -u -N -rd345f15636dc88c4c40fe310ac7777bd024e12d9 -rd12e49decb8a3df3e28f6786d38542390484ac07 --- src/ch/TSubTaskContext.h (.../TSubTaskContext.h) (revision d345f15636dc88c4c40fe310ac7777bd024e12d9) +++ src/ch/TSubTaskContext.h (.../TSubTaskContext.h) (revision d12e49decb8a3df3e28f6786d38542390484ac07) @@ -23,7 +23,7 @@ #ifndef __TSUBTASKCONTEXT_H__ #define __TSUBTASKCONTEXT_H__ -#include "FileInfo.h" +#include "../libchcore/FileInfo.h" namespace chcore { @@ -44,7 +44,7 @@ class TSubTaskContext { public: - TSubTaskContext(chcore::TTaskDefinition& rTaskDefinition, chcore::TBasePathDataContainer& rBasePathDataContainer, CFileInfoArray& rFilesCache, TTaskLocalStats& rTaskLocalStats, + TSubTaskContext(chcore::TTaskDefinition& rTaskDefinition, chcore::TBasePathDataContainer& rBasePathDataContainer, chcore::CFileInfoArray& rFilesCache, TTaskLocalStats& rTaskLocalStats, TTaskBasicProgressInfo& rTaskBasicProgressInfo, TTaskConfigTracker& rCfgTracker, icpf::log_file& rLog, chcore::IFeedbackHandler* piFeedbackHandler, chcore::TWorkerThreadController& rThreadController, TLocalFilesystem& rfsLocal); ~TSubTaskContext(); @@ -55,8 +55,8 @@ chcore::TBasePathDataContainer& GetBasePathDataContainer() { return m_rBasePathDataContainer; } const chcore::TBasePathDataContainer& GetBasePathDataContainer() const { return m_rBasePathDataContainer; } - CFileInfoArray& GetFilesCache() { return m_rFilesCache; } - const CFileInfoArray& GetFilesCache() const { return m_rFilesCache; } + chcore::CFileInfoArray& GetFilesCache() { return m_rFilesCache; } + const chcore::CFileInfoArray& GetFilesCache() const { return m_rFilesCache; } TTaskLocalStats& GetTaskLocalStats() { return m_rTaskLocalStats; } const TTaskLocalStats& GetTaskLocalStats() const { return m_rTaskLocalStats; } @@ -86,7 +86,7 @@ chcore::TBasePathDataContainer& m_rBasePathDataContainer; // data on which to operate - CFileInfoArray& m_rFilesCache; + chcore::CFileInfoArray& m_rFilesCache; // local stats for task TTaskLocalStats& m_rTaskLocalStats; Index: src/ch/TSubTaskCopyMove.cpp =================================================================== diff -u -N -r6df9b4cff81dedf8c5571a98702b584b061eac09 -rd12e49decb8a3df3e28f6786d38542390484ac07 --- src/ch/TSubTaskCopyMove.cpp (.../TSubTaskCopyMove.cpp) (revision 6df9b4cff81dedf8c5571a98702b584b061eac09) +++ src/ch/TSubTaskCopyMove.cpp (.../TSubTaskCopyMove.cpp) (revision d12e49decb8a3df3e28f6786d38542390484ac07) @@ -34,7 +34,7 @@ struct CUSTOM_COPY_PARAMS { - CFileInfoPtr spSrcFile; // CFileInfo - src file + chcore::CFileInfoPtr spSrcFile; // CFileInfo - src file chcore::TSmartPath pathDstFile; // dest path with filename chcore::TDataBuffer dbBuffer; // buffer handling @@ -50,7 +50,7 @@ TSubTaskBase::ESubOperationResult TSubTaskCopyMove::Exec() { icpf::log_file& rLog = GetContext().GetLog(); - CFileInfoArray& rFilesCache = GetContext().GetFilesCache(); + chcore::CFileInfoArray& rFilesCache = GetContext().GetFilesCache(); chcore::TTaskDefinition& rTaskDefinition = GetContext().GetTaskDefinition(); TTaskConfigTracker& rCfgTracker = GetContext().GetCfgTracker(); TTaskBasicProgressInfo& rBasicProgressInfo = GetContext().GetTaskBasicProgressInfo(); @@ -128,7 +128,7 @@ } // update m_stNextIndex, getting current CFileInfo - CFileInfoPtr spFileInfo = rFilesCache.GetAt(rBasicProgressInfo.GetCurrentIndex()); + chcore::CFileInfoPtr spFileInfo = rFilesCache.GetAt(rBasicProgressInfo.GetCurrentIndex()); // set dest path with filename ccp.pathDstFile = CalculateDestinationPath(spFileInfo, rTaskDefinition.GetDestinationPath(), ((int)bForceDirectories) << 1 | (int)bIgnoreFolders); @@ -260,7 +260,7 @@ return TSubTaskBase::eSubResult_Continue; } -bool TSubTaskCopyMove::GetMove(const CFileInfoPtr& spFileInfo) +bool TSubTaskCopyMove::GetMove(const chcore::CFileInfoPtr& spFileInfo) { if(!spFileInfo) THROW(_T("Invalid pointer"), 0, 0, 0); @@ -276,7 +276,7 @@ return spPathData->GetMove(); } -int TSubTaskCopyMove::GetBufferIndex(const CFileInfoPtr& spFileInfo) +int TSubTaskCopyMove::GetBufferIndex(const chcore::CFileInfoPtr& spFileInfo) { if(!spFileInfo) THROW(_T("Invalid pointer"), 0, 0, 0); @@ -670,7 +670,7 @@ return TSubTaskBase::eSubResult_Continue; } -TSubTaskBase::ESubOperationResult TSubTaskCopyMove::OpenDestinationFileFB(TLocalFilesystemFile& fileDst, const chcore::TSmartPath& pathDstFile, bool bNoBuffering, const CFileInfoPtr& spSrcFileInfo, unsigned long long& ullSeekTo, bool& bFreshlyCreated) +TSubTaskBase::ESubOperationResult TSubTaskCopyMove::OpenDestinationFileFB(TLocalFilesystemFile& fileDst, const chcore::TSmartPath& pathDstFile, bool bNoBuffering, const chcore::CFileInfoPtr& spSrcFileInfo, unsigned long long& ullSeekTo, bool& bFreshlyCreated) { chcore::IFeedbackHandler* piFeedbackHandler = GetContext().GetFeedbackHandler(); icpf::log_file& rLog = GetContext().GetLog(); @@ -703,7 +703,7 @@ // NOTE: it is not known which one would be faster - reading file parameters // by using spDstFileInfo->Create() (which uses FindFirstFile()) or by // reading parameters using opened handle; need to be tested in the future - CFileInfoPtr spDstFileInfo(boost::make_shared()); + chcore::CFileInfoPtr spDstFileInfo(boost::make_shared()); if(!TLocalFilesystem::GetFileInfo(pathDstFile, spDstFileInfo)) THROW(_T("Cannot get information about file which has already been opened!"), 0, GetLastError(), 0); Index: src/ch/TSubTaskCopyMove.h =================================================================== diff -u -N -r6df9b4cff81dedf8c5571a98702b584b061eac09 -rd12e49decb8a3df3e28f6786d38542390484ac07 --- src/ch/TSubTaskCopyMove.h (.../TSubTaskCopyMove.h) (revision 6df9b4cff81dedf8c5571a98702b584b061eac09) +++ src/ch/TSubTaskCopyMove.h (.../TSubTaskCopyMove.h) (revision d12e49decb8a3df3e28f6786d38542390484ac07) @@ -28,6 +28,7 @@ namespace chcore { class TDataBuffer; + typedef boost::shared_ptr CFileInfoPtr; } struct CUSTOM_COPY_PARAMS; @@ -41,13 +42,13 @@ ESubOperationResult Exec(); private: - bool GetMove(const CFileInfoPtr& spFileInfo); - int GetBufferIndex(const CFileInfoPtr& spFileInfo); + bool GetMove(const chcore::CFileInfoPtr& spFileInfo); + int GetBufferIndex(const chcore::CFileInfoPtr& spFileInfo); ESubOperationResult CustomCopyFileFB(CUSTOM_COPY_PARAMS* pData); ESubOperationResult OpenSourceFileFB(TLocalFilesystemFile& fileSrc, const chcore::TSmartPath& spPathToOpen, bool bNoBuffering); - ESubOperationResult OpenDestinationFileFB(TLocalFilesystemFile& fileDst, const chcore::TSmartPath& pathDstFile, bool bNoBuffering, const CFileInfoPtr& spSrcFileInfo, unsigned long long& ullSeekTo, bool& bFreshlyCreated); + ESubOperationResult OpenDestinationFileFB(TLocalFilesystemFile& fileDst, const chcore::TSmartPath& pathDstFile, bool bNoBuffering, const chcore::CFileInfoPtr& spSrcFileInfo, unsigned long long& ullSeekTo, bool& bFreshlyCreated); ESubOperationResult OpenExistingDestinationFileFB(TLocalFilesystemFile& fileDst, const chcore::TSmartPath& pathDstFilePath, bool bNoBuffering); ESubOperationResult SetFilePointerFB(TLocalFilesystemFile& file, long long llDistance, const chcore::TSmartPath& pathFile, bool& bSkip); Index: src/ch/TSubTaskDelete.cpp =================================================================== diff -u -N -rab32897e61cc637a1e28d9dc3f0489b8d16a429c -rd12e49decb8a3df3e28f6786d38542390484ac07 --- src/ch/TSubTaskDelete.cpp (.../TSubTaskDelete.cpp) (revision ab32897e61cc637a1e28d9dc3f0489b8d16a429c) +++ src/ch/TSubTaskDelete.cpp (.../TSubTaskDelete.cpp) (revision d12e49decb8a3df3e28f6786d38542390484ac07) @@ -39,7 +39,7 @@ { // log icpf::log_file& rLog = GetContext().GetLog(); - CFileInfoArray& rFilesCache = GetContext().GetFilesCache(); + chcore::CFileInfoArray& rFilesCache = GetContext().GetFilesCache(); chcore::TTaskDefinition& rTaskDefinition = GetContext().GetTaskDefinition(); TTaskBasicProgressInfo& rBasicProgressInfo = GetContext().GetTaskBasicProgressInfo(); chcore::TWorkerThreadController& rThreadController = GetContext().GetThreadController(); @@ -50,7 +50,7 @@ // current processed path BOOL bSuccess; - CFileInfoPtr spFileInfo; + chcore::CFileInfoPtr spFileInfo; ictranslate::CFormat fmt; // index points to 0 or next item to process Index: src/ch/TSubTaskScanDirectory.cpp =================================================================== diff -u -N -rd345f15636dc88c4c40fe310ac7777bd024e12d9 -rd12e49decb8a3df3e28f6786d38542390484ac07 --- src/ch/TSubTaskScanDirectory.cpp (.../TSubTaskScanDirectory.cpp) (revision d345f15636dc88c4c40fe310ac7777bd024e12d9) +++ src/ch/TSubTaskScanDirectory.cpp (.../TSubTaskScanDirectory.cpp) (revision d12e49decb8a3df3e28f6786d38542390484ac07) @@ -45,7 +45,7 @@ { // log icpf::log_file& rLog = GetContext().GetLog(); - CFileInfoArray& rFilesCache = GetContext().GetFilesCache(); + chcore::CFileInfoArray& rFilesCache = GetContext().GetFilesCache(); chcore::TTaskDefinition& rTaskDefinition = GetContext().GetTaskDefinition(); chcore::IFeedbackHandler* piFeedbackHandler = GetContext().GetFeedbackHandler(); const chcore::TBasePathDataContainer& rarrSourcePathsInfo = GetContext().GetBasePathDataContainer(); @@ -62,7 +62,7 @@ rFilesCache.Clear(); // read filtering options - CFiltersArray afFilters; + chcore::CFiltersArray afFilters; GetTaskPropValue(rTaskDefinition.GetConfiguration(), afFilters); // enter some data to rFilesCache @@ -80,11 +80,11 @@ size_t stSize = rTaskDefinition.GetSourcePathCount(); for(size_t stIndex = 0; stIndex < stSize ; stIndex++) { - CFileInfoPtr spFileInfo; + chcore::CFileInfoPtr spFileInfo; bSkipInputPath = false; - spFileInfo.reset(new CFileInfo()); + spFileInfo.reset(new chcore::CFileInfo()); // try to get some info about the input path; let user know if the path does not exist. do @@ -218,14 +218,14 @@ return eSubResult_Continue; } -int TSubTaskScanDirectories::ScanDirectory(chcore::TSmartPath pathDirName, size_t stSrcIndex, bool bRecurse, bool bIncludeDirs, CFiltersArray& afFilters) +int TSubTaskScanDirectories::ScanDirectory(chcore::TSmartPath pathDirName, size_t stSrcIndex, bool bRecurse, bool bIncludeDirs, chcore::CFiltersArray& afFilters) { - CFileInfoArray& rFilesCache = GetContext().GetFilesCache(); + chcore::CFileInfoArray& rFilesCache = GetContext().GetFilesCache(); chcore::TTaskDefinition& rTaskDefinition = GetContext().GetTaskDefinition(); chcore::TWorkerThreadController& rThreadController = GetContext().GetThreadController(); TLocalFilesystemFind finder = TLocalFilesystem::CreateFinderObject(pathDirName, chcore::PathFromString(_T("*"))); - CFileInfoPtr spFileInfo(boost::make_shared()); + chcore::CFileInfoPtr spFileInfo(boost::make_shared()); while(finder.FindNext(spFileInfo)) { @@ -238,7 +238,7 @@ { spFileInfo->SetParentObject(stSrcIndex, &rTaskDefinition.GetSourcePaths()); rFilesCache.AddFileInfo(spFileInfo); - spFileInfo = boost::make_shared(); + spFileInfo = boost::make_shared(); } } else @@ -248,7 +248,7 @@ { spFileInfo->SetParentObject(stSrcIndex, &rTaskDefinition.GetSourcePaths()); rFilesCache.AddFileInfo(spFileInfo); - spFileInfo = boost::make_shared(); + spFileInfo = boost::make_shared(); } if(bRecurse) Index: src/ch/TSubTaskScanDirectory.h =================================================================== diff -u -N -r8c87d4185fbe5b952c49f72afcfd5f9fca338fb4 -rd12e49decb8a3df3e28f6786d38542390484ac07 --- src/ch/TSubTaskScanDirectory.h (.../TSubTaskScanDirectory.h) (revision 8c87d4185fbe5b952c49f72afcfd5f9fca338fb4) +++ src/ch/TSubTaskScanDirectory.h (.../TSubTaskScanDirectory.h) (revision d12e49decb8a3df3e28f6786d38542390484ac07) @@ -25,7 +25,7 @@ #include "TSubTaskBase.h" #include "../libchcore/TPath.h" -#include "FileFilter.h" +#include "../libchcore/FileFilter.h" /////////////////////////////////////////////////////////////////////////// // TSubTaskScanDirectories @@ -39,7 +39,7 @@ virtual ESubOperationResult Exec(); private: - int ScanDirectory(chcore::TSmartPath pathDirName, size_t stSrcIndex, bool bRecurse, bool bIncludeDirs, CFiltersArray& afFilters); + int ScanDirectory(chcore::TSmartPath pathDirName, size_t stSrcIndex, bool bRecurse, bool bIncludeDirs, chcore::CFiltersArray& afFilters); }; #endif Index: src/ch/TTaskConfiguration.h =================================================================== diff -u -N -rb684bec49aaaea4b89ab2e599497f4085d8698a3 -rd12e49decb8a3df3e28f6786d38542390484ac07 --- src/ch/TTaskConfiguration.h (.../TTaskConfiguration.h) (revision b684bec49aaaea4b89ab2e599497f4085d8698a3) +++ src/ch/TTaskConfiguration.h (.../TTaskConfiguration.h) (revision d12e49decb8a3df3e28f6786d38542390484ac07) @@ -24,7 +24,7 @@ #define __TTASKCONFIGURATION_H__ #include "../libchcore/TConfig.h" -#include "FileFilter.h" +#include "../libchcore/FileFilter.h" enum ETaskOptions { @@ -116,7 +116,7 @@ TASK_PROPERTY(eTO_CreateDirectoriesRelativeToRoot, bool, _T("Operation.CreateDirectoriesRelativeToRoot"), false); TASK_PROPERTY(eTO_IgnoreDirectories, bool, _T("Operation.IgnoreDirectories"), false); -TASK_PROPERTY(eTO_Filters, CFiltersArray, _T("Operation.Filtering"), CFiltersArray()); +TASK_PROPERTY(eTO_Filters, chcore::CFiltersArray, _T("Operation.Filtering"), chcore::CFiltersArray()); // Naming settings TASK_PROPERTY(eTO_AlternateFilenameFormatString_First, CString, _T("Naming.AlternateFilenameFormatFirst"), _T("Copy of %name")); Index: src/ch/ch.vc90.vcproj =================================================================== diff -u -N -r6df9b4cff81dedf8c5571a98702b584b061eac09 -rd12e49decb8a3df3e28f6786d38542390484ac07 --- src/ch/ch.vc90.vcproj (.../ch.vc90.vcproj) (revision 6df9b4cff81dedf8c5571a98702b584b061eac09) +++ src/ch/ch.vc90.vcproj (.../ch.vc90.vcproj) (revision d12e49decb8a3df3e28f6786d38542390484ac07) @@ -419,22 +419,6 @@ > - - - - - - - - Index: src/ch/task.h =================================================================== diff -u -N -r6df9b4cff81dedf8c5571a98702b584b061eac09 -rd12e49decb8a3df3e28f6786d38542390484ac07 --- src/ch/task.h (.../task.h) (revision 6df9b4cff81dedf8c5571a98702b584b061eac09) +++ src/ch/task.h (.../task.h) (revision d12e49decb8a3df3e28f6786d38542390484ac07) @@ -21,10 +21,10 @@ #include "TAutoHandles.h" #include "../libchcore/TWorkerThreadController.h" -#include "FileInfo.h" +#include "../libchcore/FileInfo.h" #include "../libchcore/DataBuffer.h" #include "../libchcore/FeedbackHandlerBase.h" -#include "FileFilter.h" +#include "../libchcore/FileFilter.h" #include "../libchcore/TTaskDefinition.h" #include "TTaskConfigTracker.h" #include "../libchcore/TBasePathData.h" @@ -64,7 +64,7 @@ size_t m_stSize; chcore::TSmartPath m_pathDstPath; - CFiltersArray* m_pafFilters; + chcore::CFiltersArray* m_pafFilters; ETaskCurrentState m_eTaskState; chcore::EOperationType m_eOperationType; @@ -214,7 +214,7 @@ // current task state (derivatives of the task initial information) // changing slowly or only partially - CFileInfoArray m_files; // list of files/directories found during operating on the task input data (filled by search for files) + chcore::CFileInfoArray m_files; // list of files/directories found during operating on the task input data (filled by search for files) // changing fast volatile ETaskCurrentState m_eCurrentState; // current state of processing this task represents @@ -225,7 +225,7 @@ TTaskLocalStats m_localStats; // local statistics // task settings - CFiltersArray m_afFilters; // filtering settings for files (will be filtered according to the rules inside when searching for files) + chcore::CFiltersArray m_afFilters; // filtering settings for files (will be filtered according to the rules inside when searching for files) bool m_bForce; // if the continuation of tasks should be independent of max concurrently running task limit bool m_bContinue; // allows task to continue Index: src/libchcore/FileFilter.cpp =================================================================== diff -u -N --- src/libchcore/FileFilter.cpp (revision 0) +++ src/libchcore/FileFilter.cpp (revision d12e49decb8a3df3e28f6786d38542390484ac07) @@ -0,0 +1,744 @@ +/*************************************************************************** +* Copyright (C) 2001-2008 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 "FileInfo.h" +#include "FileFilter.h" +#include "TConfig.h" +#include "TBinarySerializer.h" +#include "SerializationHelpers.h" + +BEGIN_CHCORE_NAMESPACE + +//////////////////////////////////////////////////////////////////////////// +bool _tcicmp(TCHAR c1, TCHAR c2) +{ + TCHAR ch1[2]={c1, 0}, ch2[2]={c2, 0}; + return (_tcsicmp(ch1, ch2) == 0); +} + +CFileFilter::CFileFilter() +{ + // files mask + m_bUseMask=false; + m_astrMask.Clear(); + + m_bUseExcludeMask=false; + m_astrExcludeMask.Clear(); + + // size filtering + m_bUseSize1=false; + m_eSizeCmpType1=eSizeCmp_Greater; + m_ullSize1=0; + m_bUseSize2=false; + m_eSizeCmpType2=eSizeCmp_Less; + m_ullSize2=0; + + // date filtering + m_bUseDateTime1=false; + m_eDateType = eDateType_Created; + m_eDateCmpType1 = eDateCmp_Greater; + m_bUseDate1=false; + m_tDate1=CTime::GetCurrentTime(); + m_bUseTime1=false; + m_tTime1=CTime::GetCurrentTime(); + + m_bUseDateTime2=false; + m_eDateCmpType2 = eDateCmp_Less; + m_bUseDate2=false; + m_tDate2=CTime::GetCurrentTime(); + m_bUseTime2=false; + m_tTime2=CTime::GetCurrentTime(); + + // attribute filtering + m_bUseAttributes=false; + m_iArchive=2; + m_iReadOnly=2; + m_iHidden=2; + m_iSystem=2; + m_iDirectory=2; +} + +CFileFilter::CFileFilter(const CFileFilter& rFilter) +{ + *this=rFilter; +} + +CFileFilter& CFileFilter::operator=(const CFileFilter& rFilter) +{ + // files mask + m_bUseMask=rFilter.m_bUseMask; + m_astrMask = rFilter.m_astrMask; + + m_bUseExcludeMask=rFilter.m_bUseExcludeMask; + m_astrExcludeMask = rFilter.m_astrExcludeMask; + + // size filtering + m_bUseSize1=rFilter.m_bUseSize1; + m_eSizeCmpType1=rFilter.m_eSizeCmpType1; + m_ullSize1=rFilter.m_ullSize1; + m_bUseSize2=rFilter.m_bUseSize2; + m_eSizeCmpType2=rFilter.m_eSizeCmpType2; + m_ullSize2=rFilter.m_ullSize2; + + // date filtering + m_bUseDateTime1=rFilter.m_bUseDateTime1; + m_eDateType=rFilter.m_eDateType; + m_eDateCmpType1=rFilter.m_eDateCmpType1; + m_bUseDate1=rFilter.m_bUseDate1; + m_tDate1=rFilter.m_tDate1; + m_bUseTime1=rFilter.m_bUseTime1; + m_tTime1=rFilter.m_tTime1; + + m_bUseDateTime2=rFilter.m_bUseDateTime2; + m_eDateCmpType2=rFilter.m_eDateCmpType2; + m_bUseDate2=rFilter.m_bUseDate2; + m_tDate2=rFilter.m_tDate2; + m_bUseTime2=rFilter.m_bUseTime2; + m_tTime2=rFilter.m_tTime2; + + // attribute filtering + m_bUseAttributes=rFilter.m_bUseAttributes; + m_iArchive=rFilter.m_iArchive; + m_iReadOnly=rFilter.m_iReadOnly; + m_iHidden=rFilter.m_iHidden; + m_iSystem=rFilter.m_iSystem; + m_iDirectory=rFilter.m_iDirectory; + + return *this; +} + +chcore::TString& CFileFilter::GetCombinedMask(chcore::TString& strMask) const +{ + strMask.Clear(); + size_t stCount = m_astrMask.GetCount(); + if(stCount > 0) + { + strMask = m_astrMask.GetAt(0); + for(size_t stIndex = 1; stIndex < stCount; stIndex++) + { + strMask += _T("|") + m_astrMask.GetAt(stIndex); + } + } + + return strMask; +} + +void CFileFilter::SetCombinedMask(const chcore::TString& pMask) +{ + m_astrMask.Clear(); + + pMask.Split(_T("|"), m_astrMask); +} + +chcore::TString& CFileFilter::GetCombinedExcludeMask(chcore::TString& strMask) const +{ + strMask.Clear(); + size_t stCount = m_astrExcludeMask.GetCount(); + if(stCount > 0) + { + strMask = m_astrExcludeMask.GetAt(0); + for(size_t stIndex = 1; stIndex < stCount; stIndex++) + { + strMask += _T("|") + m_astrExcludeMask.GetAt(stIndex); + } + } + + return strMask; +} + +void CFileFilter::SetCombinedExcludeMask(const chcore::TString& pMask) +{ + m_astrExcludeMask.Clear(); + + pMask.Split(_T("|"), m_astrExcludeMask); +} + +void CFileFilter::StoreInConfig(chcore::TConfig& rConfig) const +{ + SetConfigValue(rConfig, _T("IncludeMask.Use"), m_bUseMask); + SetConfigValue(rConfig, _T("IncludeMask.MaskList.Mask"), m_astrMask); + + SetConfigValue(rConfig, _T("ExcludeMask.Use"), m_bUseExcludeMask); + SetConfigValue(rConfig, _T("ExcludeMask.MaskList.Mask"), m_astrExcludeMask); + + SetConfigValue(rConfig, _T("SizeA.Use"), m_bUseSize1); + SetConfigValue(rConfig, _T("SizeA.FilteringType"), m_eSizeCmpType1); + SetConfigValue(rConfig, _T("SizeA.Value"), m_ullSize1); + SetConfigValue(rConfig, _T("SizeB.Use"), m_bUseSize2); + SetConfigValue(rConfig, _T("SizeB.FilteringType"), m_eSizeCmpType2); + SetConfigValue(rConfig, _T("SizeB.Value"), m_ullSize2); + + SetConfigValue(rConfig, _T("DateA.Use"), m_bUseDateTime1); + SetConfigValue(rConfig, _T("DateA.Type"), m_eDateType); // created/last modified/last accessed + SetConfigValue(rConfig, _T("DateA.FilteringType"), m_eDateCmpType1); // before/after + SetConfigValue(rConfig, _T("DateA.EnableDatePart"), m_bUseDate1); + SetConfigValue(rConfig, _T("DateA.DateValue"), m_tDate1.GetTime()); + SetConfigValue(rConfig, _T("DateA.EnableTimePart"), m_bUseTime1); + SetConfigValue(rConfig, _T("DateA.TimeValue"), m_tTime1.GetTime()); + + SetConfigValue(rConfig, _T("DateB.Type"), m_bUseDateTime2); + SetConfigValue(rConfig, _T("DateB.FilteringType"), m_eDateCmpType2); + SetConfigValue(rConfig, _T("DateB.EnableDatePart"), m_bUseDate2); + SetConfigValue(rConfig, _T("DateB.DateValue"), m_tDate2.GetTime()); + SetConfigValue(rConfig, _T("DateB.EnableTimePart"), m_bUseTime2); + SetConfigValue(rConfig, _T("DateB.TimeValue"), m_tTime2.GetTime()); + + SetConfigValue(rConfig, _T("Attributes.Use"), m_bUseAttributes); + SetConfigValue(rConfig, _T("Attributes.Archive"), m_iArchive); + SetConfigValue(rConfig, _T("Attributes.ReadOnly"), m_iReadOnly); + SetConfigValue(rConfig, _T("Attributes.Hidden"), m_iHidden); + SetConfigValue(rConfig, _T("Attributes.System"), m_iSystem); + SetConfigValue(rConfig, _T("Attributes.Directory"), m_iDirectory); +} + +void CFileFilter::ReadFromConfig(const chcore::TConfig& rConfig) +{ + __time64_t tTime = 0; + + if(!GetConfigValue(rConfig, _T("IncludeMask.Use"), m_bUseMask)) + m_bUseMask = false; + + m_astrMask.Clear(); + GetConfigValue(rConfig, _T("IncludeMask.MaskList.Mask"), m_astrMask); + + if(!GetConfigValue(rConfig, _T("ExcludeMask.Use"), m_bUseExcludeMask)) + m_bUseExcludeMask = false; + + m_astrExcludeMask.Clear(); + GetConfigValue(rConfig, _T("ExcludeMask.MaskList.Mask"), m_astrExcludeMask); + + if(!GetConfigValue(rConfig, _T("SizeA.Use"), m_bUseSize1)) + m_bUseSize1 = false; + if(!GetConfigValue(rConfig, _T("SizeA.FilteringType"), *(int*)m_eSizeCmpType1)) + m_eSizeCmpType1 = eSizeCmp_Equal; + if(!GetConfigValue(rConfig, _T("SizeA.Value"), m_ullSize1)) + m_ullSize1 = 0; + if(!GetConfigValue(rConfig, _T("SizeB.Use"), m_bUseSize2)) + m_bUseSize2 = false; + if(!GetConfigValue(rConfig, _T("SizeB.FilteringType"), *(int*)m_eSizeCmpType2)) + m_eSizeCmpType2 = eSizeCmp_Equal; + if(!GetConfigValue(rConfig, _T("SizeB.Value"), m_ullSize2)) + m_ullSize2 = 0; + + if(!GetConfigValue(rConfig, _T("DateA.Use"), m_bUseDateTime1)) + m_bUseDateTime1 = false; + + if(!GetConfigValue(rConfig, _T("DateA.Type"), *(int*)m_eDateType)) // created/last modified/last accessed + m_eDateType = eDateType_Created; + if(!GetConfigValue(rConfig, _T("DateA.FilteringType"), *(int*)m_eDateCmpType1)) // before/after + m_eDateCmpType1 = eDateCmp_Equal; + if(!GetConfigValue(rConfig, _T("DateA.EnableDatePart"), m_bUseDate1)) + m_bUseDate1 = false; + + if(!GetConfigValue(rConfig, _T("DateA.DateValue"), tTime)) + tTime = 0; + m_tDate1 = tTime; + + if(!GetConfigValue(rConfig, _T("DateA.EnableTimePart"), m_bUseTime1)) + m_bUseTime1 = false; + + if(!GetConfigValue(rConfig, _T("DateA.TimeValue"), tTime)) + tTime = 0; + m_tTime1 = tTime; + + if(!GetConfigValue(rConfig, _T("DateB.Type"), m_bUseDateTime2)) + m_bUseDateTime2 = false; + if(!GetConfigValue(rConfig, _T("DateB.FilteringType"), *(int*)m_eDateCmpType2)) + m_eDateCmpType2 = eDateCmp_Equal; + if(!GetConfigValue(rConfig, _T("DateB.EnableDatePart"), m_bUseDate2)) + m_bUseDate2 = false; + + if(!GetConfigValue(rConfig, _T("DateB.DateValue"), tTime)) + tTime = 0; + m_tDate2 = tTime; + if(!GetConfigValue(rConfig, _T("DateB.EnableTimePart"), m_bUseTime2)) + m_bUseTime2 = false; + if(!GetConfigValue(rConfig, _T("DateB.TimeValue"), tTime)) + tTime = 0; + m_tTime2 = tTime; + + if(!GetConfigValue(rConfig, _T("Attributes.Use"), m_bUseAttributes)) + m_bUseAttributes = false; + if(!GetConfigValue(rConfig, _T("Attributes.Archive"), m_iArchive)) + m_iArchive = 0; + if(!GetConfigValue(rConfig, _T("Attributes.ReadOnly"), m_iReadOnly)) + m_iReadOnly = false; + if(!GetConfigValue(rConfig, _T("Attributes.Hidden"), m_iHidden)) + m_iHidden = 0; + if(!GetConfigValue(rConfig, _T("Attributes.System"), m_iSystem)) + m_iSystem = 0; + if(!GetConfigValue(rConfig, _T("Attributes.Directory"), m_iDirectory)) + m_iDirectory = 0; +} + +void CFileFilter::Serialize(chcore::TReadBinarySerializer& rSerializer) +{ + using chcore::Serializers::Serialize; + + Serialize(rSerializer, m_bUseMask); + Serialize(rSerializer, m_astrMask); + + Serialize(rSerializer, m_bUseExcludeMask); + Serialize(rSerializer, m_astrExcludeMask); + + Serialize(rSerializer, m_bUseSize1); + Serialize(rSerializer, m_eSizeCmpType1); + Serialize(rSerializer, m_ullSize1); + Serialize(rSerializer, m_bUseSize2); + Serialize(rSerializer, m_eSizeCmpType2); + Serialize(rSerializer, m_ullSize2); + + Serialize(rSerializer, m_bUseDateTime1); + Serialize(rSerializer, m_eDateType); // created/last modified/last accessed + Serialize(rSerializer, m_eDateCmpType1); // before/after + Serialize(rSerializer, m_bUseDate1); + Serialize(rSerializer, m_tDate1); + Serialize(rSerializer, m_bUseTime1); + Serialize(rSerializer, m_tTime1); + + Serialize(rSerializer, m_bUseDateTime2); + Serialize(rSerializer, m_eDateCmpType2); + Serialize(rSerializer, m_bUseDate2); + Serialize(rSerializer, m_tDate2); + Serialize(rSerializer, m_bUseTime2); + Serialize(rSerializer, m_tTime2); + + Serialize(rSerializer, m_bUseAttributes); + Serialize(rSerializer, m_iArchive); + Serialize(rSerializer, m_iReadOnly); + Serialize(rSerializer, m_iHidden); + Serialize(rSerializer, m_iSystem); + Serialize(rSerializer, m_iDirectory); +} + +void CFileFilter::Serialize(chcore::TWriteBinarySerializer& rSerializer) const +{ + using chcore::Serializers::Serialize; + + Serialize(rSerializer, m_bUseMask); + Serialize(rSerializer, m_astrMask); + + Serialize(rSerializer, m_bUseExcludeMask); + Serialize(rSerializer, m_astrExcludeMask); + + Serialize(rSerializer, m_bUseSize1); + Serialize(rSerializer, m_eSizeCmpType1); + Serialize(rSerializer, m_ullSize1); + Serialize(rSerializer, m_bUseSize2); + Serialize(rSerializer, m_eSizeCmpType2); + Serialize(rSerializer, m_ullSize2); + + Serialize(rSerializer, m_bUseDateTime1); + Serialize(rSerializer, m_eDateType); // created/last modified/last accessed + Serialize(rSerializer, m_eDateCmpType1); // before/after + Serialize(rSerializer, m_bUseDate1); + Serialize(rSerializer, m_tDate1); + Serialize(rSerializer, m_bUseTime1); + Serialize(rSerializer, m_tTime1); + + Serialize(rSerializer, m_bUseDateTime2); + Serialize(rSerializer, m_eDateCmpType2); + Serialize(rSerializer, m_bUseDate2); + Serialize(rSerializer, m_tDate2); + Serialize(rSerializer, m_bUseTime2); + Serialize(rSerializer, m_tTime2); + + Serialize(rSerializer, m_bUseAttributes); + Serialize(rSerializer, m_iArchive); + Serialize(rSerializer, m_iReadOnly); + Serialize(rSerializer, m_iHidden); + Serialize(rSerializer, m_iSystem); + Serialize(rSerializer, m_iDirectory); +} + +bool CFileFilter::Match(const CFileInfoPtr& spInfo) const +{ + // check by mask + if(m_bUseMask) + { + bool bRes=false; + for(chcore::TStringArray::const_iterator iterMask = m_astrMask.Begin(); iterMask != m_astrMask.End(); ++iterMask) + { + if(MatchMask(*iterMask, spInfo->GetFullFilePath().GetFileName().ToString())) + bRes = true; + } + if(!bRes) + return false; + } + + // excluding mask + if(m_bUseExcludeMask) + { + for(chcore::TStringArray::const_iterator iterExcludeMask = m_astrExcludeMask.Begin(); iterExcludeMask != m_astrExcludeMask.End(); ++iterExcludeMask) + { + if(MatchMask(*iterExcludeMask, spInfo->GetFullFilePath().GetFileName().ToString())) + return false; + } + } + + // by size + if (m_bUseSize1) + { + switch (m_eSizeCmpType1) + { + case eSizeCmp_Less: + if (m_ullSize1 <= spInfo->GetLength64()) + return false; + break; + case eSizeCmp_LessOrEqual: + if (m_ullSize1 < spInfo->GetLength64()) + return false; + break; + case eSizeCmp_Equal: + if (m_ullSize1 != spInfo->GetLength64()) + return false; + break; + case eSizeCmp_GreaterOrEqual: + if (m_ullSize1 > spInfo->GetLength64()) + return false; + break; + case eSizeCmp_Greater: + if (m_ullSize1 >= spInfo->GetLength64()) + return false; + break; + } + + // second part + if (m_bUseSize2) + { + switch (m_eSizeCmpType2) + { + case eSizeCmp_Less: + if (m_ullSize2 <= spInfo->GetLength64()) + return false; + break; + case eSizeCmp_LessOrEqual: + if (m_ullSize2 < spInfo->GetLength64()) + return false; + break; + case eSizeCmp_Equal: + if (m_ullSize2 != spInfo->GetLength64()) + return false; + break; + case eSizeCmp_GreaterOrEqual: + if (m_ullSize2 > spInfo->GetLength64()) + return false; + break; + case eSizeCmp_Greater: + if (m_ullSize2 >= spInfo->GetLength64()) + return false; + break; + } + } + } + + // date - get the time from rInfo + if (m_bUseDateTime1) + { + ATL::CTime tm; + switch (m_eDateType) + { + case eDateType_Created: + tm=spInfo->GetCreationTime(); + break; + case eDateType_Modified: + tm=spInfo->GetLastWriteTime(); + break; + case eDateType_LastAccessed: + tm=spInfo->GetLastAccessTime(); + break; + } + + // counting... + unsigned long ulInfo=0, ulCheck=0; + if (m_bUseDate1) + { + ulInfo=(tm.GetYear()-1970)*32140800+tm.GetMonth()*2678400+tm.GetDay()*86400; + ulCheck=(m_tDate1.GetYear()-1970)*32140800+m_tDate1.GetMonth()*2678400+m_tDate1.GetDay()*86400; + } + + if (m_bUseTime1) + { + ulInfo+=tm.GetHour()*3600+tm.GetMinute()*60+tm.GetSecond(); + ulCheck+=m_tTime1.GetHour()*3600+m_tTime1.GetMinute()*60+m_tTime1.GetSecond(); + } + + // ... and comparing + switch (m_eDateCmpType1) + { + case eDateCmp_Less: + if (ulInfo >= ulCheck) + return false; + break; + case eDateCmp_LessOrEqual: + if (ulInfo > ulCheck) + return false; + break; + case eDateCmp_Equal: + if (ulInfo != ulCheck) + return false; + break; + case eDateCmp_GreaterOrEqual: + if (ulInfo < ulCheck) + return false; + break; + case eDateCmp_Greater: + if (ulInfo <= ulCheck) + return false; + break; + } + + if (m_bUseDateTime2) + { + // counting... + ulInfo=0, ulCheck=0; + if (m_bUseDate2) + { + ulInfo=(tm.GetYear()-1970)*32140800+tm.GetMonth()*2678400+tm.GetDay()*86400; + ulCheck=(m_tDate2.GetYear()-1970)*32140800+m_tDate2.GetMonth()*2678400+m_tDate2.GetDay()*86400; + } + + if (m_bUseTime2) + { + ulInfo+=tm.GetHour()*3600+tm.GetMinute()*60+tm.GetSecond(); + ulCheck+=m_tTime2.GetHour()*3600+m_tTime2.GetMinute()*60+m_tTime2.GetSecond(); + } + + // ... comparing + switch (m_eDateCmpType2) + { + case eDateCmp_Less: + if (ulInfo >= ulCheck) + return false; + break; + case eDateCmp_LessOrEqual: + if (ulInfo > ulCheck) + return false; + break; + case eDateCmp_Equal: + if (ulInfo != ulCheck) + return false; + break; + case eDateCmp_GreaterOrEqual: + if (ulInfo < ulCheck) + return false; + break; + case eDateCmp_Greater: + if (ulInfo <= ulCheck) + return false; + break; + } + } + } // of m_bUseDate + + // attributes + if (m_bUseAttributes) + { + if ( (m_iArchive == 1 && !spInfo->IsArchived()) || (m_iArchive == 0 && spInfo->IsArchived())) + return false; + if ( (m_iReadOnly == 1 && !spInfo->IsReadOnly()) || (m_iReadOnly == 0 && spInfo->IsReadOnly())) + return false; + if ( (m_iHidden == 1 && !spInfo->IsHidden()) || (m_iHidden == 0 && spInfo->IsHidden())) + return false; + if ( (m_iSystem == 1 && !spInfo->IsSystem()) || (m_iSystem == 0 && spInfo->IsSystem())) + return false; + if ( (m_iDirectory == 1 && !spInfo->IsDirectory()) || (m_iDirectory == 0 && spInfo->IsDirectory())) + return false; + } + + return true; +} + +bool CFileFilter::MatchMask(LPCTSTR lpszMask, LPCTSTR lpszString) const +{ + bool bMatch = 1; + + //iterate and delete '?' and '*' one by one + while(*lpszMask != _T('\0') && bMatch && *lpszString != _T('\0')) + { + if (*lpszMask == _T('?')) lpszString++; + else if (*lpszMask == _T('*')) + { + bMatch = Scan(lpszMask, lpszString); + lpszMask--; + } + else + { + bMatch = _tcicmp(*lpszMask, *lpszString); + lpszString++; + } + lpszMask++; + } + while (*lpszMask == _T('*') && bMatch) lpszMask++; + + return bMatch && *lpszString == _T('\0') && *lpszMask == _T('\0'); +} + +// scan '?' and '*' +bool CFileFilter::Scan(LPCTSTR& lpszMask, LPCTSTR& lpszString) const +{ + // remove the '?' and '*' + for(lpszMask++; *lpszString != _T('\0') && (*lpszMask == _T('?') || *lpszMask == _T('*')); lpszMask++) + if (*lpszMask == _T('?')) lpszString++; + while ( *lpszMask == _T('*')) lpszMask++; + + // if lpszString is empty and lpszMask has more characters or, + // lpszMask is empty, return + if (*lpszString == _T('\0') && *lpszMask != _T('\0')) return false; + if (*lpszString == _T('\0') && *lpszMask == _T('\0')) return true; + // else search substring + else + { + LPCTSTR wdsCopy = lpszMask; + LPCTSTR lpszStringCopy = lpszString; + bool bMatch = true; + do + { + if (!MatchMask(lpszMask, lpszString)) lpszStringCopy++; + lpszMask = wdsCopy; + lpszString = lpszStringCopy; + while (!(_tcicmp(*lpszMask, *lpszString)) && (*lpszString != '\0')) lpszString++; + wdsCopy = lpszMask; + lpszStringCopy = lpszString; + } + while ((*lpszString != _T('\0')) ? !MatchMask(lpszMask, lpszString) : (bMatch = false) != false); + + if (*lpszString == _T('\0') && *lpszMask == _T('\0')) return true; + + return bMatch; + } +} + +CFiltersArray& CFiltersArray::operator=(const CFiltersArray& rSrc) +{ + if(this != &rSrc) + { + m_vFilters = rSrc.m_vFilters; + } + + return *this; +} + +bool CFiltersArray::Match(const CFileInfoPtr& spInfo) const +{ + if(m_vFilters.empty()) + return true; + + // if only one of the filters matches - return true + for(std::vector::const_iterator iterFilter = m_vFilters.begin(); iterFilter != m_vFilters.end(); iterFilter++) + { + if((*iterFilter).Match(spInfo)) + return true; + } + + return false; +} + +void CFiltersArray::StoreInConfig(chcore::TConfig& rConfig, PCTSTR pszNodeName) const +{ + rConfig.DeleteNode(pszNodeName); + BOOST_FOREACH(const CFileFilter& rFilter, m_vFilters) + { + chcore::TConfig cfgNode; + rFilter.StoreInConfig(cfgNode); + rConfig.AddSubConfig(chcore::TString(pszNodeName) + _T(".FilterDefinition"), cfgNode); + } +} + +bool CFiltersArray::ReadFromConfig(const chcore::TConfig& rConfig, PCTSTR pszNodeName) +{ + m_vFilters.clear(); + + chcore::TConfigArray vConfigs; + if(!rConfig.ExtractMultiSubConfigs(pszNodeName, vConfigs)) + return false; + + for(size_t stIndex = 0; stIndex < vConfigs.GetCount(); ++stIndex) + { + const chcore::TConfig& rCfg = vConfigs.GetAt(stIndex); + CFileFilter tFilter; + tFilter.ReadFromConfig(rCfg); + + m_vFilters.push_back(tFilter); + } + return true; +} + +void CFiltersArray::Serialize(chcore::TReadBinarySerializer& rSerializer) +{ + using chcore::Serializers::Serialize; + Serialize(rSerializer, m_vFilters); +} + +void CFiltersArray::Serialize(chcore::TWriteBinarySerializer& rSerializer) const +{ + using chcore::Serializers::Serialize; + Serialize(rSerializer, m_vFilters); +} + +bool CFiltersArray::IsEmpty() const +{ + return m_vFilters.empty(); +} + +void CFiltersArray::Add(const CFileFilter& rFilter) +{ + m_vFilters.push_back(rFilter); +} + +bool CFiltersArray::SetAt(size_t stIndex, const CFileFilter& rNewFilter) +{ + BOOST_ASSERT(stIndex < m_vFilters.size()); + if(stIndex < m_vFilters.size()) + { + CFileFilter& rFilter = m_vFilters.at(stIndex); + rFilter = rNewFilter; + return true; + } + else + return false; +} + +const CFileFilter* CFiltersArray::GetAt(size_t stIndex) const +{ + BOOST_ASSERT(stIndex < m_vFilters.size()); + if(stIndex < m_vFilters.size()) + return &m_vFilters.at(stIndex); + else + return NULL; +} + +bool CFiltersArray::RemoveAt(size_t stIndex) +{ + BOOST_ASSERT(stIndex < m_vFilters.size()); + if(stIndex < m_vFilters.size()) + { + m_vFilters.erase(m_vFilters.begin() + stIndex); + return true; + } + else + return false; +} + +size_t CFiltersArray::GetSize() const +{ + return m_vFilters.size(); +} + +END_CHCORE_NAMESPACE Index: src/ch/FileFilter.cpp =================================================================== diff -u -N --- src/ch/FileFilter.cpp (revision 10d4c73f3589c377ec0b60a2a053ff6aafeb507f) +++ src/ch/FileFilter.cpp (revision 0) @@ -1,766 +0,0 @@ -/*************************************************************************** -* Copyright (C) 2001-2008 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 "FileInfo.h" -#include "FileFilter.h" -#include "../libchcore/TConfig.h" -#include "../libchcore/TBinarySerializer.h" -#include "../libchcore/SerializationHelpers.h" - -//////////////////////////////////////////////////////////////////////////// -bool _tcicmp(TCHAR c1, TCHAR c2) -{ - TCHAR ch1[2]={c1, 0}, ch2[2]={c2, 0}; - return (_tcsicmp(ch1, ch2) == 0); -} - -CFileFilter::CFileFilter() -{ - // files mask - m_bUseMask=false; - m_astrMask.Clear(); - - m_bUseExcludeMask=false; - m_astrExcludeMask.Clear(); - - // size filtering - m_bUseSize1=false; - m_eSizeCmpType1=eSizeCmp_Greater; - m_ullSize1=0; - m_bUseSize2=false; - m_eSizeCmpType2=eSizeCmp_Less; - m_ullSize2=0; - - // date filtering - m_bUseDateTime1=false; - m_eDateType = eDateType_Created; - m_eDateCmpType1 = eDateCmp_Greater; - m_bUseDate1=false; - m_tDate1=CTime::GetCurrentTime(); - m_bUseTime1=false; - m_tTime1=CTime::GetCurrentTime(); - - m_bUseDateTime2=false; - m_eDateCmpType2 = eDateCmp_Less; - m_bUseDate2=false; - m_tDate2=CTime::GetCurrentTime(); - m_bUseTime2=false; - m_tTime2=CTime::GetCurrentTime(); - - // attribute filtering - m_bUseAttributes=false; - m_iArchive=2; - m_iReadOnly=2; - m_iHidden=2; - m_iSystem=2; - m_iDirectory=2; -} - -CFileFilter::CFileFilter(const CFileFilter& rFilter) -{ - *this=rFilter; -} - -CFileFilter& CFileFilter::operator=(const CFileFilter& rFilter) -{ - // files mask - m_bUseMask=rFilter.m_bUseMask; - m_astrMask = rFilter.m_astrMask; - - m_bUseExcludeMask=rFilter.m_bUseExcludeMask; - m_astrExcludeMask = rFilter.m_astrExcludeMask; - - // size filtering - m_bUseSize1=rFilter.m_bUseSize1; - m_eSizeCmpType1=rFilter.m_eSizeCmpType1; - m_ullSize1=rFilter.m_ullSize1; - m_bUseSize2=rFilter.m_bUseSize2; - m_eSizeCmpType2=rFilter.m_eSizeCmpType2; - m_ullSize2=rFilter.m_ullSize2; - - // date filtering - m_bUseDateTime1=rFilter.m_bUseDateTime1; - m_eDateType=rFilter.m_eDateType; - m_eDateCmpType1=rFilter.m_eDateCmpType1; - m_bUseDate1=rFilter.m_bUseDate1; - m_tDate1=rFilter.m_tDate1; - m_bUseTime1=rFilter.m_bUseTime1; - m_tTime1=rFilter.m_tTime1; - - m_bUseDateTime2=rFilter.m_bUseDateTime2; - m_eDateCmpType2=rFilter.m_eDateCmpType2; - m_bUseDate2=rFilter.m_bUseDate2; - m_tDate2=rFilter.m_tDate2; - m_bUseTime2=rFilter.m_bUseTime2; - m_tTime2=rFilter.m_tTime2; - - // attribute filtering - m_bUseAttributes=rFilter.m_bUseAttributes; - m_iArchive=rFilter.m_iArchive; - m_iReadOnly=rFilter.m_iReadOnly; - m_iHidden=rFilter.m_iHidden; - m_iSystem=rFilter.m_iSystem; - m_iDirectory=rFilter.m_iDirectory; - - return *this; -} - -chcore::TString& CFileFilter::GetCombinedMask(chcore::TString& strMask) const -{ - strMask.Clear(); - size_t stCount = m_astrMask.GetCount(); - if(stCount > 0) - { - strMask = m_astrMask.GetAt(0); - for(size_t stIndex = 1; stIndex < stCount; stIndex++) - { - strMask += _T("|") + m_astrMask.GetAt(stIndex); - } - } - - return strMask; -} - -void CFileFilter::SetCombinedMask(const chcore::TString& pMask) -{ - m_astrMask.Clear(); - - TCHAR *pszData=new TCHAR[pMask.GetLength()+1]; - _tcscpy(pszData, pMask); - - TCHAR *szToken=_tcstok(pszData, _T("|")); - while (szToken != NULL) - { - // add token to a table - m_astrMask.Add(szToken); - - // search for next - szToken=_tcstok(NULL, _T("|")); - } - - delete [] pszData; -} - -chcore::TString& CFileFilter::GetCombinedExcludeMask(chcore::TString& strMask) const -{ - strMask.Clear(); - size_t stCount = m_astrExcludeMask.GetCount(); - if(stCount > 0) - { - strMask = m_astrExcludeMask.GetAt(0); - for(size_t stIndex = 1; stIndex < stCount; stIndex++) - { - strMask += _T("|") + m_astrExcludeMask.GetAt(stIndex); - } - } - - return strMask; -} - -void CFileFilter::SetCombinedExcludeMask(const chcore::TString& pMask) -{ - m_astrExcludeMask.Clear(); - - TCHAR *pszData=new TCHAR[pMask.GetLength()+1]; - _tcscpy(pszData, pMask); - - TCHAR *szToken=_tcstok(pszData, _T("|")); - while (szToken != NULL) - { - // add token - m_astrExcludeMask.Add(szToken); - - // find next - szToken=_tcstok(NULL, _T("|")); - } - - delete [] pszData; -} - -void CFileFilter::StoreInConfig(chcore::TConfig& rConfig) const -{ - SetConfigValue(rConfig, _T("IncludeMask.Use"), m_bUseMask); - SetConfigValue(rConfig, _T("IncludeMask.MaskList.Mask"), m_astrMask); - - SetConfigValue(rConfig, _T("ExcludeMask.Use"), m_bUseExcludeMask); - SetConfigValue(rConfig, _T("ExcludeMask.MaskList.Mask"), m_astrExcludeMask); - - SetConfigValue(rConfig, _T("SizeA.Use"), m_bUseSize1); - SetConfigValue(rConfig, _T("SizeA.FilteringType"), m_eSizeCmpType1); - SetConfigValue(rConfig, _T("SizeA.Value"), m_ullSize1); - SetConfigValue(rConfig, _T("SizeB.Use"), m_bUseSize2); - SetConfigValue(rConfig, _T("SizeB.FilteringType"), m_eSizeCmpType2); - SetConfigValue(rConfig, _T("SizeB.Value"), m_ullSize2); - - SetConfigValue(rConfig, _T("DateA.Use"), m_bUseDateTime1); - SetConfigValue(rConfig, _T("DateA.Type"), m_eDateType); // created/last modified/last accessed - SetConfigValue(rConfig, _T("DateA.FilteringType"), m_eDateCmpType1); // before/after - SetConfigValue(rConfig, _T("DateA.EnableDatePart"), m_bUseDate1); - SetConfigValue(rConfig, _T("DateA.DateValue"), m_tDate1.GetTime()); - SetConfigValue(rConfig, _T("DateA.EnableTimePart"), m_bUseTime1); - SetConfigValue(rConfig, _T("DateA.TimeValue"), m_tTime1.GetTime()); - - SetConfigValue(rConfig, _T("DateB.Type"), m_bUseDateTime2); - SetConfigValue(rConfig, _T("DateB.FilteringType"), m_eDateCmpType2); - SetConfigValue(rConfig, _T("DateB.EnableDatePart"), m_bUseDate2); - SetConfigValue(rConfig, _T("DateB.DateValue"), m_tDate2.GetTime()); - SetConfigValue(rConfig, _T("DateB.EnableTimePart"), m_bUseTime2); - SetConfigValue(rConfig, _T("DateB.TimeValue"), m_tTime2.GetTime()); - - SetConfigValue(rConfig, _T("Attributes.Use"), m_bUseAttributes); - SetConfigValue(rConfig, _T("Attributes.Archive"), m_iArchive); - SetConfigValue(rConfig, _T("Attributes.ReadOnly"), m_iReadOnly); - SetConfigValue(rConfig, _T("Attributes.Hidden"), m_iHidden); - SetConfigValue(rConfig, _T("Attributes.System"), m_iSystem); - SetConfigValue(rConfig, _T("Attributes.Directory"), m_iDirectory); -} - -void CFileFilter::ReadFromConfig(const chcore::TConfig& rConfig) -{ - __time64_t tTime = 0; - - if(!GetConfigValue(rConfig, _T("IncludeMask.Use"), m_bUseMask)) - m_bUseMask = false; - - m_astrMask.Clear(); - GetConfigValue(rConfig, _T("IncludeMask.MaskList.Mask"), m_astrMask); - - if(!GetConfigValue(rConfig, _T("ExcludeMask.Use"), m_bUseExcludeMask)) - m_bUseExcludeMask = false; - - m_astrExcludeMask.Clear(); - GetConfigValue(rConfig, _T("ExcludeMask.MaskList.Mask"), m_astrExcludeMask); - - if(!GetConfigValue(rConfig, _T("SizeA.Use"), m_bUseSize1)) - m_bUseSize1 = false; - if(!GetConfigValue(rConfig, _T("SizeA.FilteringType"), *(int*)m_eSizeCmpType1)) - m_eSizeCmpType1 = eSizeCmp_Equal; - if(!GetConfigValue(rConfig, _T("SizeA.Value"), m_ullSize1)) - m_ullSize1 = 0; - if(!GetConfigValue(rConfig, _T("SizeB.Use"), m_bUseSize2)) - m_bUseSize2 = false; - if(!GetConfigValue(rConfig, _T("SizeB.FilteringType"), *(int*)m_eSizeCmpType2)) - m_eSizeCmpType2 = eSizeCmp_Equal; - if(!GetConfigValue(rConfig, _T("SizeB.Value"), m_ullSize2)) - m_ullSize2 = 0; - - if(!GetConfigValue(rConfig, _T("DateA.Use"), m_bUseDateTime1)) - m_bUseDateTime1 = false; - - if(!GetConfigValue(rConfig, _T("DateA.Type"), *(int*)m_eDateType)) // created/last modified/last accessed - m_eDateType = eDateType_Created; - if(!GetConfigValue(rConfig, _T("DateA.FilteringType"), *(int*)m_eDateCmpType1)) // before/after - m_eDateCmpType1 = eDateCmp_Equal; - if(!GetConfigValue(rConfig, _T("DateA.EnableDatePart"), m_bUseDate1)) - m_bUseDate1 = false; - - if(!GetConfigValue(rConfig, _T("DateA.DateValue"), tTime)) - tTime = 0; - m_tDate1 = tTime; - - if(!GetConfigValue(rConfig, _T("DateA.EnableTimePart"), m_bUseTime1)) - m_bUseTime1 = false; - - if(!GetConfigValue(rConfig, _T("DateA.TimeValue"), tTime)) - tTime = 0; - m_tTime1 = tTime; - - if(!GetConfigValue(rConfig, _T("DateB.Type"), m_bUseDateTime2)) - m_bUseDateTime2 = false; - if(!GetConfigValue(rConfig, _T("DateB.FilteringType"), *(int*)m_eDateCmpType2)) - m_eDateCmpType2 = eDateCmp_Equal; - if(!GetConfigValue(rConfig, _T("DateB.EnableDatePart"), m_bUseDate2)) - m_bUseDate2 = false; - - if(!GetConfigValue(rConfig, _T("DateB.DateValue"), tTime)) - tTime = 0; - m_tDate2 = tTime; - if(!GetConfigValue(rConfig, _T("DateB.EnableTimePart"), m_bUseTime2)) - m_bUseTime2 = false; - if(!GetConfigValue(rConfig, _T("DateB.TimeValue"), tTime)) - tTime = 0; - m_tTime2 = tTime; - - if(!GetConfigValue(rConfig, _T("Attributes.Use"), m_bUseAttributes)) - m_bUseAttributes = false; - if(!GetConfigValue(rConfig, _T("Attributes.Archive"), m_iArchive)) - m_iArchive = 0; - if(!GetConfigValue(rConfig, _T("Attributes.ReadOnly"), m_iReadOnly)) - m_iReadOnly = false; - if(!GetConfigValue(rConfig, _T("Attributes.Hidden"), m_iHidden)) - m_iHidden = 0; - if(!GetConfigValue(rConfig, _T("Attributes.System"), m_iSystem)) - m_iSystem = 0; - if(!GetConfigValue(rConfig, _T("Attributes.Directory"), m_iDirectory)) - m_iDirectory = 0; -} - -void CFileFilter::Serialize(chcore::TReadBinarySerializer& rSerializer) -{ - using chcore::Serializers::Serialize; - - Serialize(rSerializer, m_bUseMask); - Serialize(rSerializer, m_astrMask); - - Serialize(rSerializer, m_bUseExcludeMask); - Serialize(rSerializer, m_astrExcludeMask); - - Serialize(rSerializer, m_bUseSize1); - Serialize(rSerializer, m_eSizeCmpType1); - Serialize(rSerializer, m_ullSize1); - Serialize(rSerializer, m_bUseSize2); - Serialize(rSerializer, m_eSizeCmpType2); - Serialize(rSerializer, m_ullSize2); - - Serialize(rSerializer, m_bUseDateTime1); - Serialize(rSerializer, m_eDateType); // created/last modified/last accessed - Serialize(rSerializer, m_eDateCmpType1); // before/after - Serialize(rSerializer, m_bUseDate1); - Serialize(rSerializer, m_tDate1); - Serialize(rSerializer, m_bUseTime1); - Serialize(rSerializer, m_tTime1); - - Serialize(rSerializer, m_bUseDateTime2); - Serialize(rSerializer, m_eDateCmpType2); - Serialize(rSerializer, m_bUseDate2); - Serialize(rSerializer, m_tDate2); - Serialize(rSerializer, m_bUseTime2); - Serialize(rSerializer, m_tTime2); - - Serialize(rSerializer, m_bUseAttributes); - Serialize(rSerializer, m_iArchive); - Serialize(rSerializer, m_iReadOnly); - Serialize(rSerializer, m_iHidden); - Serialize(rSerializer, m_iSystem); - Serialize(rSerializer, m_iDirectory); -} - -void CFileFilter::Serialize(chcore::TWriteBinarySerializer& rSerializer) const -{ - using chcore::Serializers::Serialize; - - Serialize(rSerializer, m_bUseMask); - Serialize(rSerializer, m_astrMask); - - Serialize(rSerializer, m_bUseExcludeMask); - Serialize(rSerializer, m_astrExcludeMask); - - Serialize(rSerializer, m_bUseSize1); - Serialize(rSerializer, m_eSizeCmpType1); - Serialize(rSerializer, m_ullSize1); - Serialize(rSerializer, m_bUseSize2); - Serialize(rSerializer, m_eSizeCmpType2); - Serialize(rSerializer, m_ullSize2); - - Serialize(rSerializer, m_bUseDateTime1); - Serialize(rSerializer, m_eDateType); // created/last modified/last accessed - Serialize(rSerializer, m_eDateCmpType1); // before/after - Serialize(rSerializer, m_bUseDate1); - Serialize(rSerializer, m_tDate1); - Serialize(rSerializer, m_bUseTime1); - Serialize(rSerializer, m_tTime1); - - Serialize(rSerializer, m_bUseDateTime2); - Serialize(rSerializer, m_eDateCmpType2); - Serialize(rSerializer, m_bUseDate2); - Serialize(rSerializer, m_tDate2); - Serialize(rSerializer, m_bUseTime2); - Serialize(rSerializer, m_tTime2); - - Serialize(rSerializer, m_bUseAttributes); - Serialize(rSerializer, m_iArchive); - Serialize(rSerializer, m_iReadOnly); - Serialize(rSerializer, m_iHidden); - Serialize(rSerializer, m_iSystem); - Serialize(rSerializer, m_iDirectory); -} - -bool CFileFilter::Match(const CFileInfoPtr& spInfo) const -{ - // check by mask - if(m_bUseMask) - { - bool bRes=false; - for(chcore::TStringArray::const_iterator iterMask = m_astrMask.Begin(); iterMask != m_astrMask.End(); ++iterMask) - { - if(MatchMask(*iterMask, spInfo->GetFullFilePath().GetFileName().ToString())) - bRes = true; - } - if(!bRes) - return false; - } - - // excluding mask - if(m_bUseExcludeMask) - { - for(chcore::TStringArray::const_iterator iterExcludeMask = m_astrExcludeMask.Begin(); iterExcludeMask != m_astrExcludeMask.End(); ++iterExcludeMask) - { - if(MatchMask(*iterExcludeMask, spInfo->GetFullFilePath().GetFileName().ToString())) - return false; - } - } - - // by size - if (m_bUseSize1) - { - switch (m_eSizeCmpType1) - { - case eSizeCmp_Less: - if (m_ullSize1 <= spInfo->GetLength64()) - return false; - break; - case eSizeCmp_LessOrEqual: - if (m_ullSize1 < spInfo->GetLength64()) - return false; - break; - case eSizeCmp_Equal: - if (m_ullSize1 != spInfo->GetLength64()) - return false; - break; - case eSizeCmp_GreaterOrEqual: - if (m_ullSize1 > spInfo->GetLength64()) - return false; - break; - case eSizeCmp_Greater: - if (m_ullSize1 >= spInfo->GetLength64()) - return false; - break; - } - - // second part - if (m_bUseSize2) - { - switch (m_eSizeCmpType2) - { - case eSizeCmp_Less: - if (m_ullSize2 <= spInfo->GetLength64()) - return false; - break; - case eSizeCmp_LessOrEqual: - if (m_ullSize2 < spInfo->GetLength64()) - return false; - break; - case eSizeCmp_Equal: - if (m_ullSize2 != spInfo->GetLength64()) - return false; - break; - case eSizeCmp_GreaterOrEqual: - if (m_ullSize2 > spInfo->GetLength64()) - return false; - break; - case eSizeCmp_Greater: - if (m_ullSize2 >= spInfo->GetLength64()) - return false; - break; - } - } - } - - // date - get the time from rInfo - if (m_bUseDateTime1) - { - COleDateTime tm; - switch (m_eDateType) - { - case eDateType_Created: - tm=spInfo->GetCreationTime(); - break; - case eDateType_Modified: - tm=spInfo->GetLastWriteTime(); - break; - case eDateType_LastAccessed: - tm=spInfo->GetLastAccessTime(); - break; - } - - // counting... - unsigned long ulInfo=0, ulCheck=0; - if (m_bUseDate1) - { - ulInfo=(tm.GetYear()-1970)*32140800+tm.GetMonth()*2678400+tm.GetDay()*86400; - ulCheck=(m_tDate1.GetYear()-1970)*32140800+m_tDate1.GetMonth()*2678400+m_tDate1.GetDay()*86400; - } - - if (m_bUseTime1) - { - ulInfo+=tm.GetHour()*3600+tm.GetMinute()*60+tm.GetSecond(); - ulCheck+=m_tTime1.GetHour()*3600+m_tTime1.GetMinute()*60+m_tTime1.GetSecond(); - } - - // ... and comparing - switch (m_eDateCmpType1) - { - case eDateCmp_Less: - if (ulInfo >= ulCheck) - return false; - break; - case eDateCmp_LessOrEqual: - if (ulInfo > ulCheck) - return false; - break; - case eDateCmp_Equal: - if (ulInfo != ulCheck) - return false; - break; - case eDateCmp_GreaterOrEqual: - if (ulInfo < ulCheck) - return false; - break; - case eDateCmp_Greater: - if (ulInfo <= ulCheck) - return false; - break; - } - - if (m_bUseDateTime2) - { - // counting... - ulInfo=0, ulCheck=0; - if (m_bUseDate2) - { - ulInfo=(tm.GetYear()-1970)*32140800+tm.GetMonth()*2678400+tm.GetDay()*86400; - ulCheck=(m_tDate2.GetYear()-1970)*32140800+m_tDate2.GetMonth()*2678400+m_tDate2.GetDay()*86400; - } - - if (m_bUseTime2) - { - ulInfo+=tm.GetHour()*3600+tm.GetMinute()*60+tm.GetSecond(); - ulCheck+=m_tTime2.GetHour()*3600+m_tTime2.GetMinute()*60+m_tTime2.GetSecond(); - } - - // ... comparing - switch (m_eDateCmpType2) - { - case eDateCmp_Less: - if (ulInfo >= ulCheck) - return false; - break; - case eDateCmp_LessOrEqual: - if (ulInfo > ulCheck) - return false; - break; - case eDateCmp_Equal: - if (ulInfo != ulCheck) - return false; - break; - case eDateCmp_GreaterOrEqual: - if (ulInfo < ulCheck) - return false; - break; - case eDateCmp_Greater: - if (ulInfo <= ulCheck) - return false; - break; - } - } - } // of m_bUseDate - - // attributes - if (m_bUseAttributes) - { - if ( (m_iArchive == 1 && !spInfo->IsArchived()) || (m_iArchive == 0 && spInfo->IsArchived())) - return false; - if ( (m_iReadOnly == 1 && !spInfo->IsReadOnly()) || (m_iReadOnly == 0 && spInfo->IsReadOnly())) - return false; - if ( (m_iHidden == 1 && !spInfo->IsHidden()) || (m_iHidden == 0 && spInfo->IsHidden())) - return false; - if ( (m_iSystem == 1 && !spInfo->IsSystem()) || (m_iSystem == 0 && spInfo->IsSystem())) - return false; - if ( (m_iDirectory == 1 && !spInfo->IsDirectory()) || (m_iDirectory == 0 && spInfo->IsDirectory())) - return false; - } - - return true; -} - -bool CFileFilter::MatchMask(LPCTSTR lpszMask, LPCTSTR lpszString) const -{ - bool bMatch = 1; - - //iterate and delete '?' and '*' one by one - while(*lpszMask != _T('\0') && bMatch && *lpszString != _T('\0')) - { - if (*lpszMask == _T('?')) lpszString++; - else if (*lpszMask == _T('*')) - { - bMatch = Scan(lpszMask, lpszString); - lpszMask--; - } - else - { - bMatch = _tcicmp(*lpszMask, *lpszString); - lpszString++; - } - lpszMask++; - } - while (*lpszMask == _T('*') && bMatch) lpszMask++; - - return bMatch && *lpszString == _T('\0') && *lpszMask == _T('\0'); -} - -// scan '?' and '*' -bool CFileFilter::Scan(LPCTSTR& lpszMask, LPCTSTR& lpszString) const -{ - // remove the '?' and '*' - for(lpszMask++; *lpszString != _T('\0') && (*lpszMask == _T('?') || *lpszMask == _T('*')); lpszMask++) - if (*lpszMask == _T('?')) lpszString++; - while ( *lpszMask == _T('*')) lpszMask++; - - // if lpszString is empty and lpszMask has more characters or, - // lpszMask is empty, return - if (*lpszString == _T('\0') && *lpszMask != _T('\0')) return false; - if (*lpszString == _T('\0') && *lpszMask == _T('\0')) return true; - // else search substring - else - { - LPCTSTR wdsCopy = lpszMask; - LPCTSTR lpszStringCopy = lpszString; - bool bMatch = true; - do - { - if (!MatchMask(lpszMask, lpszString)) lpszStringCopy++; - lpszMask = wdsCopy; - lpszString = lpszStringCopy; - while (!(_tcicmp(*lpszMask, *lpszString)) && (*lpszString != '\0')) lpszString++; - wdsCopy = lpszMask; - lpszStringCopy = lpszString; - } - while ((*lpszString != _T('\0')) ? !MatchMask(lpszMask, lpszString) : (bMatch = false) != false); - - if (*lpszString == _T('\0') && *lpszMask == _T('\0')) return true; - - return bMatch; - } -} - -CFiltersArray& CFiltersArray::operator=(const CFiltersArray& rSrc) -{ - if(this != &rSrc) - { - m_vFilters = rSrc.m_vFilters; - } - - return *this; -} - -bool CFiltersArray::Match(const CFileInfoPtr& spInfo) const -{ - if(m_vFilters.empty()) - return true; - - // if only one of the filters matches - return true - for(std::vector::const_iterator iterFilter = m_vFilters.begin(); iterFilter != m_vFilters.end(); iterFilter++) - { - if((*iterFilter).Match(spInfo)) - return true; - } - - return false; -} - -void CFiltersArray::StoreInConfig(chcore::TConfig& rConfig, PCTSTR pszNodeName) const -{ - rConfig.DeleteNode(pszNodeName); - BOOST_FOREACH(const CFileFilter& rFilter, m_vFilters) - { - chcore::TConfig cfgNode; - rFilter.StoreInConfig(cfgNode); - rConfig.AddSubConfig(chcore::TString(pszNodeName) + _T(".FilterDefinition"), cfgNode); - } -} - -bool CFiltersArray::ReadFromConfig(const chcore::TConfig& rConfig, PCTSTR pszNodeName) -{ - m_vFilters.clear(); - - chcore::TConfigArray vConfigs; - if(!rConfig.ExtractMultiSubConfigs(pszNodeName, vConfigs)) - return false; - - for(size_t stIndex = 0; stIndex < vConfigs.GetCount(); ++stIndex) - { - const chcore::TConfig& rCfg = vConfigs.GetAt(stIndex); - CFileFilter tFilter; - tFilter.ReadFromConfig(rCfg); - - m_vFilters.push_back(tFilter); - } - return true; -} - -void CFiltersArray::Serialize(chcore::TReadBinarySerializer& rSerializer) -{ - using chcore::Serializers::Serialize; - Serialize(rSerializer, m_vFilters); -} - -void CFiltersArray::Serialize(chcore::TWriteBinarySerializer& rSerializer) const -{ - using chcore::Serializers::Serialize; - Serialize(rSerializer, m_vFilters); -} - -bool CFiltersArray::IsEmpty() const -{ - return m_vFilters.empty(); -} - -void CFiltersArray::Add(const CFileFilter& rFilter) -{ - m_vFilters.push_back(rFilter); -} - -bool CFiltersArray::SetAt(size_t stIndex, const CFileFilter& rNewFilter) -{ - BOOST_ASSERT(stIndex < m_vFilters.size()); - if(stIndex < m_vFilters.size()) - { - CFileFilter& rFilter = m_vFilters.at(stIndex); - rFilter = rNewFilter; - return true; - } - else - return false; -} - -const CFileFilter* CFiltersArray::GetAt(size_t stIndex) const -{ - BOOST_ASSERT(stIndex < m_vFilters.size()); - if(stIndex < m_vFilters.size()) - return &m_vFilters.at(stIndex); - else - return NULL; -} - -bool CFiltersArray::RemoveAt(size_t stIndex) -{ - BOOST_ASSERT(stIndex < m_vFilters.size()); - if(stIndex < m_vFilters.size()) - { - m_vFilters.erase(m_vFilters.begin() + stIndex); - return true; - } - else - return false; -} - -size_t CFiltersArray::GetSize() const -{ - return m_vFilters.size(); -} Index: src/libchcore/FileFilter.h =================================================================== diff -u -N --- src/libchcore/FileFilter.h (revision 0) +++ src/libchcore/FileFilter.h (revision d12e49decb8a3df3e28f6786d38542390484ac07) @@ -0,0 +1,255 @@ +/*************************************************************************** + * Copyright (C) 2001-2008 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 __FILEFILTER_H__ +#define __FILEFILTER_H__ + +#include "libchcore.h" +#include "FileInfo.h" +#include + +BEGIN_CHCORE_NAMESPACE + +class TConfig; + +class LIBCHCORE_API CFileFilter +{ +public: + enum ESizeCompareType + { + eSizeCmp_Less = 0, + eSizeCmp_LessOrEqual = 1, + eSizeCmp_Equal = 2, + eSizeCmp_GreaterOrEqual = 3, + eSizeCmp_Greater = 4 + }; + + enum EDateCompareType + { + eDateCmp_Less = 0, + eDateCmp_LessOrEqual = 1, + eDateCmp_Equal = 2, + eDateCmp_GreaterOrEqual = 3, + eDateCmp_Greater = 4 + }; + + enum EDateType + { + eDateType_Created = 0, + eDateType_Modified = 1, + eDateType_LastAccessed = 2 + }; + +public: + CFileFilter(); + CFileFilter(const CFileFilter& rFilter); + CFileFilter& operator=(const CFileFilter& rFilter); + + bool Match(const CFileInfoPtr& spInfo) const; + + chcore::TString& GetCombinedMask(chcore::TString& pMask) const; + void SetCombinedMask(const chcore::TString& pMask); + + chcore::TString& GetCombinedExcludeMask(chcore::TString& pMask) const; + void SetCombinedExcludeMask(const chcore::TString& pMask); + + void StoreInConfig(chcore::TConfig& rConfig) const; + void ReadFromConfig(const chcore::TConfig& rConfig); + + void Serialize(chcore::TReadBinarySerializer& rSerializer); + void Serialize(chcore::TWriteBinarySerializer& rSerializer) const; + + // atrributes access + bool GetUseMask() const { return m_bUseMask; } + void SetUseMask(bool bUseMask) { m_bUseMask = bUseMask; } + +// const chcore::TStringArray& GetMaskArray() const { return m_astrMask; } +// chcore::TStringArray& GetMaskArray() { return m_astrMask; } + + bool GetUseExcludeMask() const { return m_bUseExcludeMask; } + void SetUseExcludeMask(bool bUseExcludeMask) { m_bUseExcludeMask = bUseExcludeMask; } + +// const chcore::TStringArray& GetExcludeMaskArray() const { return m_astrExcludeMask; } +// chcore::TStringArray& GetExcludeMaskArray() { return m_astrExcludeMask; } + + bool GetUseSize1() const { return m_bUseSize1; } + void SetUseSize1(bool bUseSize1) { m_bUseSize1 = bUseSize1; } + + ESizeCompareType GetSizeType1() const { return m_eSizeCmpType1; } + void SetSizeType1(ESizeCompareType eSizeType1) { m_eSizeCmpType1 = eSizeType1; } + + unsigned long long GetSize1() const { return m_ullSize1; } + void SetSize1(unsigned long long ullSize1) { m_ullSize1 = ullSize1; } + + bool GetUseSize2() const { return m_bUseSize2; } + void SetUseSize2(bool bUseSize2) { m_bUseSize2 = bUseSize2; } + + ESizeCompareType GetSizeType2() const { return m_eSizeCmpType2; } + void SetSizeType2(ESizeCompareType eSizeType2) { m_eSizeCmpType2 = eSizeType2; } + + unsigned long long GetSize2() const { return m_ullSize2; } + void SetSize2(unsigned long long ullSize2) { m_ullSize2 = ullSize2; } + + // dates + CFileFilter::EDateType GetDateType() const { return m_eDateType; } + void SetDateType(CFileFilter::EDateType eDateType) { m_eDateType = eDateType; } + + // date 1 + bool GetUseDateTime1() const { return m_bUseDateTime1; } + void SetUseDateTime1(bool bUseDateTime1) { m_bUseDateTime1 = bUseDateTime1; } + + CFileFilter::EDateCompareType GetDateCmpType1() const { return m_eDateCmpType1; } + void SetDateCmpType1(CFileFilter::EDateCompareType eCmpType1) { m_eDateCmpType1 = eCmpType1; } + + bool GetUseDate1() const { return m_bUseDate1; } + void SetUseDate1(bool tDate1) { m_bUseDate1 = tDate1; } + + const ATL::CTime& GetDate1() const { return m_tDate1; } + void SetDate1(const ATL::CTime& tDate1) { m_tDate1 = tDate1; } + + bool GetUseTime1() const { return m_bUseTime1; } + void SetUseTime1(bool tTime1) { m_bUseTime1 = tTime1; } + + const ATL::CTime& GetTime1() const { return m_tTime1; } + void SetTime1(const ATL::CTime& val) { m_tTime1 = val; } + + // date 2 + bool GetUseDateTime2() const { return m_bUseDateTime2; } + void SetUseDateTime2(bool bUseDateTime2) { m_bUseDateTime2 = bUseDateTime2; } + + CFileFilter::EDateCompareType GetDateCmpType2() const { return m_eDateCmpType2; } + void SetDateCmpType2(CFileFilter::EDateCompareType eCmpType2) { m_eDateCmpType2 = eCmpType2; } + + bool GetUseDate2() const { return m_bUseDate2; } + void SetUseDate2(bool tDate2) { m_bUseDate2 = tDate2; } + + const ATL::CTime& GetDate2() const { return m_tDate2; } + void SetDate2(const ATL::CTime& tDate2) { m_tDate2 = tDate2; } + + bool GetUseTime2() const { return m_bUseTime2; } + void SetUseTime2(bool tTime2) { m_bUseTime2 = tTime2; } + + const ATL::CTime& GetTime2() const { return m_tTime2; } + void SetTime2(const ATL::CTime& val) { m_tTime2 = val; } + + // attributes + bool GetUseAttributes() const { return m_bUseAttributes; } + void SetUseAttributes(bool bUseAttributes) { m_bUseAttributes = bUseAttributes; } + + int GetArchive() const { return m_iArchive; } + void SetArchive(int iArchive) { m_iArchive = iArchive; } + + int GetReadOnly() const { return m_iReadOnly; } + void SetReadOnly(int iReadOnly) { m_iReadOnly = iReadOnly; } + + int GetHidden() const { return m_iHidden; } + void SetHidden(int iHidden) { m_iHidden = iHidden; } + + int GetSystem() const { return m_iSystem; } + void SetSystem(int iSystem) { m_iSystem = iSystem; } + + int GetDirectory() const { return m_iDirectory; } + void SetDirectory(int iDirectory) { m_iDirectory = iDirectory; } + +protected: + bool MatchMask(LPCTSTR lpszMask, LPCTSTR lpszString) const; + bool Scan(LPCTSTR& lpszMask, LPCTSTR& lpszString) const; + +private: + // files mask + bool m_bUseMask; + chcore::TStringArray m_astrMask; + + // files mask- + bool m_bUseExcludeMask; + chcore::TStringArray m_astrExcludeMask; + + // size filtering + bool m_bUseSize1; + ESizeCompareType m_eSizeCmpType1; + unsigned long long m_ullSize1; + + bool m_bUseSize2; + ESizeCompareType m_eSizeCmpType2; + unsigned long long m_ullSize2; + + // date filtering + EDateType m_eDateType; // created/last modified/last accessed + + bool m_bUseDateTime1; +#pragma warning(push) +#pragma warning(disable: 4251) + EDateCompareType m_eDateCmpType1; // before/after + bool m_bUseDate1; + ATL::CTime m_tDate1; + bool m_bUseTime1; + ATL::CTime m_tTime1; + + bool m_bUseDateTime2; + + EDateCompareType m_eDateCmpType2; + bool m_bUseDate2; + ATL::CTime m_tDate2; + bool m_bUseTime2; + ATL::CTime m_tTime2; +#pragma warning(pop) + + // attribute filtering + bool m_bUseAttributes; + int m_iArchive; + int m_iReadOnly; + int m_iHidden; + int m_iSystem; + int m_iDirectory; +}; + +class LIBCHCORE_API CFiltersArray +{ +public: + CFiltersArray() {} + ~CFiltersArray() {} + + CFiltersArray& operator=(const CFiltersArray& rSrc); + bool Match(const CFileInfoPtr& spInfo) const; + + void StoreInConfig(chcore::TConfig& rConfig, PCTSTR pszNodeName) const; + bool ReadFromConfig(const chcore::TConfig& rConfig, PCTSTR pszNodeName); + + void Serialize(chcore::TReadBinarySerializer& rSerializer); + void Serialize(chcore::TWriteBinarySerializer& rSerializer) const; + + bool IsEmpty() const; + + void Add(const CFileFilter& rFilter); + bool SetAt(size_t stIndex, const CFileFilter& rNewFilter); + const CFileFilter* GetAt(size_t stIndex) const; + bool RemoveAt(size_t stIndex); + size_t GetSize() const; + +protected: +#pragma warning(push) +#pragma warning(disable: 4251) + std::vector m_vFilters; +#pragma warning(pop) +}; + +END_CHCORE_NAMESPACE + +CONFIG_MEMBER_SERIALIZATION(CFiltersArray) + +#endif Index: src/ch/FileFilter.h =================================================================== diff -u -N --- src/ch/FileFilter.h (revision 10d4c73f3589c377ec0b60a2a053ff6aafeb507f) +++ src/ch/FileFilter.h (revision 0) @@ -1,245 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2001-2008 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 __FILEFILTER_H__ -#define __FILEFILTER_H__ - -#include "FileInfo.h" - -namespace chcore { class TConfig; } - -class CFileFilter -{ -public: - enum ESizeCompareType - { - eSizeCmp_Less = 0, - eSizeCmp_LessOrEqual = 1, - eSizeCmp_Equal = 2, - eSizeCmp_GreaterOrEqual = 3, - eSizeCmp_Greater = 4 - }; - - enum EDateCompareType - { - eDateCmp_Less = 0, - eDateCmp_LessOrEqual = 1, - eDateCmp_Equal = 2, - eDateCmp_GreaterOrEqual = 3, - eDateCmp_Greater = 4 - }; - - enum EDateType - { - eDateType_Created = 0, - eDateType_Modified = 1, - eDateType_LastAccessed = 2 - }; - -public: - CFileFilter(); - CFileFilter(const CFileFilter& rFilter); - CFileFilter& operator=(const CFileFilter& rFilter); - - bool Match(const CFileInfoPtr& spInfo) const; - - chcore::TString& GetCombinedMask(chcore::TString& pMask) const; - void SetCombinedMask(const chcore::TString& pMask); - - chcore::TString& GetCombinedExcludeMask(chcore::TString& pMask) const; - void SetCombinedExcludeMask(const chcore::TString& pMask); - - void StoreInConfig(chcore::TConfig& rConfig) const; - void ReadFromConfig(const chcore::TConfig& rConfig); - - void Serialize(chcore::TReadBinarySerializer& rSerializer); - void Serialize(chcore::TWriteBinarySerializer& rSerializer) const; - - // atrributes access - bool GetUseMask() const { return m_bUseMask; } - void SetUseMask(bool bUseMask) { m_bUseMask = bUseMask; } - -// const chcore::TStringArray& GetMaskArray() const { return m_astrMask; } -// chcore::TStringArray& GetMaskArray() { return m_astrMask; } - - bool GetUseExcludeMask() const { return m_bUseExcludeMask; } - void SetUseExcludeMask(bool bUseExcludeMask) { m_bUseExcludeMask = bUseExcludeMask; } - -// const chcore::TStringArray& GetExcludeMaskArray() const { return m_astrExcludeMask; } -// chcore::TStringArray& GetExcludeMaskArray() { return m_astrExcludeMask; } - - bool GetUseSize1() const { return m_bUseSize1; } - void SetUseSize1(bool bUseSize1) { m_bUseSize1 = bUseSize1; } - - ESizeCompareType GetSizeType1() const { return m_eSizeCmpType1; } - void SetSizeType1(ESizeCompareType eSizeType1) { m_eSizeCmpType1 = eSizeType1; } - - unsigned long long GetSize1() const { return m_ullSize1; } - void SetSize1(unsigned long long ullSize1) { m_ullSize1 = ullSize1; } - - bool GetUseSize2() const { return m_bUseSize2; } - void SetUseSize2(bool bUseSize2) { m_bUseSize2 = bUseSize2; } - - ESizeCompareType GetSizeType2() const { return m_eSizeCmpType2; } - void SetSizeType2(ESizeCompareType eSizeType2) { m_eSizeCmpType2 = eSizeType2; } - - unsigned long long GetSize2() const { return m_ullSize2; } - void SetSize2(unsigned long long ullSize2) { m_ullSize2 = ullSize2; } - - // dates - CFileFilter::EDateType GetDateType() const { return m_eDateType; } - void SetDateType(CFileFilter::EDateType eDateType) { m_eDateType = eDateType; } - - // date 1 - bool GetUseDateTime1() const { return m_bUseDateTime1; } - void SetUseDateTime1(bool bUseDateTime1) { m_bUseDateTime1 = bUseDateTime1; } - - CFileFilter::EDateCompareType GetDateCmpType1() const { return m_eDateCmpType1; } - void SetDateCmpType1(CFileFilter::EDateCompareType eCmpType1) { m_eDateCmpType1 = eCmpType1; } - - bool GetUseDate1() const { return m_bUseDate1; } - void SetUseDate1(bool tDate1) { m_bUseDate1 = tDate1; } - - const CTime& GetDate1() const { return m_tDate1; } - void SetDate1(const CTime& tDate1) { m_tDate1 = tDate1; } - - bool GetUseTime1() const { return m_bUseTime1; } - void SetUseTime1(bool tTime1) { m_bUseTime1 = tTime1; } - - const CTime& GetTime1() const { return m_tTime1; } - void SetTime1(const CTime& val) { m_tTime1 = val; } - - // date 2 - bool GetUseDateTime2() const { return m_bUseDateTime2; } - void SetUseDateTime2(bool bUseDateTime2) { m_bUseDateTime2 = bUseDateTime2; } - - CFileFilter::EDateCompareType GetDateCmpType2() const { return m_eDateCmpType2; } - void SetDateCmpType2(CFileFilter::EDateCompareType eCmpType2) { m_eDateCmpType2 = eCmpType2; } - - bool GetUseDate2() const { return m_bUseDate2; } - void SetUseDate2(bool tDate2) { m_bUseDate2 = tDate2; } - - const CTime& GetDate2() const { return m_tDate2; } - void SetDate2(const CTime& tDate2) { m_tDate2 = tDate2; } - - bool GetUseTime2() const { return m_bUseTime2; } - void SetUseTime2(bool tTime2) { m_bUseTime2 = tTime2; } - - const CTime& GetTime2() const { return m_tTime2; } - void SetTime2(const CTime& val) { m_tTime2 = val; } - - // attributes - bool GetUseAttributes() const { return m_bUseAttributes; } - void SetUseAttributes(bool bUseAttributes) { m_bUseAttributes = bUseAttributes; } - - int GetArchive() const { return m_iArchive; } - void SetArchive(int iArchive) { m_iArchive = iArchive; } - - int GetReadOnly() const { return m_iReadOnly; } - void SetReadOnly(int iReadOnly) { m_iReadOnly = iReadOnly; } - - int GetHidden() const { return m_iHidden; } - void SetHidden(int iHidden) { m_iHidden = iHidden; } - - int GetSystem() const { return m_iSystem; } - void SetSystem(int iSystem) { m_iSystem = iSystem; } - - int GetDirectory() const { return m_iDirectory; } - void SetDirectory(int iDirectory) { m_iDirectory = iDirectory; } - -protected: - bool MatchMask(LPCTSTR lpszMask, LPCTSTR lpszString) const; - bool Scan(LPCTSTR& lpszMask, LPCTSTR& lpszString) const; - -private: - // files mask - bool m_bUseMask; - chcore::TStringArray m_astrMask; - - // files mask- - bool m_bUseExcludeMask; - chcore::TStringArray m_astrExcludeMask; - - // size filtering - bool m_bUseSize1; - ESizeCompareType m_eSizeCmpType1; - unsigned long long m_ullSize1; - - bool m_bUseSize2; - ESizeCompareType m_eSizeCmpType2; - unsigned long long m_ullSize2; - - // date filtering - EDateType m_eDateType; // created/last modified/last accessed - - bool m_bUseDateTime1; - - EDateCompareType m_eDateCmpType1; // before/after - bool m_bUseDate1; - CTime m_tDate1; - bool m_bUseTime1; - CTime m_tTime1; - - bool m_bUseDateTime2; - - EDateCompareType m_eDateCmpType2; - bool m_bUseDate2; - CTime m_tDate2; - bool m_bUseTime2; - CTime m_tTime2; - - // attribute filtering - bool m_bUseAttributes; - int m_iArchive; - int m_iReadOnly; - int m_iHidden; - int m_iSystem; - int m_iDirectory; -}; - -class CFiltersArray -{ -public: - CFiltersArray() {} - ~CFiltersArray() {} - - CFiltersArray& operator=(const CFiltersArray& rSrc); - bool Match(const CFileInfoPtr& spInfo) const; - - void StoreInConfig(chcore::TConfig& rConfig, PCTSTR pszNodeName) const; - bool ReadFromConfig(const chcore::TConfig& rConfig, PCTSTR pszNodeName); - - void Serialize(chcore::TReadBinarySerializer& rSerializer); - void Serialize(chcore::TWriteBinarySerializer& rSerializer) const; - - bool IsEmpty() const; - - void Add(const CFileFilter& rFilter); - bool SetAt(size_t stIndex, const CFileFilter& rNewFilter); - const CFileFilter* GetAt(size_t stIndex) const; - bool RemoveAt(size_t stIndex); - size_t GetSize() const; - -protected: - std::vector m_vFilters; -}; - -CONFIG_MEMBER_SERIALIZATION(CFiltersArray) - -#endif - Index: src/libchcore/FileInfo.cpp =================================================================== diff -u -N --- src/libchcore/FileInfo.cpp (revision 0) +++ src/libchcore/FileInfo.cpp (revision d12e49decb8a3df3e28f6786d38542390484ac07) @@ -0,0 +1,301 @@ +/*************************************************************************** +* Copyright (C) 2001-2008 by Jozef Starosczyk * +* ixen@copyhandler.com * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU Library General Public License * +* (version 2) as published by the Free Software Foundation; * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU Library General Public * +* License along with this program; if not, write to the * +* Free Software Foundation, Inc., * +* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * +***************************************************************************/ +// File was originally based on FileInfo.cpp by Antonio Tejada Lacaci. +// Almost everything has changed since then. +#include "stdafx.h" +#include +#include "FileInfo.h" +#include "../libicpf/exception.h" +#include "TBinarySerializer.h" +#include "SerializationHelpers.h" + +BEGIN_CHCORE_NAMESPACE + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CFileInfo::CFileInfo() : + m_pBasePaths(NULL), + m_pathFile(), + m_stSrcIndex(std::numeric_limits::max()), + m_dwAttributes(0), + m_uhFileSize(0), + m_uiFlags(0) +{ + m_ftCreation.dwHighDateTime = m_ftCreation.dwLowDateTime = 0; + m_ftLastAccess.dwHighDateTime = m_ftLastAccess.dwLowDateTime = 0; + m_ftLastWrite.dwHighDateTime = m_ftLastWrite.dwLowDateTime = 0; +} + +CFileInfo::CFileInfo(const CFileInfo& 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) +{ +} + +CFileInfo::~CFileInfo() +{ +} + +void CFileInfo::Init(const chcore::TSmartPath& rpathFile, size_t stSrcIndex, const chcore::TPathContainer* pBasePaths, + DWORD dwAttributes, ULONGLONG uhFileSize, FILETIME ftCreation, FILETIME ftLastAccess, FILETIME ftLastWrite, + uint_t uiFlags) +{ + m_pathFile = rpathFile; + m_stSrcIndex = stSrcIndex; + m_pBasePaths = pBasePaths; + 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 +} + +void CFileInfo::Init(const chcore::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_dwAttributes = dwAttributes; + m_uhFileSize = uhFileSize; + m_ftCreation = ftCreation; + m_ftLastAccess = ftLastAccess; + m_ftLastWrite = ftLastWrite; + m_uiFlags = uiFlags; +} + +void CFileInfo::SetParentObject(size_t stIndex, const chcore::TPathContainer* pBasePaths) +{ + // cannot set parent object if there is already one specified + if(m_pBasePaths && m_stSrcIndex != std::numeric_limits::max()) + THROW(_T("Invalid argument"), 0, 0, 0); + + m_stSrcIndex = stIndex; + m_pBasePaths = pBasePaths; + + if(m_pBasePaths && m_stSrcIndex != std::numeric_limits::max()) + m_pathFile.MakeRelativePath(m_pBasePaths->GetAt(m_stSrcIndex)); +} + +bool CFileInfo::operator==(const CFileInfo& rInfo) +{ + return (rInfo.m_dwAttributes == m_dwAttributes && rInfo.m_ftCreation.dwHighDateTime == m_ftCreation.dwHighDateTime && rInfo.m_ftCreation.dwLowDateTime == m_ftCreation.dwLowDateTime + && rInfo.m_ftLastWrite.dwHighDateTime == m_ftLastWrite.dwHighDateTime && rInfo.m_ftLastWrite.dwLowDateTime == m_ftLastWrite.dwLowDateTime && rInfo.m_uhFileSize == m_uhFileSize); +} + +chcore::TSmartPath CFileInfo::GetFullFilePath() const +{ + if(m_stSrcIndex != std::numeric_limits::max()) + { + BOOST_ASSERT(m_pBasePaths); + if(!m_pBasePaths) + THROW(_T("Invalid pointer"), 0, 0, 0); + + chcore::TSmartPath pathCombined = m_pBasePaths->GetAt(m_stSrcIndex); + pathCombined += m_pathFile; + return pathCombined; + } + else + return m_pathFile; +} + +void CFileInfo::Serialize(chcore::TReadBinarySerializer& rSerializer) +{ + using chcore::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); +} + +void CFileInfo::Serialize(chcore::TWriteBinarySerializer& rSerializer) const +{ + using chcore::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); +} + +/////////////////////////////////////////////////////////////////////// +// Array +CFileInfoArray::CFileInfoArray(const chcore::TPathContainer& rBasePaths) : + m_rBasePaths(rBasePaths) +{ +} + +CFileInfoArray::~CFileInfoArray() +{ +} + +void CFileInfoArray::AddFileInfo(const CFileInfoPtr& spFileInfo) +{ + boost::unique_lock lock(m_lock); + m_vFiles.push_back(spFileInfo); +} + +size_t CFileInfoArray::GetSize() const +{ + boost::shared_lock lock(m_lock); + return m_vFiles.size(); +} + +CFileInfoPtr CFileInfoArray::GetAt(size_t stIndex) const +{ + boost::shared_lock lock(m_lock); + + if(stIndex >= m_vFiles.size()) + THROW(_T("Out of bounds"), 0, 0, 0); + + return m_vFiles.at(stIndex); +} + +CFileInfo CFileInfoArray::GetCopyAt(size_t stIndex) const +{ + boost::shared_lock lock(m_lock); + + if(stIndex >= m_vFiles.size()) + THROW(_T("Out of bounds"), 0, 0, 0); + const CFileInfoPtr& spInfo = m_vFiles.at(stIndex); + if(!spInfo) + THROW(_T("Invalid pointer"), 0, 0, 0); + + return *spInfo; +} + +void CFileInfoArray::Clear() +{ + boost::unique_lock lock(m_lock); + m_vFiles.clear(); +} + +unsigned long long CFileInfoArray::CalculateTotalSize() +{ + unsigned long long ullSize = 0; + + boost::shared_lock lock(m_lock); + BOOST_FOREACH(CFileInfoPtr& spFileInfo, m_vFiles) + { + ullSize += spFileInfo->GetLength64(); + } + + return ullSize; +} + +void CFileInfoArray::Serialize(chcore::TReadBinarySerializer& rSerializer, bool bOnlyFlags) +{ + using chcore::Serializers::Serialize; + + 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); + + CFileInfoPtr spFileInfo; + + uint_t uiFlags = 0; + for(size_t stIndex = 0; stIndex < stCount; stIndex++) + { + if(bOnlyFlags) + { + CFileInfoPtr& rspFileInfo = m_vFiles.at(stIndex); + Serialize(rSerializer, uiFlags); + rspFileInfo->SetFlags(uiFlags); + } + else + { + spFileInfo.reset(new CFileInfo); + spFileInfo->SetClipboard(&m_rBasePaths); + Serialize(rSerializer, *spFileInfo); + m_vFiles.push_back(spFileInfo); + } + } +} + +void CFileInfoArray::Serialize(chcore::TWriteBinarySerializer& rSerializer, bool bOnlyFlags) const +{ + using chcore::Serializers::Serialize; + + size_t stCount = m_vFiles.size(); + Serialize(rSerializer, stCount); + + 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 CFileInfoArray::CalculatePartialSize(size_t stCount) +{ + unsigned long long ullSize = 0; + + boost::shared_lock lock(m_lock); + if(stCount > m_vFiles.size()) + THROW(_T("Invalid argument"), 0, 0, 0); + + for(std::vector::iterator iter = m_vFiles.begin(); iter != m_vFiles.begin() + stCount; ++iter) + { + ullSize += (*iter)->GetLength64(); + } + + return ullSize; +} + +END_CHCORE_NAMESPACE Index: src/ch/FileInfo.cpp =================================================================== diff -u -N --- src/ch/FileInfo.cpp (revision b611128c48b4bfbc20bf2ba0ac4168ae774ed79b) +++ src/ch/FileInfo.cpp (revision 0) @@ -1,303 +0,0 @@ -/*************************************************************************** -* Copyright (C) 2001-2008 by Jozef Starosczyk * -* ixen@copyhandler.com * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU Library General Public License * -* (version 2) as published by the Free Software Foundation; * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU Library General Public * -* License along with this program; if not, write to the * -* Free Software Foundation, Inc., * -* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * -***************************************************************************/ -// File was originally based on FileInfo.cpp by Antonio Tejada Lacaci. -// Almost everything has changed since then. -#include "stdafx.h" -#include -#include "FileInfo.h" -#include "../libicpf/exception.h" -#include "../libchcore/TBinarySerializer.h" -#include "../libchcore/SerializationHelpers.h" - -#ifdef _DEBUG -#undef THIS_FILE -static char THIS_FILE[]=__FILE__; -#define new DEBUG_NEW -#endif - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -CFileInfo::CFileInfo() : - m_pBasePaths(NULL), - m_pathFile(), - m_stSrcIndex(std::numeric_limits::max()), - m_dwAttributes(0), - m_uhFileSize(0), - m_uiFlags(0) -{ - m_ftCreation.dwHighDateTime = m_ftCreation.dwLowDateTime = 0; - m_ftLastAccess.dwHighDateTime = m_ftLastAccess.dwLowDateTime = 0; - m_ftLastWrite.dwHighDateTime = m_ftLastWrite.dwLowDateTime = 0; -} - -CFileInfo::CFileInfo(const CFileInfo& 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) -{ -} - -CFileInfo::~CFileInfo() -{ -} - -void CFileInfo::Init(const chcore::TSmartPath& rpathFile, size_t stSrcIndex, const chcore::TPathContainer* pBasePaths, - DWORD dwAttributes, ULONGLONG uhFileSize, FILETIME ftCreation, FILETIME ftLastAccess, FILETIME ftLastWrite, - uint_t uiFlags) -{ - m_pathFile = rpathFile; - m_stSrcIndex = stSrcIndex; - m_pBasePaths = pBasePaths; - 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 -} - -void CFileInfo::Init(const chcore::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_dwAttributes = dwAttributes; - m_uhFileSize = uhFileSize; - m_ftCreation = ftCreation; - m_ftLastAccess = ftLastAccess; - m_ftLastWrite = ftLastWrite; - m_uiFlags = uiFlags; -} - -void CFileInfo::SetParentObject(size_t stIndex, const chcore::TPathContainer* pBasePaths) -{ - // cannot set parent object if there is already one specified - if(m_pBasePaths && m_stSrcIndex != std::numeric_limits::max()) - THROW(_T("Invalid argument"), 0, 0, 0); - - m_stSrcIndex = stIndex; - m_pBasePaths = pBasePaths; - - if(m_pBasePaths && m_stSrcIndex != std::numeric_limits::max()) - m_pathFile.MakeRelativePath(m_pBasePaths->GetAt(m_stSrcIndex)); -} - -bool CFileInfo::operator==(const CFileInfo& rInfo) -{ - return (rInfo.m_dwAttributes == m_dwAttributes && rInfo.m_ftCreation.dwHighDateTime == m_ftCreation.dwHighDateTime && rInfo.m_ftCreation.dwLowDateTime == m_ftCreation.dwLowDateTime - && rInfo.m_ftLastWrite.dwHighDateTime == m_ftLastWrite.dwHighDateTime && rInfo.m_ftLastWrite.dwLowDateTime == m_ftLastWrite.dwLowDateTime && rInfo.m_uhFileSize == m_uhFileSize); -} - -chcore::TSmartPath CFileInfo::GetFullFilePath() const -{ - if(m_stSrcIndex != std::numeric_limits::max()) - { - BOOST_ASSERT(m_pBasePaths); - if(!m_pBasePaths) - THROW(_T("Invalid pointer"), 0, 0, 0); - - chcore::TSmartPath pathCombined = m_pBasePaths->GetAt(m_stSrcIndex); - pathCombined += m_pathFile; - return pathCombined; - } - else - return m_pathFile; -} - -void CFileInfo::Serialize(chcore::TReadBinarySerializer& rSerializer) -{ - using chcore::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); -} - -void CFileInfo::Serialize(chcore::TWriteBinarySerializer& rSerializer) const -{ - using chcore::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); -} - -/////////////////////////////////////////////////////////////////////// -// Array -CFileInfoArray::CFileInfoArray(const chcore::TPathContainer& rBasePaths) : - m_rBasePaths(rBasePaths) -{ -} - -CFileInfoArray::~CFileInfoArray() -{ -} - -void CFileInfoArray::AddFileInfo(const CFileInfoPtr& spFileInfo) -{ - boost::unique_lock lock(m_lock); - m_vFiles.push_back(spFileInfo); -} - -size_t CFileInfoArray::GetSize() const -{ - boost::shared_lock lock(m_lock); - return m_vFiles.size(); -} - -CFileInfoPtr CFileInfoArray::GetAt(size_t stIndex) const -{ - boost::shared_lock lock(m_lock); - - if(stIndex >= m_vFiles.size()) - THROW(_T("Out of bounds"), 0, 0, 0); - - return m_vFiles.at(stIndex); -} - -CFileInfo CFileInfoArray::GetCopyAt(size_t stIndex) const -{ - boost::shared_lock lock(m_lock); - - if(stIndex >= m_vFiles.size()) - THROW(_T("Out of bounds"), 0, 0, 0); - const CFileInfoPtr& spInfo = m_vFiles.at(stIndex); - if(!spInfo) - THROW(_T("Invalid pointer"), 0, 0, 0); - - return *spInfo; -} - -void CFileInfoArray::Clear() -{ - boost::unique_lock lock(m_lock); - m_vFiles.clear(); -} - -unsigned long long CFileInfoArray::CalculateTotalSize() -{ - unsigned long long ullSize = 0; - - boost::shared_lock lock(m_lock); - BOOST_FOREACH(CFileInfoPtr& spFileInfo, m_vFiles) - { - ullSize += spFileInfo->GetLength64(); - } - - return ullSize; -} - -void CFileInfoArray::Serialize(chcore::TReadBinarySerializer& rSerializer, bool bOnlyFlags) -{ - using chcore::Serializers::Serialize; - - 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); - - CFileInfoPtr spFileInfo; - - uint_t uiFlags = 0; - for(size_t stIndex = 0; stIndex < stCount; stIndex++) - { - if(bOnlyFlags) - { - CFileInfoPtr& rspFileInfo = m_vFiles.at(stIndex); - Serialize(rSerializer, uiFlags); - rspFileInfo->SetFlags(uiFlags); - } - else - { - spFileInfo.reset(new CFileInfo); - spFileInfo->SetClipboard(&m_rBasePaths); - Serialize(rSerializer, *spFileInfo); - m_vFiles.push_back(spFileInfo); - } - } -} - -void CFileInfoArray::Serialize(chcore::TWriteBinarySerializer& rSerializer, bool bOnlyFlags) const -{ - using chcore::Serializers::Serialize; - - size_t stCount = m_vFiles.size(); - Serialize(rSerializer, stCount); - - 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 CFileInfoArray::CalculatePartialSize(size_t stCount) -{ - unsigned long long ullSize = 0; - - boost::shared_lock lock(m_lock); - if(stCount > m_vFiles.size()) - THROW(_T("Invalid argument"), 0, 0, 0); - - for(std::vector::iterator iter = m_vFiles.begin(); iter != m_vFiles.begin() + stCount; ++iter) - { - ullSize += (*iter)->GetLength64(); - } - - return ullSize; -} Index: src/libchcore/FileInfo.h =================================================================== diff -u -N --- src/libchcore/FileInfo.h (revision 0) +++ src/libchcore/FileInfo.h (revision d12e49decb8a3df3e28f6786d38542390484ac07) @@ -0,0 +1,154 @@ +/*************************************************************************** +* Copyright (C) 2001-2008 by Jozef Starosczyk * +* ixen@copyhandler.com * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU Library General Public License * +* (version 2) as published by the Free Software Foundation; * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU Library General Public * +* License along with this program; if not, write to the * +* Free Software Foundation, Inc., * +* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * +***************************************************************************/ +// File was originally based on FileInfo.h by Antonio Tejada Lacaci. +// Almost everything has changed since then. + +#ifndef __FILEINFO_H__ +#define __FILEINFO_H__ + +#include "libchcore.h" +#include "TPath.h" + +BEGIN_CHCORE_NAMESPACE + +// CFileInfo flags +// flag stating that file has been processed (used to determine if file can be deleted at the end of copying) +#define FIF_PROCESSED 0x00000001 + +class CFiltersArray; + +class LIBCHCORE_API CFileInfo +{ +public: + CFileInfo(); + CFileInfo(const CFileInfo& finf); + ~CFileInfo(); + + // with base path + void Init(const chcore::TSmartPath& rpathFile, size_t stSrcIndex, const chcore::TPathContainer* pBasePaths, + DWORD dwAttributes, ULONGLONG uhFileSize, FILETIME ftCreation, FILETIME ftLastAccess, FILETIME ftLastWrite, + uint_t uiFlags); + + // without base path + void Init(const chcore::TSmartPath& rpathFile, DWORD dwAttributes, ULONGLONG uhFileSize, FILETIME ftCreation, + FILETIME ftLastAccess, FILETIME ftLastWrite, uint_t uiFlags); + + // setting parent object + void SetParentObject(size_t stIndex, const chcore::TPathContainer* pBasePaths); + + ULONGLONG GetLength64() const { return m_uhFileSize; } + void SetLength64(ULONGLONG uhSize) { m_uhFileSize=uhSize; } + + const chcore::TSmartPath& GetFilePath() const { return m_pathFile; } // returns path with m_pathFile (probably not full) + chcore::TSmartPath GetFullFilePath() const; // returns full path + void SetFilePath(const chcore::TSmartPath& tPath) { m_pathFile = tPath; }; + + /* Get File times info (equivalent to CFindFile members) */ + const FILETIME& GetCreationTime() const { return m_ftCreation; }; + const FILETIME& GetLastAccessTime() const { return m_ftLastAccess; }; + const FILETIME& GetLastWriteTime() const { return m_ftLastWrite; }; + + /* Get File attributes info (equivalent to CFindFile members) */ + DWORD GetAttributes() const { return m_dwAttributes; } + bool IsDirectory() const { return (m_dwAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0; } + bool IsArchived() const { return (m_dwAttributes & FILE_ATTRIBUTE_ARCHIVE) != 0; } + bool IsReadOnly() const { return (m_dwAttributes & FILE_ATTRIBUTE_READONLY) != 0; } + bool IsCompressed() const { return (m_dwAttributes & FILE_ATTRIBUTE_COMPRESSED) != 0; } + bool IsSystem() const { return (m_dwAttributes & FILE_ATTRIBUTE_SYSTEM) != 0; } + bool IsHidden() const { return (m_dwAttributes & FILE_ATTRIBUTE_HIDDEN) != 0; } + bool IsTemporary() const { return (m_dwAttributes & FILE_ATTRIBUTE_TEMPORARY) != 0; } + bool IsNormal() const { return m_dwAttributes == 0; } + + 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 SetClipboard(const chcore::TPathContainer* pBasePaths) { m_pBasePaths = pBasePaths; } + + void SetSrcIndex(size_t stIndex) { m_stSrcIndex = stIndex; }; + size_t GetSrcIndex() const { return m_stSrcIndex; }; + + // operators + bool operator==(const CFileInfo& rInfo); + + void Serialize(chcore::TReadBinarySerializer& rSerializer); + void Serialize(chcore::TWriteBinarySerializer& rSerializer) const; + +private: + chcore::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 chcore::TPathContainer* m_pBasePaths; + + DWORD m_dwAttributes; // attributes + ULONGLONG m_uhFileSize; + FILETIME m_ftCreation; + FILETIME m_ftLastAccess; + FILETIME m_ftLastWrite; + + uint_t m_uiFlags; +}; + +typedef boost::shared_ptr CFileInfoPtr; + +class LIBCHCORE_API CFileInfoArray +{ +public: + CFileInfoArray(const chcore::TPathContainer& rBasePaths); + ~CFileInfoArray(); + + // Adds a new object info to this container + void AddFileInfo(const CFileInfoPtr& spFileInfo); + + /// Retrieves count of elements in this object + size_t GetSize() const; + + /// Retrieves an element at the specified index + CFileInfoPtr GetAt(size_t stIndex) const; + + /// Retrieves a copy of the element at a specified index + CFileInfo GetCopyAt(size_t stIndex) const; + + /// Removes all elements from this object + void Clear(); + + // specialized operations on contents of m_vFiles + /// Calculates the size of the first stCount file info objects + unsigned long long CalculatePartialSize(size_t stCount); + + /// Calculates the size of all file info objects inside this object + unsigned long long CalculateTotalSize(); + + /// Stores infos about elements in the archive + void Serialize(chcore::TReadBinarySerializer& rSerializer, bool bOnlyFlags); + void Serialize(chcore::TWriteBinarySerializer& rSerializer, bool bOnlyFlags) const; + +protected: + const chcore::TPathContainer& m_rBasePaths; + +#pragma warning(push) +#pragma warning(disable: 4251) + std::vector m_vFiles; + mutable boost::shared_mutex m_lock; +#pragma warning(pop) +}; + +END_CHCORE_NAMESPACE + +#endif Index: src/ch/FileInfo.h =================================================================== diff -u -N --- src/ch/FileInfo.h (revision 5fd6beaad9f1eccb664b997d151acb59961e4827) +++ src/ch/FileInfo.h (revision 0) @@ -1,146 +0,0 @@ -/*************************************************************************** -* Copyright (C) 2001-2008 by Jozef Starosczyk * -* ixen@copyhandler.com * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU Library General Public License * -* (version 2) as published by the Free Software Foundation; * -* * -* This program is distributed in the hope that it will be useful, * -* but WITHOUT ANY WARRANTY; without even the implied warranty of * -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -* GNU General Public License for more details. * -* * -* You should have received a copy of the GNU Library General Public * -* License along with this program; if not, write to the * -* Free Software Foundation, Inc., * -* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * -***************************************************************************/ -// File was originally based on FileInfo.h by Antonio Tejada Lacaci. -// Almost everything has changed since then. - -#ifndef __FILEINFO_H__ -#define __FILEINFO_H__ - -#include "../libchcore/TPath.h" - -// CFileInfo flags -// flag stating that file has been processed (used to determine if file can be deleted at the end of copying) -#define FIF_PROCESSED 0x00000001 - -class CFiltersArray; - -class CFileInfo -{ -public: - CFileInfo(); - CFileInfo(const CFileInfo& finf); - ~CFileInfo(); - - // with base path - void Init(const chcore::TSmartPath& rpathFile, size_t stSrcIndex, const chcore::TPathContainer* pBasePaths, - DWORD dwAttributes, ULONGLONG uhFileSize, FILETIME ftCreation, FILETIME ftLastAccess, FILETIME ftLastWrite, - uint_t uiFlags); - - // without base path - void Init(const chcore::TSmartPath& rpathFile, DWORD dwAttributes, ULONGLONG uhFileSize, FILETIME ftCreation, - FILETIME ftLastAccess, FILETIME ftLastWrite, uint_t uiFlags); - - // setting parent object - void SetParentObject(size_t stIndex, const chcore::TPathContainer* pBasePaths); - - ULONGLONG GetLength64() const { return m_uhFileSize; } - void SetLength64(ULONGLONG uhSize) { m_uhFileSize=uhSize; } - - const chcore::TSmartPath& GetFilePath() const { return m_pathFile; } // returns path with m_pathFile (probably not full) - chcore::TSmartPath GetFullFilePath() const; // returns full path - void SetFilePath(const chcore::TSmartPath& tPath) { m_pathFile = tPath; }; - - /* Get File times info (equivalent to CFindFile members) */ - const FILETIME& GetCreationTime() const { return m_ftCreation; }; - const FILETIME& GetLastAccessTime() const { return m_ftLastAccess; }; - const FILETIME& GetLastWriteTime() const { return m_ftLastWrite; }; - - /* Get File attributes info (equivalent to CFindFile members) */ - DWORD GetAttributes() const { return m_dwAttributes; } - bool IsDirectory() const { return (m_dwAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0; } - bool IsArchived() const { return (m_dwAttributes & FILE_ATTRIBUTE_ARCHIVE) != 0; } - bool IsReadOnly() const { return (m_dwAttributes & FILE_ATTRIBUTE_READONLY) != 0; } - bool IsCompressed() const { return (m_dwAttributes & FILE_ATTRIBUTE_COMPRESSED) != 0; } - bool IsSystem() const { return (m_dwAttributes & FILE_ATTRIBUTE_SYSTEM) != 0; } - bool IsHidden() const { return (m_dwAttributes & FILE_ATTRIBUTE_HIDDEN) != 0; } - bool IsTemporary() const { return (m_dwAttributes & FILE_ATTRIBUTE_TEMPORARY) != 0; } - bool IsNormal() const { return m_dwAttributes == 0; } - - 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 SetClipboard(const chcore::TPathContainer* pBasePaths) { m_pBasePaths = pBasePaths; } - - void SetSrcIndex(size_t stIndex) { m_stSrcIndex = stIndex; }; - size_t GetSrcIndex() const { return m_stSrcIndex; }; - - // operators - bool operator==(const CFileInfo& rInfo); - - void Serialize(chcore::TReadBinarySerializer& rSerializer); - void Serialize(chcore::TWriteBinarySerializer& rSerializer) const; - -private: - chcore::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 chcore::TPathContainer* m_pBasePaths; - - DWORD m_dwAttributes; // attributes - ULONGLONG m_uhFileSize; - FILETIME m_ftCreation; - FILETIME m_ftLastAccess; - FILETIME m_ftLastWrite; - - uint_t m_uiFlags; -}; - -typedef boost::shared_ptr CFileInfoPtr; - -class CFileInfoArray -{ -public: - CFileInfoArray(const chcore::TPathContainer& rBasePaths); - ~CFileInfoArray(); - - // Adds a new object info to this container - void AddFileInfo(const CFileInfoPtr& spFileInfo); - - /// Retrieves count of elements in this object - size_t GetSize() const; - - /// Retrieves an element at the specified index - CFileInfoPtr GetAt(size_t stIndex) const; - - /// Retrieves a copy of the element at a specified index - CFileInfo GetCopyAt(size_t stIndex) const; - - /// Removes all elements from this object - void Clear(); - - // specialized operations on contents of m_vFiles - /// Calculates the size of the first stCount file info objects - unsigned long long CalculatePartialSize(size_t stCount); - - /// Calculates the size of all file info objects inside this object - unsigned long long CalculateTotalSize(); - - /// Stores infos about elements in the archive - void Serialize(chcore::TReadBinarySerializer& rSerializer, bool bOnlyFlags); - void Serialize(chcore::TWriteBinarySerializer& rSerializer, bool bOnlyFlags) const; - -protected: - const chcore::TPathContainer& m_rBasePaths; - std::vector m_vFiles; - - mutable boost::shared_mutex m_lock; -}; - -#endif Index: src/libchcore/SerializationHelpers.h =================================================================== diff -u -N -r5fd6beaad9f1eccb664b997d151acb59961e4827 -rd12e49decb8a3df3e28f6786d38542390484ac07 --- src/libchcore/SerializationHelpers.h (.../SerializationHelpers.h) (revision 5fd6beaad9f1eccb664b997d151acb59961e4827) +++ src/libchcore/SerializationHelpers.h (.../SerializationHelpers.h) (revision d12e49decb8a3df3e28f6786d38542390484ac07) @@ -101,6 +101,23 @@ SerializerType::StoreValue(rSerializer, tValue); } +#ifdef _ATL_VER + template<> + inline void Serialize(TReadBinarySerializer& rSerializer, ATL::CTime& tValue) + { + long long llTime = 0; + Serialize(rSerializer, llTime); + tValue = ATL::CTime(llTime); + } + + template<> + inline void Serialize(TWriteBinarySerializer& rSerializer, const ATL::CTime& tValue) + { + long long llTime = tValue.GetTime(); + Serialize(rSerializer, llTime); + } +#endif + #ifdef _MFC_VER template<> inline void Serialize(TReadBinarySerializer& rSerializer, CString& tValue) @@ -116,6 +133,7 @@ Serialize(rSerializer, (PCTSTR)tValue); } +/* template<> inline void Serialize(TReadBinarySerializer& rSerializer, CTime& tValue) { @@ -130,6 +148,7 @@ long long llTime = tValue.GetTime(); Serialize(rSerializer, llTime); } +*/ #endif } Index: src/libchcore/libchcore.vc90.vcproj =================================================================== diff -u -N -r6df9b4cff81dedf8c5571a98702b584b061eac09 -rd12e49decb8a3df3e28f6786d38542390484ac07 --- src/libchcore/libchcore.vc90.vcproj (.../libchcore.vc90.vcproj) (revision 6df9b4cff81dedf8c5571a98702b584b061eac09) +++ src/libchcore/libchcore.vc90.vcproj (.../libchcore.vc90.vcproj) (revision d12e49decb8a3df3e28f6786d38542390484ac07) @@ -348,6 +348,22 @@ > + + + + + + + +