aboutsummaryrefslogtreecommitdiff
path: root/src/test/burn/TestData/PrereqBaTests/ReplaceConfig/ReplaceConfig.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/burn/TestData/PrereqBaTests/ReplaceConfig/ReplaceConfig.cpp')
-rw-r--r--src/test/burn/TestData/PrereqBaTests/ReplaceConfig/ReplaceConfig.cpp20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/test/burn/TestData/PrereqBaTests/ReplaceConfig/ReplaceConfig.cpp b/src/test/burn/TestData/PrereqBaTests/ReplaceConfig/ReplaceConfig.cpp
index 1fa71bc2..b8172e6b 100644
--- a/src/test/burn/TestData/PrereqBaTests/ReplaceConfig/ReplaceConfig.cpp
+++ b/src/test/burn/TestData/PrereqBaTests/ReplaceConfig/ReplaceConfig.cpp
@@ -7,27 +7,31 @@ int __cdecl wmain(
7 __in LPWSTR argv[] 7 __in LPWSTR argv[]
8 ) 8 )
9{ 9{
10 DWORD er = ERROR_SUCCESS;
10 HRESULT hr = S_OK; 11 HRESULT hr = S_OK;
11 DWORD dwExitCode = 0;
12 LPCWSTR wzDestinationFile = argc > 1 ? argv[1] : NULL; 12 LPCWSTR wzDestinationFile = argc > 1 ? argv[1] : NULL;
13 LPCWSTR wzGoodFile = argc > 2 ? argv[2] : NULL; 13 LPCWSTR wzGoodFile = argc > 2 ? argv[2] : NULL;
14 LPCWSTR wzBadFile = argc > 3 ? argv[3] : NULL; 14 LPCWSTR wzBackupFile = argc > 3 ? argv[3] : NULL;
15 15
16 if (argc != 4) 16 if (!wzDestinationFile || !*wzDestinationFile || !wzGoodFile || !*wzGoodFile)
17 { 17 {
18 ExitWithRootFailure(hr, E_INVALIDARG, "Invalid args"); 18 ExitWithRootFailure(hr, E_INVALIDARG, "Invalid args");
19 } 19 }
20 20
21 if (!::MoveFileW(wzDestinationFile, wzBadFile)) 21 if (wzBackupFile && *wzBackupFile && !::CopyFileW(wzDestinationFile, wzBackupFile, FALSE))
22 { 22 {
23 ExitWithLastError(hr, "Failed to move bad file"); 23 er = ::GetLastError();
24 if (ERROR_PATH_NOT_FOUND != er && ERROR_FILE_NOT_FOUND != er)
25 {
26 ExitOnWin32Error(er, hr, "Failed to copy to backup file");
27 }
24 } 28 }
25 29
26 if (!::MoveFileW(wzGoodFile, wzDestinationFile)) 30 if (!::CopyFileW(wzGoodFile, wzDestinationFile, FALSE))
27 { 31 {
28 ExitWithLastError(hr, "Failed to move good file"); 32 ExitWithLastError(hr, "Failed to copy in good file");
29 } 33 }
30 34
31LExit: 35LExit:
32 return FAILED(hr) ? (int)hr : (int)dwExitCode; 36 return FAILED(hr) ? (int)hr : (int)0;
33} 37}