aboutsummaryrefslogtreecommitdiff
path: root/src/libs/dutil/WixToolset.DUtil/file2utl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/dutil/WixToolset.DUtil/file2utl.cpp')
-rw-r--r--src/libs/dutil/WixToolset.DUtil/file2utl.cpp31
1 files changed, 19 insertions, 12 deletions
diff --git a/src/libs/dutil/WixToolset.DUtil/file2utl.cpp b/src/libs/dutil/WixToolset.DUtil/file2utl.cpp
index 88f8377c..3ab47f59 100644
--- a/src/libs/dutil/WixToolset.DUtil/file2utl.cpp
+++ b/src/libs/dutil/WixToolset.DUtil/file2utl.cpp
@@ -16,6 +16,7 @@
16#define FileExitOnInvalidHandleWithLastError(p, x, s, ...) ExitOnInvalidHandleWithLastErrorSource(DUTIL_SOURCE_FILEUTIL, p, x, s, __VA_ARGS__) 16#define FileExitOnInvalidHandleWithLastError(p, x, s, ...) ExitOnInvalidHandleWithLastErrorSource(DUTIL_SOURCE_FILEUTIL, p, x, s, __VA_ARGS__)
17#define FileExitOnWin32Error(e, x, s, ...) ExitOnWin32ErrorSource(DUTIL_SOURCE_FILEUTIL, e, x, s, __VA_ARGS__) 17#define FileExitOnWin32Error(e, x, s, ...) ExitOnWin32ErrorSource(DUTIL_SOURCE_FILEUTIL, e, x, s, __VA_ARGS__)
18#define FileExitOnGdipFailure(g, x, s, ...) ExitOnGdipFailureSource(DUTIL_SOURCE_FILEUTIL, g, x, s, __VA_ARGS__) 18#define FileExitOnGdipFailure(g, x, s, ...) ExitOnGdipFailureSource(DUTIL_SOURCE_FILEUTIL, g, x, s, __VA_ARGS__)
19#define FileExitOnPathFailure(x, b, s, ...) ExitOnPathFailureSource(DUTIL_SOURCE_FILEUTIL, x, b, s, __VA_ARGS__)
19 20
20// constants 21// constants
21 22
@@ -35,6 +36,7 @@ extern "C" BOOL DAPI FileExistsAfterRestart(
35{ 36{
36 HRESULT hr = S_OK; 37 HRESULT hr = S_OK;
37 BOOL fExists = FALSE; 38 BOOL fExists = FALSE;
39 BOOL fRegExists = FALSE;
38 HKEY hkPendingFileRename = NULL; 40 HKEY hkPendingFileRename = NULL;
39 LPWSTR* rgsczRenames = NULL; 41 LPWSTR* rgsczRenames = NULL;
40 DWORD cRenames = 0; 42 DWORD cRenames = 0;
@@ -44,18 +46,20 @@ extern "C" BOOL DAPI FileExistsAfterRestart(
44 if (fExists) 46 if (fExists)
45 { 47 {
46 hr = RegOpen(HKEY_LOCAL_MACHINE, REGISTRY_PENDING_FILE_RENAME_KEY, KEY_QUERY_VALUE, &hkPendingFileRename); 48 hr = RegOpen(HKEY_LOCAL_MACHINE, REGISTRY_PENDING_FILE_RENAME_KEY, KEY_QUERY_VALUE, &hkPendingFileRename);
47 if (E_FILENOTFOUND == hr) 49 FileExitOnPathFailure(hr, fRegExists, "Failed to open pending file rename registry key.");
50
51 if (!fRegExists)
48 { 52 {
49 ExitFunction1(hr = S_OK); 53 ExitFunction();
50 } 54 }
51 FileExitOnFailure(hr, "Failed to open pending file rename registry key.");
52 55
53 hr = RegReadStringArray(hkPendingFileRename, REGISTRY_PENDING_FILE_RENAME_VALUE, &rgsczRenames, &cRenames); 56 hr = RegReadStringArray(hkPendingFileRename, REGISTRY_PENDING_FILE_RENAME_VALUE, &rgsczRenames, &cRenames);
54 if (E_FILENOTFOUND == hr) 57 FileExitOnPathFailure(hr, fRegExists, "Failed to read pending file renames.");
58
59 if (!fRegExists)
55 { 60 {
56 ExitFunction1(hr = S_OK); 61 ExitFunction();
57 } 62 }
58 FileExitOnFailure(hr, "Failed to read pending file renames.");
59 63
60 // The pending file renames array is pairs of source and target paths. We only care 64 // The pending file renames array is pairs of source and target paths. We only care
61 // about checking the source paths so skip the target paths (i += 2). 65 // about checking the source paths so skip the target paths (i += 2).
@@ -95,6 +99,7 @@ extern "C" HRESULT DAPI FileRemoveFromPendingRename(
95{ 99{
96 HRESULT hr = S_OK; 100 HRESULT hr = S_OK;
97 HKEY hkPendingFileRename = NULL; 101 HKEY hkPendingFileRename = NULL;
102 BOOL fExists = FALSE;
98 LPWSTR* rgsczRenames = NULL; 103 LPWSTR* rgsczRenames = NULL;
99 DWORD cRenames = 0; 104 DWORD cRenames = 0;
100 BOOL fPathEqual = FALSE; 105 BOOL fPathEqual = FALSE;
@@ -102,18 +107,20 @@ extern "C" HRESULT DAPI FileRemoveFromPendingRename(
102 DWORD cNewRenames = 0; 107 DWORD cNewRenames = 0;
103 108
104 hr = RegOpen(HKEY_LOCAL_MACHINE, REGISTRY_PENDING_FILE_RENAME_KEY, KEY_QUERY_VALUE | KEY_SET_VALUE, &hkPendingFileRename); 109 hr = RegOpen(HKEY_LOCAL_MACHINE, REGISTRY_PENDING_FILE_RENAME_KEY, KEY_QUERY_VALUE | KEY_SET_VALUE, &hkPendingFileRename);
105 if (E_FILENOTFOUND == hr) 110 FileExitOnPathFailure(hr, fExists, "Failed to open pending file rename registry key.");
111
112 if (!fExists)
106 { 113 {
107 ExitFunction1(hr = S_OK); 114 ExitFunction();
108 } 115 }
109 FileExitOnFailure(hr, "Failed to open pending file rename registry key.");
110 116
111 hr = RegReadStringArray(hkPendingFileRename, REGISTRY_PENDING_FILE_RENAME_VALUE, &rgsczRenames, &cRenames); 117 hr = RegReadStringArray(hkPendingFileRename, REGISTRY_PENDING_FILE_RENAME_VALUE, &rgsczRenames, &cRenames);
112 if (E_FILENOTFOUND == hr) 118 FileExitOnPathFailure(hr, fExists, "Failed to read pending file renames.");
119
120 if (!fExists)
113 { 121 {
114 ExitFunction1(hr = S_OK); 122 ExitFunction();
115 } 123 }
116 FileExitOnFailure(hr, "Failed to read pending file renames.");
117 124
118 // The pending file renames array is pairs of source and target paths. We only care 125 // The pending file renames array is pairs of source and target paths. We only care
119 // about checking the source paths so skip the target paths (i += 2). 126 // about checking the source paths so skip the target paths (i += 2).