#ifndef SYNCHRONIZATION_H_INCLUDED #define SYNCHRONIZATION_H_INCLUDED #include "fileHierarchy.h" #include "library/processXml.h" #include #ifdef FFS_WIN #include "shared/shadow.h" #endif class StatusHandler; namespace FreeFileSync { class SyncStatistics { public: SyncStatistics(const HierarchyObject& hierObj); 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); 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 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& syncConfig, FolderComparison& folderCmp); private: template class SyncRecursively; 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; }; void syncRecursively(HierarchyObject& hierObj); void synchronizeFile(FileMapping& fileObj, const DeletionHandling& delHandling) const; void synchronizeFolder(DirMapping& dirObj, const DeletionHandling& delHandling) const; template void removeFile(const FileMapping& fileObj, const DeletionHandling& delHandling, bool showStatusUpdate) const; template 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; const bool m_copyFileSymLinks; const bool m_traverseDirSymLinks; const bool m_verifyCopiedFiles; //warnings xmlAccess::OptionalDialogs& m_warnings; #ifdef FFS_WIN //shadow copy buffer std::auto_ptr 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; }; } #endif // SYNCHRONIZATION_H_INCLUDED