InstallXmlInfo2.cpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #include "StdAfx.h"
  2. #include "InstallXmlInfo2.h"
  3. #include "markup.h"
  4. CInstallXmlInfo2::CInstallXmlInfo2(CString strFile)
  5. {
  6. CMarkup xml;
  7. xml.Load(strFile);
  8. xml.FindElem(); // root ORDER element
  9. xml.IntoElem(); // inside ORDER
  10. if( xml.FindElem(_T("install_dir")) )
  11. {
  12. this->sysPath = GetSysPath(xml.GetAttrib(_T("syspath")));
  13. this->corpPath = sysPath +_T("\\")+xml.GetAttrib(_T("corp"));
  14. this->productPath = corpPath +_T("\\")+xml.GetAttrib(_T("product"));
  15. xml.IntoElem();
  16. if( xml.FindElem(_T("mainapp")) )
  17. {
  18. this->appPath = productPath + _T("\\")+xml.GetData();
  19. list.Add(this->appPath);
  20. }
  21. if( xml.FindElem(_T("data")) )
  22. {
  23. this->dataPath = productPath + _T("\\")+xml.GetData();
  24. list.Add(this->dataPath);
  25. }
  26. if( xml.FindElem(_T("cache")) )
  27. {
  28. this->cachePath = productPath + _T("\\")+xml.GetData();
  29. list.Add(this->cachePath);
  30. }
  31. if( xml.FindElem(_T("log")) )
  32. {
  33. this->logPath = productPath + _T("\\")+xml.GetData();
  34. list.Add(this->logPath);
  35. }
  36. if( xml.FindElem(_T("temp")) )
  37. {
  38. this->tempPath = productPath + _T("\\")+xml.GetData();
  39. }
  40. xml.OutOfElem();
  41. }
  42. /*if( xml.FindElem(_T("file_list")) )
  43. {
  44. xml.IntoElem();
  45. while( xml.FindElem(_T("file")))
  46. {
  47. CFileLocationInfo info;
  48. info.fileName = xml.GetData();
  49. info.fileType = xml.GetAttrib(_T("type"));
  50. info.subDir = xml.GetAttrib(_T("subdir"));
  51. locations.Add(info);
  52. }
  53. xml.OutOfElem();
  54. }*/
  55. xml.OutOfElem();
  56. }
  57. CInstallXmlInfo2::~CInstallXmlInfo2(void)
  58. {
  59. }
  60. CString CInstallXmlInfo2::GetSysPath(CString sEnvironmentName)
  61. {
  62. TCHAR buffer[1024];
  63. DWORD dwRet = GetEnvironmentVariable(sEnvironmentName, buffer, sizeof(buffer));
  64. CString value;
  65. if (dwRet > 0)
  66. {
  67. value = buffer;
  68. }
  69. return value;
  70. }