@joebigelow / wix / commits / 570c1134

WIXBUG5809 - jchoover - FileNames may be case sensitive when using LSW, so preserve the case of the file name and make the dictionary case insensitive.

Jacob Hoover committed Jan 31, 2019 at 11:12 UTC 570c113409a6aaab462efec8e223e75a89e4ded0
1 file changed +4 -13
src/dutil/cabcutil.cpp
+4 -13
@@ -302,7 +302,7 @@ extern "C" HRESULT DAPI CabCBegin(
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);
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");
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
@@ -383,16 +383,9 @@ extern "C" HRESULT DAPI CabCAddFile(
383 HRESULT hr = S_OK;
384 CABC_DATA *pcd = reinterpret_cast<CABC_DATA*>(hContext);
385 CABC_FILE *pcfDuplicate = NULL;
386 - LPWSTR sczUpperCaseFile = NULL;
386 LONGLONG llFileSize = 0;
387 PMSIFILEHASHINFO pmfLocalHash = pmfHash;
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 -
389 // Use Smart Cabbing if there are duplicates and if Cabinet Splitting is not desired
390 // For Cabinet Spliting avoid hashing as Smart Cabbing is disabled
391 if(!pcd->fCabinetSplittingEnabled)
@@ -401,7 +394,7 @@ extern "C" HRESULT DAPI CabCAddFile(
394 hr = FileSize(wzFile, &llFileSize);
395 ExitOnFailure(hr, "Failed to check size of file %ls", wzFile);
396
404 - hr = CheckForDuplicateFile(pcd, &pcfDuplicate, sczUpperCaseFile, &pmfLocalHash, llFileSize);
397 + hr = CheckForDuplicateFile(pcd, &pcfDuplicate, wzFile, &pmfLocalHash, llFileSize);
398 ExitOnFailure(hr, "Failed while checking for duplicate of file: %ls", wzFile);
399 }
400
@@ -411,20 +404,18 @@ extern "C" HRESULT DAPI CabCAddFile(
404 hr = ::PtrdiffTToDWord(pcfDuplicate - pcd->prgFiles, &index);
405 ExitOnFailure(hr, "Failed to calculate index of file name: %ls", pcfDuplicate->pwzSourcePath);
406
414 - hr = AddDuplicateFile(pcd, index, sczUpperCaseFile, wzToken, pcd->dwLastFileIndex);
407 + hr = AddDuplicateFile(pcd, index, wzFile, wzToken, pcd->dwLastFileIndex);
408 ExitOnFailure(hr, "Failed to add duplicate of file name: %ls", pcfDuplicate->pwzSourcePath);
409 }
410 else
411 {
419 - hr = AddNonDuplicateFile(pcd, sczUpperCaseFile, wzToken, pmfLocalHash, llFileSize, pcd->dwLastFileIndex);
412 + hr = AddNonDuplicateFile(pcd, wzFile, wzToken, pmfLocalHash, llFileSize, pcd->dwLastFileIndex);
413 ExitOnFailure(hr, "Failed to add non-duplicated file: %ls", wzFile);
414 }
415
416 ++pcd->dwLastFileIndex;
417
418 LExit:
426 - ReleaseStr(sczUpperCaseFile);
427 -
419 // If we allocated a hash struct ourselves, free it
420 if (pmfHash != pmfLocalHash)
421 {