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.

146 lines
4.8 KiB

  1. /******************************************************************************
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. Instance.cpp
  5. Abstract:
  6. This file contains the implementation of the Taxonomy::Instance class,
  7. which controls the set of files for a specific SKU.
  8. Revision History:
  9. Davide Massarenti (Dmassare) 24/03/2001
  10. created
  11. ******************************************************************************/
  12. #include "stdafx.h"
  13. ////////////////////////////////////////////////////////////////////////////////
  14. Taxonomy::Instance::Instance()
  15. {
  16. m_fSystem = false; // bool m_fSystem;
  17. m_fMUI = false; // bool m_fMUI;
  18. m_fExported = false; // bool m_fExported;
  19. m_dLastUpdated = 0; // DATE m_dLastUpdated;
  20. //
  21. // MPC::wstring m_strLocation;
  22. // MPC::wstring m_strHelpFiles;
  23. // MPC::wstring m_strDatabaseDir;
  24. // MPC::wstring m_strDatabaseFile;
  25. // MPC::wstring m_strIndexFile;
  26. // MPC::wstring m_strIndexDisplayName;
  27. }
  28. HRESULT Taxonomy::operator>>( /*[in]*/ MPC::Serializer& stream, /*[out]*/ Taxonomy::Instance& val )
  29. {
  30. HRESULT hr;
  31. if(SUCCEEDED(hr = (stream >> (InstanceBase&)val )) &&
  32. SUCCEEDED(hr = (stream >> val.m_fSystem )) &&
  33. SUCCEEDED(hr = (stream >> val.m_fMUI )) &&
  34. SUCCEEDED(hr = (stream >> val.m_fExported )) &&
  35. SUCCEEDED(hr = (stream >> val.m_dLastUpdated )) &&
  36. SUCCEEDED(hr = (stream >> val.m_strSystem )) &&
  37. SUCCEEDED(hr = (stream >> val.m_strHelpFiles )) &&
  38. SUCCEEDED(hr = (stream >> val.m_strDatabaseDir )) &&
  39. SUCCEEDED(hr = (stream >> val.m_strDatabaseFile )) &&
  40. SUCCEEDED(hr = (stream >> val.m_strIndexFile )) &&
  41. SUCCEEDED(hr = (stream >> val.m_strIndexDisplayName)) )
  42. {
  43. hr = S_OK;
  44. }
  45. return hr;
  46. }
  47. HRESULT Taxonomy::operator<<( /*[in]*/ MPC::Serializer& stream, /*[in] */ const Taxonomy::Instance& val )
  48. {
  49. HRESULT hr;
  50. if(SUCCEEDED(hr = (stream << (InstanceBase&)val )) &&
  51. SUCCEEDED(hr = (stream << val.m_fSystem )) &&
  52. SUCCEEDED(hr = (stream << val.m_fMUI )) &&
  53. SUCCEEDED(hr = (stream << val.m_fExported )) &&
  54. SUCCEEDED(hr = (stream << val.m_dLastUpdated )) &&
  55. SUCCEEDED(hr = (stream << val.m_strSystem )) &&
  56. SUCCEEDED(hr = (stream << val.m_strHelpFiles )) &&
  57. SUCCEEDED(hr = (stream << val.m_strDatabaseDir )) &&
  58. SUCCEEDED(hr = (stream << val.m_strDatabaseFile )) &&
  59. SUCCEEDED(hr = (stream << val.m_strIndexFile )) &&
  60. SUCCEEDED(hr = (stream << val.m_strIndexDisplayName)) )
  61. {
  62. hr = S_OK;
  63. }
  64. return hr;
  65. }
  66. ////////////////////////////////////////////////////////////////////////////////
  67. static const DWORD l_dwVersion = 0x01534854; // THS 01
  68. HRESULT Taxonomy::Instance::LoadFromStream( /*[in]*/ IStream *pStm )
  69. {
  70. __HCP_FUNC_ENTRY( "Taxonomy::Instance::LoadFromStream" );
  71. HRESULT hr;
  72. MPC::Serializer_IStream stream ( pStm );
  73. MPC::Serializer_Buffering stream2( stream );
  74. DWORD dwVer;
  75. __MPC_EXIT_IF_METHOD_FAILS(hr, stream2 >> dwVer); if(dwVer != l_dwVersion) __MPC_SET_ERROR_AND_EXIT(hr, E_INVALIDARG);
  76. __MPC_EXIT_IF_METHOD_FAILS(hr, stream2 >> *this);
  77. hr = S_OK;
  78. __HCP_FUNC_CLEANUP;
  79. __HCP_FUNC_EXIT(hr);
  80. }
  81. HRESULT Taxonomy::Instance::SaveToStream( /*[in]*/ IStream* pStm ) const
  82. {
  83. __HCP_FUNC_ENTRY( "Taxonomy::Instance::SaveToStream" );
  84. HRESULT hr;
  85. MPC::Serializer_IStream stream ( pStm );
  86. MPC::Serializer_Buffering stream2( stream );
  87. __MPC_EXIT_IF_METHOD_FAILS(hr, stream2 << l_dwVersion);
  88. __MPC_EXIT_IF_METHOD_FAILS(hr, stream2 << *this );
  89. __MPC_EXIT_IF_METHOD_FAILS(hr, stream2.Flush());
  90. hr = S_OK;
  91. __HCP_FUNC_CLEANUP;
  92. __HCP_FUNC_EXIT(hr);
  93. }
  94. ////////////////////////////////////////////////////////////////////////////////
  95. ////////////////////////////////////////////////////////////////////////////////
  96. void Taxonomy::Instance::SetTimeStamp()
  97. {
  98. m_dLastUpdated = MPC::GetLocalTime();
  99. }
  100. HRESULT Taxonomy::Instance::GetFileName( /*[out]*/ MPC::wstring& strFile )
  101. {
  102. WCHAR rgBuf[MAX_PATH]; _snwprintf( rgBuf, MAXSTRLEN(rgBuf), L"%s\\instance_%s_%ld.cab", HC_ROOT_HELPSVC_PKGSTORE, m_ths.GetSKU(), m_ths.GetLanguage() ); rgBuf[MAXSTRLEN(rgBuf)] = 0;
  103. return MPC::SubstituteEnvVariables( strFile = rgBuf );
  104. }