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.

156 lines
3.3 KiB

  1. #include "stdafx.h"
  2. #include "mimemapc.h"
  3. CMimeMap::CMimeMap ( LPCTSTR pchOriginalMimeMap)
  4. {
  5. CString strOriginalMimeMap = pchOriginalMimeMap;
  6. int iCharIndex;
  7. //Save this away and never change it.
  8. m_strPrevMimeMap = pchOriginalMimeMap;
  9. if ((iCharIndex = strOriginalMimeMap.Find(',')) != -1) {
  10. m_strMimeType = strOriginalMimeMap.Left(iCharIndex);
  11. strOriginalMimeMap = strOriginalMimeMap.Mid(iCharIndex + 1);
  12. }
  13. else {
  14. m_strMimeType = strOriginalMimeMap;
  15. strOriginalMimeMap = _T("");
  16. }
  17. if ((iCharIndex = strOriginalMimeMap.Find(',')) != -1) {
  18. m_strFileExtension = strOriginalMimeMap.Left(iCharIndex);
  19. strOriginalMimeMap = strOriginalMimeMap.Mid(iCharIndex + 1);
  20. }
  21. else {
  22. m_strFileExtension = strOriginalMimeMap;
  23. strOriginalMimeMap = _T("");
  24. }
  25. if ((iCharIndex = strOriginalMimeMap.Find(',')) != -1) {
  26. m_strImageFile = strOriginalMimeMap.Left(iCharIndex);
  27. strOriginalMimeMap = strOriginalMimeMap.Mid(iCharIndex + 1);
  28. }
  29. else {
  30. m_strImageFile = strOriginalMimeMap;
  31. strOriginalMimeMap = _T("");
  32. }
  33. m_strGopherType = strOriginalMimeMap;
  34. }
  35. CMimeMap::CMimeMap ( LPCTSTR pchFileExtension, LPCTSTR pchMimeType, LPCTSTR pchImageFile, LPCTSTR pchGopherType)
  36. {
  37. m_strPrevMimeMap = _T("");
  38. m_strMimeType = pchMimeType;
  39. SetFileExtension(pchFileExtension);
  40. m_strImageFile = pchImageFile;
  41. m_strGopherType = pchGopherType;
  42. }
  43. CMimeMap::~CMimeMap()
  44. {
  45. }
  46. void CMimeMap::SetMimeType(LPCTSTR pchMimeType)
  47. {
  48. m_strMimeType = pchMimeType;
  49. }
  50. LPCTSTR CMimeMap::GetMimeType()
  51. {
  52. return (m_strMimeType);
  53. }
  54. void CMimeMap::SetGopherType(LPCTSTR pchGopherType)
  55. {
  56. m_strGopherType = pchGopherType;
  57. }
  58. LPCTSTR CMimeMap::GetGopherType()
  59. {
  60. return (m_strGopherType);
  61. }
  62. void CMimeMap::SetImageFile(LPCTSTR pchImageFile)
  63. {
  64. m_strImageFile = pchImageFile;
  65. }
  66. LPCTSTR CMimeMap::GetImageFile()
  67. {
  68. return(m_strImageFile);
  69. }
  70. void CMimeMap::SetFileExtension(LPCTSTR pchFileExtension)
  71. {
  72. CString strTempFileExtension = pchFileExtension;
  73. CheckDot(strTempFileExtension);
  74. m_strFileExtension = strTempFileExtension;
  75. }
  76. LPCTSTR CMimeMap::GetFileExtension()
  77. {
  78. return(m_strFileExtension);
  79. }
  80. LPCTSTR CMimeMap::GetPrevMimeMap()
  81. {
  82. return(m_strPrevMimeMap);
  83. }
  84. void CMimeMap::SetPrevMimeMap()
  85. {
  86. m_strPrevMimeMap = GetMimeMapping();
  87. }
  88. BOOL CMimeMap::PrevMimeMapExists()
  89. {
  90. return (m_strPrevMimeMap != _T(""));
  91. }
  92. ////////////////////////////////////////////////////////////////////////////////
  93. // Private functions
  94. LPCTSTR CMimeMap::GetMimeMapping()
  95. {
  96. m_strCurrentMimeMap = m_strMimeType;
  97. m_strCurrentMimeMap += _T(",");
  98. m_strCurrentMimeMap += m_strFileExtension;
  99. m_strCurrentMimeMap += _T(",");
  100. m_strCurrentMimeMap += m_strImageFile;
  101. m_strCurrentMimeMap += _T(",");
  102. m_strCurrentMimeMap += m_strGopherType;
  103. return (m_strCurrentMimeMap);
  104. }
  105. LPCTSTR CMimeMap::GetDisplayString()
  106. {
  107. m_strDisplayString = m_strFileExtension;
  108. m_strDisplayString += _T("\t");
  109. m_strDisplayString += m_strMimeType;
  110. m_strDisplayString += _T("\t");
  111. m_strDisplayString += m_strGopherType;
  112. return (m_strDisplayString);
  113. }
  114. void CMimeMap::CheckDot(CString &strFileExtension)
  115. {
  116. if (strFileExtension.Left(1) == _T(".")) {
  117. CString strTemp = strFileExtension.Mid(1);
  118. strFileExtension = strTemp;
  119. }
  120. }