Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.9 KiB

  1. #include "precomp.h"
  2. #define NSUBGRPS 10
  3. #define CSOF_FAILIFTHERE 0x80000000L // dependent on shellp.h value
  4. extern TCHAR g_szDestCif[];
  5. extern TCHAR g_szBuildTemp[];
  6. extern TCHAR g_szCustIns[];
  7. extern TCHAR g_szBuildRoot[];
  8. extern BOOL g_fBatch, g_fIntranet;
  9. extern PROPSHEETPAGE g_psp[];
  10. extern int g_iCurPage;
  11. void SetCompSize(LPTSTR szCab, LPTSTR szSect, DWORD dwInstallSize)
  12. {
  13. DWORD dwDownloadSize, dwTolerance, dwsHi, dwLowSize, dwHighSize;
  14. HANDLE hCab = CreateFile(szCab, GENERIC_READ, 0, NULL, OPEN_EXISTING, NULL, NULL);
  15. TCHAR szSize[32];
  16. if (hCab == INVALID_HANDLE_VALUE)
  17. return;
  18. dwDownloadSize = GetFileSize( hCab, &dwsHi ) >> 10;
  19. if (dwInstallSize ==0)
  20. dwInstallSize = dwDownloadSize << 1;
  21. CloseHandle(hCab);
  22. wnsprintf(szSize, countof(szSize), TEXT("%i,%i"), dwDownloadSize, dwInstallSize);
  23. ICifRWComponent * pCifRWComponent;
  24. if (SUCCEEDED(g_lpCifRWFileDest->CreateComponent(szSect, &pCifRWComponent)))
  25. {
  26. pCifRWComponent->SetDownloadSize(dwDownloadSize);
  27. pCifRWComponent->SetExtractSize(dwInstallSize);
  28. pCifRWComponent->SetInstalledSize(0, dwInstallSize);
  29. return;
  30. }
  31. if (dwDownloadSize <= 7)
  32. dwTolerance = 100;
  33. else
  34. {
  35. if (dwDownloadSize > 60)
  36. dwTolerance = 10;
  37. else
  38. dwTolerance = (600 / dwDownloadSize);
  39. }
  40. wnsprintf(szSize, countof(szSize), TEXT("0,%i"), dwInstallSize);
  41. WritePrivateProfileString( szSect, TEXT("InstalledSize"), szSize, g_szDestCif );
  42. dwTolerance = (dwDownloadSize * dwTolerance) / 100;
  43. dwLowSize = dwDownloadSize - dwTolerance;
  44. dwHighSize = dwDownloadSize + dwTolerance;
  45. wnsprintf(szSize, countof(szSize), TEXT("%i,%i"), dwLowSize, dwHighSize);
  46. WritePrivateProfileString( szSect, TEXT("Size1"), szSize, g_szDestCif );
  47. }