diff options
author | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:01:29 +0200 |
---|---|---|
committer | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:01:29 +0200 |
commit | 9a2a524f1e311853d08050be2dcdddc09ac7759a (patch) | |
tree | d8e4a24169fce88c2d89931d58514889a0bcb0ea /synchronization.h | |
parent | 2.3 (diff) | |
download | FreeFileSync-9a2a524f1e311853d08050be2dcdddc09ac7759a.tar.gz FreeFileSync-9a2a524f1e311853d08050be2dcdddc09ac7759a.tar.bz2 FreeFileSync-9a2a524f1e311853d08050be2dcdddc09ac7759a.zip |
3.0
Diffstat (limited to 'synchronization.h')
-rw-r--r-- | synchronization.h | 182 |
1 files changed, 89 insertions, 93 deletions
diff --git a/synchronization.h b/synchronization.h index 0e54b123..95b297ce 100644 --- a/synchronization.h +++ b/synchronization.h @@ -14,123 +14,119 @@ class StatusHandler; namespace FreeFileSync { - class SyncStatistics - { - public: - SyncStatistics(const BaseDirMapping& baseDir); - SyncStatistics(const FolderComparison& folderCmp); - - int getCreate( bool inclLeft = true, bool inclRight = true) const; - int getOverwrite(bool inclLeft = true, bool inclRight = true) const; - int getDelete( bool inclLeft = true, bool inclRight = true) const; - int getConflict() const; - wxULongLong getDataToProcess() const; - int getRowCount() const; - - private: - void init(); - - void getNumbersRecursively(const HierarchyObject& hierObj); - - void getFileNumbers(const FileMapping& fileObj); - void getDirNumbers(const DirMapping& dirObj); - - int createLeft, createRight; - int overwriteLeft, overwriteRight; - int deleteLeft, deleteRight; - int conflict; - wxULongLong dataToProcess; - int rowsTotal; - }; - - bool synchronizationNeeded(const FolderComparison& folderCmp); +class SyncStatistics +{ +public: + SyncStatistics(const HierarchyObject& hierObj); + SyncStatistics(const FolderComparison& folderCmp); - SyncOperation getSyncOperation(const CompareFilesResult cmpResult, - const bool selectedForSynchronization, - const SyncDirection syncDir); //evaluate comparison result and sync direction + int getCreate( bool inclLeft = true, bool inclRight = true) const; + int getOverwrite(bool inclLeft = true, bool inclRight = true) const; + int getDelete( bool inclLeft = true, bool inclRight = true) const; + int getConflict() const; + wxULongLong getDataToProcess() const; + int getRowCount() const; +private: + void init(); - SyncOperation getSyncOperation(const FileSystemObject& fsObj); //convenience function + void getNumbersRecursively(const HierarchyObject& hierObj); + void getFileNumbers(const FileMapping& fileObj); + void getDirNumbers(const DirMapping& dirObj); - struct FolderPairSyncCfg - { - FolderPairSyncCfg(const DeletionPolicy handleDel, - const wxString& custDelDir) : - handleDeletion(handleDel), - custDelFolder(custDelDir) {} + int createLeft, createRight; + int overwriteLeft, overwriteRight; + int deleteLeft, deleteRight; + int conflict; + wxULongLong dataToProcess; + int rowsTotal; +}; - DeletionPolicy handleDeletion; - wxString custDelFolder; - }; - std::vector<FolderPairSyncCfg> extractSyncCfg(const MainConfiguration& mainCfg); +bool synchronizationNeeded(const FolderComparison& folderCmp); - //class handling synchronization process - class SyncProcess - { - public: - SyncProcess(const bool copyFileSymLinks, - const bool traverseDirSymLinks, - xmlAccess::OptionalDialogs& warnings, - const bool verifyCopiedFiles, - StatusHandler* handler); +struct FolderPairSyncCfg +{ + FolderPairSyncCfg(bool inAutomaticMode, + const DeletionPolicy handleDel, + const Zstring& custDelDir) : + updateSyncDB(inAutomaticMode), + handleDeletion(handleDel), + custDelFolder(custDelDir) {} + + bool updateSyncDB; //update database if in automatic mode + DeletionPolicy handleDeletion; + Zstring custDelFolder; +}; +std::vector<FolderPairSyncCfg> extractSyncCfg(const MainConfiguration& mainCfg); + + +//class handling synchronization process +class SyncProcess +{ +public: + SyncProcess(const bool copyFileSymLinks, + const bool traverseDirSymLinks, + xmlAccess::OptionalDialogs& warnings, + const bool verifyCopiedFiles, + StatusHandler* handler); - //CONTRACT: syncConfig must have SAME SIZE folderCmp and correspond per row! - void startSynchronizationProcess(const std::vector<FolderPairSyncCfg>& syncConfig, FolderComparison& folderCmp); + //CONTRACT: syncConfig must have SAME SIZE folderCmp and correspond per row! + void startSynchronizationProcess(const std::vector<FolderPairSyncCfg>& syncConfig, FolderComparison& folderCmp); - private: +private: template <bool deleteOnly> class SyncRecursively; - struct DeletionHandling - { - DeletionHandling(const DeletionPolicy handleDel, - const wxString& custDelFolder); + struct DeletionHandling + { + DeletionHandling(const DeletionPolicy handleDel, + const Zstring& custDelFolder); - DeletionPolicy handleDeletion; - Zstring currentDelFolder; //alternate deletion folder for current folder pair (with timestamp, ends with path separator) - //preloaded status texts: - const Zstring txtMoveFileUserDefined; - const Zstring txtMoveFolderUserDefined; - }; + DeletionPolicy handleDeletion; + Zstring currentDelFolder; //alternate deletion folder for current folder pair (with timestamp, ends with path separator) + //preloaded status texts: + const Zstring txtMoveFileUserDefined; + const Zstring txtMoveFolderUserDefined; + }; - void syncRecursively(HierarchyObject& hierObj); - void synchronizeFile(FileMapping& fileObj, const DeletionHandling& delHandling) const; - void synchronizeFolder(DirMapping& dirObj, const DeletionHandling& delHandling) const; + void syncRecursively(HierarchyObject& hierObj); + void synchronizeFile(FileMapping& fileObj, const DeletionHandling& delHandling) const; + void synchronizeFolder(DirMapping& dirObj, const DeletionHandling& delHandling) const; - template <FreeFileSync::SelectedSide side> - void removeFile(const FileMapping& fileObj, const DeletionHandling& delHandling, bool showStatusUpdate) const; + template <FreeFileSync::SelectedSide side> + void removeFile(const FileMapping& fileObj, const DeletionHandling& delHandling, bool showStatusUpdate) const; - template <FreeFileSync::SelectedSide side> - void removeFolder(const DirMapping& dirObj, const DeletionHandling& delHandling) const; + template <FreeFileSync::SelectedSide side> + void removeFolder(const DirMapping& dirObj, const DeletionHandling& delHandling) const; - void copyFileUpdating(const Zstring& source, const Zstring& target, const wxULongLong& sourceFileSize) const; - void verifyFileCopy(const Zstring& source, const Zstring& target) const; + void copyFileUpdating(const Zstring& source, const Zstring& target, const wxULongLong& sourceFileSize) const; + void verifyFileCopy(const Zstring& source, const Zstring& target) const; - const bool m_copyFileSymLinks; - const bool m_traverseDirSymLinks; - const bool m_verifyCopiedFiles; + const bool m_copyFileSymLinks; + const bool m_traverseDirSymLinks; + const bool m_verifyCopiedFiles; - //warnings - xmlAccess::OptionalDialogs& m_warnings; + //warnings + xmlAccess::OptionalDialogs& m_warnings; #ifdef FFS_WIN - //shadow copy buffer - std::auto_ptr<ShadowCopy> shadowCopyHandler; + //shadow copy buffer + std::auto_ptr<ShadowCopy> shadowCopyHandler; #endif - StatusHandler* const statusUpdater; - - //preload status texts - const Zstring txtCopyingFile; - const Zstring txtOverwritingFile; - const Zstring txtCreatingFolder; - const Zstring txtDeletingFile; - const Zstring txtDeletingFolder; - const Zstring txtMoveToRecycler; - const Zstring txtVerifying; - }; + StatusHandler* const statusUpdater; + + //preload status texts + const Zstring txtCopyingFile; + const Zstring txtOverwritingFile; + const Zstring txtCreatingFolder; + const Zstring txtDeletingFile; + const Zstring txtDeletingFolder; + const Zstring txtMoveToRecycler; + const Zstring txtVerifying; +}; } #endif // SYNCHRONIZATION_H_INCLUDED |