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.

152 lines
2.5 KiB

  1. //*******************************************************************************************
  2. //
  3. // Filename : Enum.cpp
  4. //
  5. // Implementation for CEnumCabObjs
  6. //
  7. // Copyright (c) 1994 - 1996 Microsoft Corporation. All rights reserved
  8. //
  9. //*******************************************************************************************
  10. #include "pch.h"
  11. #include "thisdll.h"
  12. #include "enum.h"
  13. // *** IUnknown methods ***
  14. STDMETHODIMP CEnumCabObjs::QueryInterface(
  15. REFIID riid,
  16. LPVOID FAR* ppvObj)
  17. {
  18. *ppvObj = NULL;
  19. LPUNKNOWN pObj;
  20. if (riid == IID_IUnknown)
  21. {
  22. pObj = (IUnknown*)((IEnumIDList*)this);
  23. }
  24. else if (riid == IID_IEnumIDList)
  25. {
  26. pObj = (IUnknown*)((IEnumIDList*)this);
  27. }
  28. else
  29. {
  30. return(E_NOINTERFACE);
  31. }
  32. pObj->AddRef();
  33. *ppvObj = pObj;
  34. return(NOERROR);
  35. }
  36. STDMETHODIMP_(ULONG) CEnumCabObjs::AddRef(void)
  37. {
  38. return(m_cRef.AddRef());
  39. }
  40. STDMETHODIMP_(ULONG) CEnumCabObjs::Release(void)
  41. {
  42. if (!m_cRef.Release())
  43. {
  44. delete this;
  45. return(0);
  46. }
  47. return(m_cRef.GetRef());
  48. }
  49. // *** IEnumIDList methods ***
  50. STDMETHODIMP CEnumCabObjs::Next(ULONG celt,
  51. LPITEMIDLIST *rgelt,
  52. ULONG *pceltFetched)
  53. {
  54. *rgelt = NULL;
  55. if (pceltFetched)
  56. {
  57. *pceltFetched = 0;
  58. }
  59. HRESULT hRes = m_pcfThis->InitItems();
  60. if (FAILED(hRes))
  61. {
  62. return(hRes);
  63. }
  64. for ( ; ; ++m_iCount)
  65. {
  66. if (m_iCount >= m_pcfThis->m_lItems.GetCount())
  67. {
  68. return(S_FALSE);
  69. }
  70. LPCABITEM pit = m_pcfThis->m_lItems[m_iCount];
  71. if ((m_uFlags&(SHCONTF_FOLDERS|SHCONTF_NONFOLDERS))
  72. != (SHCONTF_FOLDERS|SHCONTF_NONFOLDERS))
  73. {
  74. DWORD gfInOut = SFGAO_FOLDER;
  75. if (FAILED(m_pcfThis->GetAttributesOf(1, (LPCITEMIDLIST *)&pit, &gfInOut)))
  76. {
  77. continue;
  78. }
  79. if (!(m_uFlags&SHCONTF_FOLDERS) && (gfInOut&SFGAO_FOLDER))
  80. {
  81. continue;
  82. }
  83. if ((m_uFlags&SHCONTF_FOLDERS) && !(gfInOut&SFGAO_FOLDER))
  84. {
  85. continue;
  86. }
  87. }
  88. if (!(m_uFlags&SHCONTF_INCLUDEHIDDEN)
  89. && (pit->uFileAttribs&(FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM)))
  90. {
  91. continue;
  92. }
  93. break;
  94. }
  95. *rgelt = ILClone((LPCITEMIDLIST)m_pcfThis->m_lItems[m_iCount]);
  96. ++m_iCount;
  97. if (*rgelt)
  98. {
  99. if (pceltFetched)
  100. {
  101. *pceltFetched = 1;
  102. }
  103. return(S_OK);
  104. }
  105. return(E_OUTOFMEMORY);
  106. }
  107. STDMETHODIMP CEnumCabObjs::Skip(ULONG celt)
  108. {
  109. return(E_NOTIMPL);
  110. }
  111. STDMETHODIMP CEnumCabObjs::Reset()
  112. {
  113. m_iCount = 0;
  114. return(NOERROR);
  115. }
  116. STDMETHODIMP CEnumCabObjs::Clone(IEnumIDList **ppenum)
  117. {
  118. return(E_NOTIMPL);
  119. }