1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
|
#ifndef SYNCHRONIZATION_H_INCLUDED
#define SYNCHRONIZATION_H_INCLUDED
#include "fileHierarchy.h"
#include "library/processXml.h"
#include <memory>
#ifdef FFS_WIN
#include "shared/shadow.h"
#endif
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);
SyncOperation getSyncOperation(const CompareFilesResult cmpResult,
const bool selectedForSynchronization,
const SyncDirection syncDir); //evaluate comparison result and sync direction
SyncOperation getSyncOperation(const FileSystemObject& fsObj); //convenience function
struct FolderPairSyncCfg
{
FolderPairSyncCfg(const DeletionPolicy handleDel,
const wxString& custDelDir) :
handleDeletion(handleDel),
custDelFolder(custDelDir) {}
DeletionPolicy handleDeletion;
wxString 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);
private:
template <bool deleteOnly>
class SyncRecursively;
struct DeletionHandling
{
DeletionHandling(const DeletionPolicy handleDel,
const wxString& 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 <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;
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<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;
};
}
#endif // SYNCHRONIZATION_H_INCLUDED
|