aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Hoover <jacob.hoover@greenheck.com>2019-01-31 11:12:42 -0600
committerRob Mensching <rob@robmensching.com>2019-01-31 09:24:16 -0800
commit570c113409a6aaab462efec8e223e75a89e4ded0 (patch)
tree4a8a37736982597ca9830e061d3d8d5346359c95
parentf8c806374a2fdbf8fb85a654d561e37a419f5ea3 (diff)
downloadwix-570c113409a6aaab462efec8e223e75a89e4ded0.tar.gz
wix-570c113409a6aaab462efec8e223e75a89e4ded0.tar.bz2
wix-570c113409a6aaab462efec8e223e75a89e4ded0.zip
WIXBUG5809 - jchoover - FileNames may be case sensitive when using LSW, so preserve the case of the file name and make the dictionary case insensitive.
-rw-r--r--src/dutil/cabcutil.cpp17
1 files changed, 4 insertions, 13 deletions
diff --git a/src/dutil/cabcutil.cpp b/src/dutil/cabcutil.cpp
index 35fefaba..8619822d 100644
--- a/src/dutil/cabcutil.cpp
+++ b/src/dutil/cabcutil.cpp
@@ -302,7 +302,7 @@ extern "C" HRESULT DAPI CabCBegin(
302 // case is we'll leave a zero byte file behind in the temp folder. 302 // case is we'll leave a zero byte file behind in the temp folder.
303 pcd->hEmptyFile = ::CreateFileW(pcd->wzEmptyFile, 0, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_TEMPORARY | FILE_FLAG_DELETE_ON_CLOSE, NULL); 303 pcd->hEmptyFile = ::CreateFileW(pcd->wzEmptyFile, 0, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_TEMPORARY | FILE_FLAG_DELETE_ON_CLOSE, NULL);
304 304
305 hr = DictCreateWithEmbeddedKey(&pcd->shDictHandle, dwMaxFiles, reinterpret_cast<void **>(&pcd->prgFiles), offsetof(CABC_FILE, pwzSourcePath), DICT_FLAG_NONE); 305 hr = DictCreateWithEmbeddedKey(&pcd->shDictHandle, dwMaxFiles, reinterpret_cast<void **>(&pcd->prgFiles), offsetof(CABC_FILE, pwzSourcePath), DICT_FLAG_CASEINSENSITIVE);
306 ExitOnFailure(hr, "Failed to create dictionary to keep track of duplicate files"); 306 ExitOnFailure(hr, "Failed to create dictionary to keep track of duplicate files");
307 307
308 // Make sure to allocate at least some space, or we won't be able to realloc later if they "lied" about having zero files 308 // Make sure to allocate at least some space, or we won't be able to realloc later if they "lied" about having zero files
@@ -383,16 +383,9 @@ extern "C" HRESULT DAPI CabCAddFile(
383 HRESULT hr = S_OK; 383 HRESULT hr = S_OK;
384 CABC_DATA *pcd = reinterpret_cast<CABC_DATA*>(hContext); 384 CABC_DATA *pcd = reinterpret_cast<CABC_DATA*>(hContext);
385 CABC_FILE *pcfDuplicate = NULL; 385 CABC_FILE *pcfDuplicate = NULL;
386 LPWSTR sczUpperCaseFile = NULL;
387 LONGLONG llFileSize = 0; 386 LONGLONG llFileSize = 0;
388 PMSIFILEHASHINFO pmfLocalHash = pmfHash; 387 PMSIFILEHASHINFO pmfLocalHash = pmfHash;
389 388
390 hr = StrAllocString(&sczUpperCaseFile, wzFile, 0);
391 ExitOnFailure(hr, "Failed to allocate new string for file %ls", wzFile);
392
393 // Modifies the string in-place
394 StrStringToUpper(sczUpperCaseFile);
395
396 // Use Smart Cabbing if there are duplicates and if Cabinet Splitting is not desired 389 // Use Smart Cabbing if there are duplicates and if Cabinet Splitting is not desired
397 // For Cabinet Spliting avoid hashing as Smart Cabbing is disabled 390 // For Cabinet Spliting avoid hashing as Smart Cabbing is disabled
398 if(!pcd->fCabinetSplittingEnabled) 391 if(!pcd->fCabinetSplittingEnabled)
@@ -401,7 +394,7 @@ extern "C" HRESULT DAPI CabCAddFile(
401 hr = FileSize(wzFile, &llFileSize); 394 hr = FileSize(wzFile, &llFileSize);
402 ExitOnFailure(hr, "Failed to check size of file %ls", wzFile); 395 ExitOnFailure(hr, "Failed to check size of file %ls", wzFile);
403 396
404 hr = CheckForDuplicateFile(pcd, &pcfDuplicate, sczUpperCaseFile, &pmfLocalHash, llFileSize); 397 hr = CheckForDuplicateFile(pcd, &pcfDuplicate, wzFile, &pmfLocalHash, llFileSize);
405 ExitOnFailure(hr, "Failed while checking for duplicate of file: %ls", wzFile); 398 ExitOnFailure(hr, "Failed while checking for duplicate of file: %ls", wzFile);
406 } 399 }
407 400
@@ -411,20 +404,18 @@ extern "C" HRESULT DAPI CabCAddFile(
411 hr = ::PtrdiffTToDWord(pcfDuplicate - pcd->prgFiles, &index); 404 hr = ::PtrdiffTToDWord(pcfDuplicate - pcd->prgFiles, &index);
412 ExitOnFailure(hr, "Failed to calculate index of file name: %ls", pcfDuplicate->pwzSourcePath); 405 ExitOnFailure(hr, "Failed to calculate index of file name: %ls", pcfDuplicate->pwzSourcePath);
413 406
414 hr = AddDuplicateFile(pcd, index, sczUpperCaseFile, wzToken, pcd->dwLastFileIndex); 407 hr = AddDuplicateFile(pcd, index, wzFile, wzToken, pcd->dwLastFileIndex);
415 ExitOnFailure(hr, "Failed to add duplicate of file name: %ls", pcfDuplicate->pwzSourcePath); 408 ExitOnFailure(hr, "Failed to add duplicate of file name: %ls", pcfDuplicate->pwzSourcePath);
416 } 409 }
417 else 410 else
418 { 411 {
419 hr = AddNonDuplicateFile(pcd, sczUpperCaseFile, wzToken, pmfLocalHash, llFileSize, pcd->dwLastFileIndex); 412 hr = AddNonDuplicateFile(pcd, wzFile, wzToken, pmfLocalHash, llFileSize, pcd->dwLastFileIndex);
420 ExitOnFailure(hr, "Failed to add non-duplicated file: %ls", wzFile); 413 ExitOnFailure(hr, "Failed to add non-duplicated file: %ls", wzFile);
421 } 414 }
422 415
423 ++pcd->dwLastFileIndex; 416 ++pcd->dwLastFileIndex;
424 417
425LExit: 418LExit:
426 ReleaseStr(sczUpperCaseFile);
427
428 // If we allocated a hash struct ourselves, free it 419 // If we allocated a hash struct ourselves, free it
429 if (pmfHash != pmfLocalHash) 420 if (pmfHash != pmfLocalHash)
430 { 421 {