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.

89 lines
2.6 KiB

  1. #include "precomp.h"
  2. #include "cabclass.h"
  3. extern TCHAR g_szBuildTemp[];
  4. extern TCHAR g_szWizRoot[];
  5. extern TCHAR g_szCustInf[];
  6. extern TCHAR g_szCustIns[];
  7. extern TCHAR g_szUnsignedFiles[];
  8. extern BOOL g_fDownload;
  9. const TCHAR *CCabMappings::c_szCabNameArray[] = {
  10. { TEXT("BRANDING") },
  11. { TEXT("CHNLS") },
  12. { TEXT("DESKTOP") },
  13. { TEXT("") } // keep the last entry the empty string
  14. };
  15. const FEATUREMAPPING CCabMappings::c_fmFeatureList[] = {
  16. { 0, TEXT("") },
  17. { 0, TEXT("FAVS") },
  18. { 0, TEXT("CONNECT") },
  19. { 1, TEXT("BASE") },
  20. { 2, TEXT("DESKCOMP") },
  21. { 2, TEXT("TOOLBAR") },
  22. { 2, TEXT("MYCPTR") },
  23. { 2, TEXT("CTLPANEL") },
  24. { 0, TEXT("LDAP") },
  25. { 0, TEXT("OE") },
  26. { 2, TEXT("WALLPAPR") },
  27. { 0, TEXT("BTOOLBAR") }
  28. };
  29. void CCabMappings::GetFeatureDir(FEATURE feature, LPTSTR pszDir, BOOL fFullyQualified)
  30. {
  31. if (fFullyQualified)
  32. {
  33. PathCombine(pszDir, g_szBuildTemp, c_szCabNameArray[c_fmFeatureList[feature].index]);
  34. CreateDirectory(pszDir, NULL);
  35. PathAppend(pszDir, c_fmFeatureList[feature].szDirName);
  36. CreateDirectory(pszDir, NULL);
  37. }
  38. else
  39. PathCombine(pszDir, c_szCabNameArray[c_fmFeatureList[feature].index],
  40. c_fmFeatureList[feature].szDirName);
  41. CharLower(pszDir);
  42. }
  43. HRESULT CCabMappings::MakeCab(int index, LPCTSTR pcszDestDir, LPCTSTR pcszCabName)
  44. {
  45. TCHAR szCmd[MAX_PATH * 3];
  46. TCHAR szExePath[MAX_PATH];
  47. TCHAR szCabPath[MAX_PATH];
  48. TCHAR szSrcPath[MAX_PATH];
  49. PathCombine(szExePath, g_szWizRoot, TEXT("TOOLS"));
  50. PathAppend(szExePath, TEXT("CABARC.EXE"));
  51. if (pcszCabName == NULL)
  52. {
  53. PathCombine(szCabPath, pcszDestDir, c_szCabNameArray[index]);
  54. StrCat(szCabPath, TEXT(".CAB"));
  55. }
  56. else
  57. PathCombine(szCabPath, pcszDestDir, pcszCabName);
  58. PathCombine(szSrcPath, g_szBuildTemp, c_szCabNameArray[index]);
  59. PathAppend(szSrcPath, TEXT("*.*"));
  60. wnsprintf(szCmd, countof(szCmd), TEXT("%s -r N %s %s"), szExePath, szCabPath, szSrcPath);
  61. if (!RunAndWait(szCmd, g_szBuildTemp, SW_HIDE))
  62. return E_FAIL;
  63. if (g_fDownload)
  64. SignFile(PathFindFileName(szCabPath), g_szBuildTemp, g_szCustIns, g_szUnsignedFiles, g_szCustInf);
  65. return S_OK;
  66. }
  67. HRESULT CCabMappings::MakeCabs(LPCTSTR pcszDestDir)
  68. {
  69. for (int i=0; *c_szCabNameArray[i]; i++)
  70. {
  71. if (MakeCab(i, pcszDestDir, NULL) != S_OK)
  72. return E_FAIL;
  73. }
  74. return S_OK;
  75. }