aboutsummaryrefslogtreecommitdiff
path: root/src/dtf/SfxCA
diff options
context:
space:
mode:
Diffstat (limited to 'src/dtf/SfxCA')
-rw-r--r--src/dtf/SfxCA/SfxUtil.cpp32
1 files changed, 6 insertions, 26 deletions
diff --git a/src/dtf/SfxCA/SfxUtil.cpp b/src/dtf/SfxCA/SfxUtil.cpp
index 2e6b0555..32dc6e04 100644
--- a/src/dtf/SfxCA/SfxUtil.cpp
+++ b/src/dtf/SfxCA/SfxUtil.cpp
@@ -164,38 +164,18 @@ bool ExtractToTempDirectory(__in MSIHANDLE hSession, __in HMODULE hModule,
164 StringCchCopy(szTempDir, cchTempDirBuf, szModule); 164 StringCchCopy(szTempDir, cchTempDirBuf, szModule);
165 StringCchCat(szTempDir, cchTempDirBuf, L"-"); 165 StringCchCat(szTempDir, cchTempDirBuf, L"-");
166 166
167 BOOL fCreatedDirectory = FALSE;
167 DWORD cchTempDir = (DWORD) wcslen(szTempDir); 168 DWORD cchTempDir = (DWORD) wcslen(szTempDir);
168 for (int i = 0; DirectoryExists(szTempDir); i++) 169 for (int i = 0; i < 10000 && !fCreatedDirectory; i++)
169 { 170 {
170 swprintf_s(szTempDir + cchTempDir, cchTempDirBuf - cchTempDir, L"%d", i); 171 swprintf_s(szTempDir + cchTempDir, cchTempDirBuf - cchTempDir, L"%d", i);
172 fCreatedDirectory = ::CreateDirectory(szTempDir, NULL);
171 } 173 }
172 174
173 if (!CreateDirectory(szTempDir, NULL)) 175 if (!fCreatedDirectory)
174 { 176 {
175 cchCopied = GetTempPath(cchTempDirBuf, szTempDir); 177 Log(hSession, L"Failed to create temp directory. Error code %d", ::GetLastError());
176 if (cchCopied == 0 || cchCopied >= cchTempDirBuf) 178 return false;
177 {
178 Log(hSession, L"Failed to get temp directory. Error code %d", GetLastError());
179 return false;
180 }
181
182 wchar_t* szModuleName = wcsrchr(szModule, L'\\');
183 if (szModuleName == NULL) szModuleName = szModule;
184 else szModuleName = szModuleName + 1;
185 StringCchCat(szTempDir, cchTempDirBuf, szModuleName);
186 StringCchCat(szTempDir, cchTempDirBuf, L"-");
187
188 cchTempDir = (DWORD) wcslen(szTempDir);
189 for (int i = 0; DirectoryExists(szTempDir); i++)
190 {
191 swprintf_s(szTempDir + cchTempDir, cchTempDirBuf - cchTempDir, L"%d", i);
192 }
193
194 if (!CreateDirectory(szTempDir, NULL))
195 {
196 Log(hSession, L"Failed to create temp directory. Error code %d", GetLastError());
197 return false;
198 }
199 } 179 }
200 180
201 Log(hSession, L"Extracting custom action to temporary directory: %s\\", szTempDir); 181 Log(hSession, L"Extracting custom action to temporary directory: %s\\", szTempDir);