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.5 KiB

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 2001, Microsoft Corporation All rights reserved.
  4. //
  5. // Module Name:
  6. //
  7. // FileList.h
  8. //
  9. // Abstract:
  10. //
  11. // This file contains the File List object definition.
  12. //
  13. // Revision History:
  14. //
  15. // 2001-06-20 lguindon Created.
  16. //
  17. ///////////////////////////////////////////////////////////////////////////////
  18. #ifndef _FILELIST_H_
  19. #define _FILELIST_H_
  20. ///////////////////////////////////////////////////////////////////////////////
  21. //
  22. // Includes Files.
  23. //
  24. ///////////////////////////////////////////////////////////////////////////////
  25. #include "infparser.h"
  26. #include "File.h"
  27. ///////////////////////////////////////////////////////////////////////////////
  28. //
  29. // Class definition.
  30. //
  31. ///////////////////////////////////////////////////////////////////////////////
  32. class FileList
  33. {
  34. public:
  35. FileList()
  36. {
  37. m_Head = NULL;
  38. m_Tail = NULL;
  39. m_Entries = 0;
  40. };
  41. ~FileList()
  42. {
  43. free();
  44. };
  45. DWORD getFileNumber() { return (m_Entries); };
  46. File* getFirst() { return (m_Head); };
  47. void add(File* item)
  48. {
  49. if ((m_Tail == NULL) && (m_Head == NULL))
  50. {
  51. m_Tail = item;
  52. m_Head = item;
  53. }
  54. else
  55. {
  56. item->setPrevious(m_Tail);
  57. m_Tail->setNext(item);
  58. m_Tail = item;
  59. }
  60. m_Entries++;
  61. };
  62. void remove(File* item)
  63. {
  64. if ((m_Tail == m_Head) && (m_Tail == item))
  65. {
  66. m_Tail = NULL;
  67. m_Head = NULL;
  68. }
  69. else
  70. {
  71. if (m_Head == item)
  72. {
  73. m_Head = item->getNext();
  74. (item->getNext())->setPrevious(NULL);
  75. }
  76. else if (m_Tail == item)
  77. {
  78. m_Tail = item->getPrevious();
  79. (item->getPrevious())->setNext(NULL);
  80. }
  81. else
  82. {
  83. (item->getPrevious())->setNext(item->getNext());
  84. (item->getNext())->setPrevious(item->getPrevious());
  85. }
  86. }
  87. delete item;
  88. item = NULL;
  89. m_Entries--;
  90. };
  91. BOOL isDirId(BOOL bWindowsDir)
  92. {
  93. File* index;
  94. index = getFirst();
  95. while (index != NULL)
  96. {
  97. if (index->isWindowsDir() == bWindowsDir)
  98. {
  99. return (TRUE);
  100. }
  101. }
  102. return (FALSE);
  103. };
  104. File* search(File* refNode, LPSTR dirBase)
  105. {
  106. File* index;
  107. LPSTR dirNamePtr;
  108. index = getFirst();
  109. while (index != NULL)
  110. {
  111. if (index != refNode)
  112. {
  113. //
  114. // Try a match
  115. //
  116. dirNamePtr = index->getDirectoryDestination();
  117. if (_stricmp(dirNamePtr, dirBase) == 0)
  118. {
  119. return (index);
  120. }
  121. }
  122. //
  123. // Continue the loop.
  124. //
  125. index = index->getNext();
  126. }
  127. return (NULL);
  128. };
  129. void free()
  130. {
  131. File* temp;
  132. while ((temp = getFirst()) != NULL)
  133. {
  134. remove(temp);
  135. }
  136. }
  137. private:
  138. File *m_Head;
  139. File *m_Tail;
  140. DWORD m_Entries;
  141. };
  142. #endif //_FILELIST_H_