diff options
Diffstat (limited to 'src/wcautil/wcascript.cpp')
| -rw-r--r-- | src/wcautil/wcascript.cpp | 32 |
1 files changed, 7 insertions, 25 deletions
diff --git a/src/wcautil/wcascript.cpp b/src/wcautil/wcascript.cpp index b6629850..a7e98491 100644 --- a/src/wcautil/wcascript.cpp +++ b/src/wcautil/wcascript.cpp | |||
| @@ -247,9 +247,8 @@ extern "C" HRESULT WIXAPI WcaCaScriptWriteString( | |||
| 247 | { | 247 | { |
| 248 | HRESULT hr = S_OK; | 248 | HRESULT hr = S_OK; |
| 249 | DWORD cbFile = 0; | 249 | DWORD cbFile = 0; |
| 250 | DWORD cbWrite = 0; | ||
| 251 | DWORD cbTotalWritten = 0; | ||
| 252 | WCHAR delim[] = { MAGIC_MULTISZ_DELIM }; // magic char followed by NULL terminator | 250 | WCHAR delim[] = { MAGIC_MULTISZ_DELIM }; // magic char followed by NULL terminator |
| 251 | SIZE_T cch = 0; | ||
| 253 | 252 | ||
| 254 | cbFile = ::SetFilePointer(hScript->hScriptFile, 0, NULL, FILE_END); | 253 | cbFile = ::SetFilePointer(hScript->hScriptFile, 0, NULL, FILE_END); |
| 255 | if (INVALID_SET_FILE_POINTER == cbFile) | 254 | if (INVALID_SET_FILE_POINTER == cbFile) |
| @@ -261,32 +260,15 @@ extern "C" HRESULT WIXAPI WcaCaScriptWriteString( | |||
| 261 | // before adding our new data on the end of the file. | 260 | // before adding our new data on the end of the file. |
| 262 | if (0 < cbFile) | 261 | if (0 < cbFile) |
| 263 | { | 262 | { |
| 264 | cbWrite = sizeof(delim); | 263 | hr = FileWriteHandle(hScript->hScriptFile, reinterpret_cast<LPCBYTE>(delim), sizeof(delim)); |
| 265 | cbTotalWritten = 0; | 264 | ExitOnFailure(hr, "Failed to write data to ca script."); |
| 266 | while (cbTotalWritten < cbWrite) | ||
| 267 | { | ||
| 268 | DWORD cbWritten = 0; | ||
| 269 | if (!::WriteFile(hScript->hScriptFile, reinterpret_cast<BYTE*>(delim) + cbTotalWritten, cbWrite - cbTotalWritten, &cbWritten, NULL)) | ||
| 270 | { | ||
| 271 | ExitWithLastError(hr, "Failed to write data to ca script."); | ||
| 272 | } | ||
| 273 | |||
| 274 | cbTotalWritten += cbWritten; | ||
| 275 | } | ||
| 276 | } | 265 | } |
| 277 | 266 | ||
| 278 | cbWrite = lstrlenW(wzValue) * sizeof(WCHAR); | 267 | hr = ::StringCchLengthW(wzValue, STRSAFE_MAX_CCH, reinterpret_cast<size_t*>(&cch)); |
| 279 | cbTotalWritten = 0; | 268 | ExitOnRootFailure(hr, "Failed to get length of ca script string."); |
| 280 | while (cbTotalWritten < cbWrite) | ||
| 281 | { | ||
| 282 | DWORD cbWritten = 0; | ||
| 283 | if (!::WriteFile(hScript->hScriptFile, reinterpret_cast<const BYTE*>(wzValue) + cbTotalWritten, cbWrite - cbTotalWritten, &cbWritten, NULL)) | ||
| 284 | { | ||
| 285 | ExitWithLastError(hr, "Failed to write data to ca script."); | ||
| 286 | } | ||
| 287 | 269 | ||
| 288 | cbTotalWritten += cbWritten; | 270 | hr = FileWriteHandle(hScript->hScriptFile, reinterpret_cast<LPCBYTE>(wzValue), static_cast<DWORD>(cch) * sizeof(WCHAR)); |
| 289 | } | 271 | ExitOnFailure(hr, "Failed to write data to ca script."); |
| 290 | 272 | ||
| 291 | LExit: | 273 | LExit: |
| 292 | return hr; | 274 | return hr; |
