main
cpp 33 lines 899 Bytes
Raw
1 // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3 #include "precomp.h"
4
5 int __cdecl wmain(
6 __in int argc,
7 __in LPWSTR argv[]
8 )
9 {
10 HRESULT hr = S_OK;
11 DWORD dwExitCode = 0;
12 LPCWSTR wzDestinationFile = argc > 1 ? argv[1] : NULL;
13 LPCWSTR wzGoodFile = argc > 2 ? argv[2] : NULL;
14 LPCWSTR wzBadFile = argc > 3 ? argv[3] : NULL;
15
16 if (argc != 4)
17 {
18 ExitWithRootFailure(hr, E_INVALIDARG, "Invalid args");
19 }
20
21 if (!::MoveFileW(wzDestinationFile, wzBadFile))
22 {
23 ExitWithLastError(hr, "Failed to move bad file");
24 }
25
26 if (!::MoveFileW(wzGoodFile, wzDestinationFile))
27 {
28 ExitWithLastError(hr, "Failed to move good file");
29 }
30
31 LExit:
32 return FAILED(hr) ? (int)hr : (int)dwExitCode;
33 }