@joebigelow / wix / commits / 2113f2be

Make FileCopyUsingHandlesWithProgress more like MoveFileWithProgress

FileCopyUsingHandlesWithProgress now returns ERROR_REQUEST_ABORTED as an HRESULT when canceled or stopping rather than return success.

Rob Mensching committed Apr 12, 2021 at 15:08 UTC 2113f2bedbdf5c2f8fb21fc5dfacc6ddc7379fe7
1 file changed +6 -11
src/dutil/fileutil.cpp
+6 -11
@@ -1120,7 +1120,6 @@ extern "C" HRESULT DAPI FileCopyUsingHandlesWithProgress(
1120 )
1121 {
1122 HRESULT hr = S_OK;
1123 - BOOL fStop = FALSE;
1123 BOOL fCanceled = FALSE;
1124 DWORD64 cbTotalCopied = 0;
1125 BYTE rgbData[64 * 1024];
@@ -1147,12 +1146,10 @@ extern "C" HRESULT DAPI FileCopyUsingHandlesWithProgress(
1146
1147 case PROGRESS_CANCEL:
1148 fCanceled = TRUE;
1150 - fStop = TRUE;
1151 - break;
1149 + ExitFunction1(hr = HRESULT_FROM_WIN32(ERROR_REQUEST_ABORTED));
1150
1151 case PROGRESS_STOP:
1154 - fStop = TRUE;
1155 - break;
1152 + ExitFunction1(hr = HRESULT_FROM_WIN32(ERROR_REQUEST_ABORTED));
1153
1154 case PROGRESS_QUIET:
1155 lpProgressRoutine = NULL;
@@ -1173,7 +1170,7 @@ extern "C" HRESULT DAPI FileCopyUsingHandlesWithProgress(
1170 }
1171
1172 // Copy with progress.
1176 - while (!fStop && (0 == cbCopy || cbTotalCopied < cbCopy))
1173 + while (0 == cbCopy || cbTotalCopied < cbCopy)
1174 {
1175 cbRead = static_cast<DWORD>((0 == cbCopy) ? countof(rgbData) : min(countof(rgbData), cbCopy - cbTotalCopied));
1176 if (!::ReadFile(hSource, rgbData, cbRead, &cbRead, NULL))
@@ -1199,12 +1196,10 @@ extern "C" HRESULT DAPI FileCopyUsingHandlesWithProgress(
1196
1197 case PROGRESS_CANCEL:
1198 fCanceled = TRUE;
1202 - fStop = TRUE;
1203 - break;
1199 + ExitFunction1(hr = HRESULT_FROM_WIN32(ERROR_REQUEST_ABORTED));
1200
1201 case PROGRESS_STOP:
1206 - fStop = TRUE;
1207 - break;
1202 + ExitFunction1(hr = HRESULT_FROM_WIN32(ERROR_REQUEST_ABORTED));
1203
1204 case PROGRESS_QUIET:
1205 lpProgressRoutine = NULL;
@@ -1214,7 +1209,7 @@ extern "C" HRESULT DAPI FileCopyUsingHandlesWithProgress(
1209 }
1210 else
1211 {
1217 - fStop = TRUE;
1212 + break;
1213 }
1214 }
1215