summaryrefslogtreecommitdiff
path: root/src/libs/dutil/WixToolset.DUtil/apputil.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/dutil/WixToolset.DUtil/apputil.cpp')
-rw-r--r--src/libs/dutil/WixToolset.DUtil/apputil.cpp68
1 files changed, 68 insertions, 0 deletions
diff --git a/src/libs/dutil/WixToolset.DUtil/apputil.cpp b/src/libs/dutil/WixToolset.DUtil/apputil.cpp
index 9e75082a..42f589dc 100644
--- a/src/libs/dutil/WixToolset.DUtil/apputil.cpp
+++ b/src/libs/dutil/WixToolset.DUtil/apputil.cpp
@@ -313,6 +313,74 @@ LExit:
313 return hr; 313 return hr;
314} 314}
315 315
316DAPI_(HRESULT) AppWaitForSingleObject(
317 __in HANDLE hHandle,
318 __in DWORD dwMilliseconds
319 )
320{
321 HRESULT hr = S_OK;
322 DWORD dwResult = 0;
323
324 dwResult = ::WaitForSingleObject(hHandle, dwMilliseconds);
325 if (WAIT_TIMEOUT == dwResult)
326 {
327 ExitFunction1(hr = HRESULT_FROM_WIN32(dwResult));
328 }
329 else if (WAIT_ABANDONED == dwResult)
330 {
331 AppExitOnWin32Error(dwResult, hr, "Abandoned wait for single object.");
332 }
333 else if (WAIT_OBJECT_0 != dwResult)
334 {
335 AssertSz(WAIT_FAILED == dwResult, "Unexpected return code from WaitForSingleObject.");
336 AppExitWithLastError(hr, "Failed to wait for single object.");
337 }
338
339LExit:
340 return hr;
341}
342
343DAPI_(HRESULT) AppWaitForMultipleObjects(
344 __in DWORD dwCount,
345 __in const HANDLE* rghHandles,
346 __in BOOL fWaitAll,
347 __in DWORD dwMilliseconds,
348 __out_opt DWORD* pdwSignaledIndex
349 )
350{
351 HRESULT hr = S_OK;
352 DWORD dwResult = 0;
353 DWORD dwSignaledIndex = dwCount;
354
355 dwResult = ::WaitForMultipleObjects(dwCount, rghHandles, fWaitAll, dwMilliseconds);
356 if (WAIT_TIMEOUT == dwResult)
357 {
358 ExitFunction1(hr = HRESULT_FROM_WIN32(dwResult));
359 }
360 else if (WAIT_ABANDONED_0 <= dwResult && (WAIT_ABANDONED_0 + dwCount) > dwResult)
361 {
362 dwSignaledIndex = dwResult - WAIT_ABANDONED_0;
363 AppExitOnWin32Error(dwResult, hr, "Abandoned wait for multiple objects, index: %u.", dwSignaledIndex);
364 }
365 else if (WAIT_OBJECT_0 <= dwResult && (WAIT_OBJECT_0 + dwCount) > dwResult)
366 {
367 dwSignaledIndex = dwResult - WAIT_OBJECT_0;
368 }
369 else
370 {
371 AssertSz(WAIT_FAILED == dwResult, "Unexpected return code from WaitForMultipleObjects.");
372 AppExitWithLastError(hr, "Failed to wait for multiple objects.");
373 }
374
375LExit:
376 if (pdwSignaledIndex)
377 {
378 *pdwSignaledIndex = dwSignaledIndex;
379 }
380
381 return hr;
382}
383
316static HRESULT EscapeCommandLineArgument( 384static HRESULT EscapeCommandLineArgument(
317 __in_z LPCWSTR wzArgument, 385 __in_z LPCWSTR wzArgument,
318 __out_z LPWSTR* psczEscaped 386 __out_z LPWSTR* psczEscaped