Source code of Windows XP (NT5)
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.

125 lines
2.7 KiB

  1. // Implementation of class CFileNode
  2. //
  3. // During parsing an inf file, information about each file
  4. // is stored in an instance of this class. Such information
  5. // includes the name of the file, its section in the inf file,
  6. // its location (directory), etc.
  7. #include "filenode.h"
  8. CPNode::CPNode(LPCTSTR szName)
  9. {
  10. Assert (szName != NULL);
  11. lstrcpyn(m_szName, szName, MAX_PATH);
  12. m_pNext = NULL;
  13. m_bRemovable = FALSE;
  14. }
  15. CPNode::~CPNode()
  16. {
  17. if (m_pNext != NULL)
  18. delete m_pNext;
  19. }
  20. // insert a new file node into list
  21. //HRESULT CFileNode::Insert(LPCTSTR szName, LPCTSTR szSection)
  22. HRESULT CPNode::Insert(CPNode* pNewNode)
  23. {
  24. if (pNewNode == NULL)
  25. return HRESULT_FROM_WIN32(ERROR_BAD_ARGUMENTS);
  26. m_pNext = pNewNode;
  27. return S_OK;
  28. }
  29. // get the file node placed right after this one in list
  30. CPNode* CPNode::GetNext() const
  31. {
  32. return m_pNext;
  33. }
  34. // tell the path in which this file is located
  35. HRESULT CPNode::SetStr(LPTSTR lpszMember, LPCTSTR lpszNew )
  36. {
  37. Assert (lpszNew != NULL);
  38. if (lpszNew == NULL)
  39. return HRESULT_FROM_WIN32(ERROR_BAD_ARGUMENTS);
  40. lstrcpyn(lpszMember, lpszNew, MAX_PATH); // all our string members are MAX_PATH
  41. return S_OK;
  42. }
  43. // retrieve the name of the file represented by this node
  44. LPCTSTR CPNode::GetName() const
  45. {
  46. return m_szName;
  47. }
  48. // retrieve the path of the file represented by this node
  49. LPCTSTR CPNode::GetPath() const
  50. {
  51. return (m_szPath[0] == '\0' ? NULL : m_szPath);
  52. }
  53. // constructor
  54. CPackageNode::CPackageNode(LPCTSTR szName, LPCTSTR szNamespace, LPCTSTR szPath) : CPNode(szName)
  55. {
  56. Assert (szNamespace != NULL);
  57. lstrcpyn(m_szName, szName, MAX_PATH);
  58. lstrcpyn(m_szNamespace, szNamespace, MAX_PATH);
  59. if (szPath != NULL)
  60. {
  61. lstrcpyn(m_szPath, szPath, MAX_PATH);
  62. }
  63. else
  64. {
  65. m_szPath[0] = '\0';
  66. }
  67. m_pNext = NULL;
  68. m_fIsSystemClass = FALSE;
  69. }
  70. // destructor
  71. CPackageNode::~CPackageNode()
  72. {
  73. }
  74. // retrieve the name of the section in the inf file which
  75. // which the file represented by this node was installed
  76. LPCTSTR CPackageNode::GetNamespace() const
  77. {
  78. return m_szNamespace;
  79. }
  80. // constructor
  81. CFileNode::CFileNode(LPCTSTR szName, LPCTSTR szSection, LPCTSTR szPath) : CPNode(szName)
  82. {
  83. Assert (szSection != NULL);
  84. lstrcpyn(m_szName, szName, MAX_PATH);
  85. lstrcpyn(m_szSection, szSection, MAX_PATH);
  86. if (szPath != NULL)
  87. {
  88. lstrcpyn(m_szPath, szPath, MAX_PATH);
  89. }
  90. else
  91. {
  92. m_szPath[0] = '\0';
  93. }
  94. m_pNext = NULL;
  95. }
  96. // destructor
  97. CFileNode::~CFileNode()
  98. {
  99. }
  100. // retrieve the name of the section in the inf file which
  101. // which the file represented by this node was installed
  102. LPCTSTR CFileNode::GetSection() const
  103. {
  104. return m_szSection;
  105. }