MCPcopy Create free account
hub / github.com/HO-COOH/FastCopy / Start

Method Start

FastCopy/RobocopyViewModel.cpp:128–178  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

126 return ReadableUnitConverter::Speed::ToString<wchar_t>(m_bytesPerSec).data();
127 }
128 winrt::Windows::Foundation::IAsyncAction RobocopyViewModel::Start()
129 {
130 if (!m_recordFile)
131 co_return;
132 co_await m_countItemTask;
133 ProcessIOUpdater::Start(std::chrono::milliseconds{ 100 });
134 m_status = Status::Running;
135 concurrency::create_task([this]
136 {
137 m_countItemTask.get();
138 static uint64_t bytes{};
139 while (*m_iter != m_recordFile->end() && m_status == Status::Running)
140 {
141 Global::UIThread.TryEnqueue([this] {raisePropertyChange(L"Source"); });
142 if (canUseShellCopy())
143 {
144 ShellCopy::Move(**m_iter, m_destination);
145 m_finishedFiles += m_recordFile->GetNumFiles(m_recordFile->IndexOf(*m_iter));
146 }
147 else if (canUseRobocopy())
148 {
149 m_process.emplace(getRobocopyArg());
150 SetHandle(m_process->Handle());
151 auto const ret = m_process->WaitForExit();
152 m_finishedFiles += m_recordFile->GetNumFiles(m_recordFile->IndexOf(*m_iter));
153 }
154 else
155 {
156 //use fallback
157 std::wstring_view destinationView{ m_destination };
158 Global::UIThread.TryEnqueue([this, value = **m_iter] {
159 m_duplicateFiles.Append({
160 value,
161 std::format(LR"({}\{})", m_destination.data(), std::filesystem::path{ value }.filename().wstring())
162 });
163 });
164 m_hasDuplicates = true;
165 }
166 bytes += TaskFile::GetSizeOfPath(**m_iter);
167 m_copiedBytes = bytes;
168 raiseProgressChange();
169 ++*m_iter;
170 }
171 if (*m_iter == m_recordFile->end())
172 {
173 onNormalRobocopyFinished();
174 }
175 if (m_hasConfirmed)
176 ConfirmDuplicates();
177 });
178 }
179 void RobocopyViewModel::Pause()
180 {
181 m_status = Status::Pause;

Callers 2

PauseButton_ClickMethod · 0.45
normalLaunchMethod · 0.45

Calls 9

MoveFunction · 0.85
TryEnqueueMethod · 0.80
GetNumFilesMethod · 0.80
IndexOfMethod · 0.80
HandleMethod · 0.80
WaitForExitMethod · 0.80
dataMethod · 0.80
getMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected