MCPcopy Create free account
hub / github.com/WinMerge/winmerge / CreateOperationsScripts

Method CreateOperationsScripts

Src/FileActionScript.cpp:85–188  ·  view source on GitHub ↗

* @brief Create ShellFileOperations operation lists from our scripts. * * We use ShellFileOperations internally to do actual file operations. * ShellFileOperations can do only one type of operation (copy, move, delete) * with one instance at a time, so we use own instance for every * type of action. * @return One of CreateScriptReturn values. */

Source from the content-addressed store, hash-verified

83 * @return One of CreateScriptReturn values.
84 */
85int FileActionScript::CreateOperationsScripts()
86{
87 UINT operation = 0;
88 FILEOP_FLAGS operFlags = 0;
89 bool bContinue = true;
90
91 // Copy operations first
92 operation = FO_COPY;
93 operFlags |= FOF_NOCONFIRMMKDIR | FOF_MULTIDESTFILES | FOF_NOCONFIRMATION;
94 if (m_bUseRecycleBin)
95 operFlags |= FOF_ALLOWUNDO;
96
97 vector<FileActionItem>::const_iterator iter = m_actions.begin();
98 while (iter != m_actions.end() && bContinue)
99 {
100 bool bSkip = false;
101 if ((*iter).atype == FileAction::ACT_COPY && !(*iter).dirflag)
102 {
103 if (!CMergeApp::CreateBackup(true, (*iter).dest))
104 {
105 String strErr = _("Error backing up file");
106 AfxMessageBox(strErr.c_str(), MB_OK | MB_ICONERROR);
107 bContinue = false;
108 }
109 }
110
111 if ((*iter).atype == FileAction::ACT_COPY &&
112 !bSkip && bContinue)
113 {
114 m_pCopyOperations->AddSourceAndDestination((*iter).src, (*iter).dest);
115 m_bHasCopyOperations = true;
116 }
117 ++iter;
118 }
119 if (!bContinue)
120 {
121 m_bHasCopyOperations = false;
122 m_pCopyOperations->Reset();
123 return SCRIPT_USERCANCEL;
124 }
125
126 if (m_bHasCopyOperations)
127 m_pCopyOperations->SetOperation(operation, operFlags, m_hParentWindow);
128
129 // Move operations next
130 operation = FO_MOVE;
131 operFlags = FOF_MULTIDESTFILES;
132 if (m_bUseRecycleBin)
133 operFlags |= FOF_ALLOWUNDO;
134
135 iter = m_actions.begin();
136 while (iter != m_actions.end())
137 {
138 if ((*iter).atype == FileAction::ACT_MOVE)
139 {
140 m_pMoveOperations->AddSourceAndDestination((*iter).src, (*iter).dest);
141 m_bHasMoveOperations = true;
142 }

Callers

nothing calls this directly

Calls 7

SetOperationMethod · 0.80
AddSourceMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
ResetMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected