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.

135 lines
3.7 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1992.
  5. //
  6. // File: msfiter.cxx
  7. //
  8. // Contents: Iterator code for MSF
  9. //
  10. // Classes: None. (Defined in iter.hxx)
  11. //
  12. //--------------------------------------------------------------------------
  13. #include "msfhead.cxx"
  14. #include "h/dirfunc.hxx"
  15. #include "h/msfiter.hxx"
  16. //+-------------------------------------------------------------------------
  17. //
  18. // Member: CMSFIterator::GetNext, public
  19. //
  20. // Synposis: Fill in a stat buffer for the next iteration entry
  21. //
  22. // Effects: Modifies _sidCurrent
  23. //
  24. // Arguments: [pstat] - Stat buffer
  25. //
  26. // Returns: S_OK if call completed OK.
  27. // STG_E_NOMOREFILES if no next entry was found.
  28. //
  29. // Notes:
  30. //
  31. //---------------------------------------------------------------------------
  32. SCODE CMSFIterator::GetNext(STATSTGW *pstat)
  33. {
  34. SCODE sc;
  35. SID sidNext;
  36. msfDebugOut((DEB_TRACE,"In CMSFIterator::GetNext()\n"));
  37. if (_sidChildRoot == NOSTREAM)
  38. msfChk(STG_E_NOMOREFILES);
  39. msfChk(_pdir->FindGreaterEntry(_sidChildRoot, &_dfnCurrent, &sidNext));
  40. // We found another child
  41. CDirEntry *pde;
  42. msfChk(_pdir->GetDirEntry(sidNext, FB_NONE, &pde));
  43. pstat->type = pde->GetFlags();
  44. //Note: The casting below assumes that DfName is always a
  45. // wide character string. If we at some point in
  46. // the future convert to a system where this is not
  47. // true, this code needs to be updated.
  48. msfChk(DfAllocWCS((WCHAR *)pde->GetName()->GetBuffer(), &pstat->pwcsName));
  49. wcscpy(pstat->pwcsName, (WCHAR *)pde->GetName()->GetBuffer());
  50. pstat->ctime = pde->GetTime(WT_CREATION);
  51. pstat->mtime = pde->GetTime(WT_MODIFICATION);
  52. //Don't currently keep access times
  53. pstat->atime = pstat->mtime;
  54. if ((pstat->type & STGTY_REAL) == STGTY_STORAGE)
  55. {
  56. pstat->cbSize.QuadPart = 0;
  57. pstat->clsid = pde->GetClassId();
  58. pstat->grfStateBits = pde->GetUserFlags();
  59. }
  60. else
  61. {
  62. pstat->cbSize.QuadPart = pde->GetSize(_pdir->IsLargeSector());
  63. pstat->clsid = CLSID_NULL;
  64. pstat->grfStateBits = 0;
  65. }
  66. // update our iterator
  67. _dfnCurrent.Set(pde->GetName());
  68. _pdir->ReleaseEntry(sidNext);
  69. msfDebugOut((DEB_TRACE,"Leaving CMSFIterator::GetNext()\n"));
  70. // Fall through
  71. Err:
  72. return sc;
  73. }
  74. //+--------------------------------------------------------------
  75. //
  76. // Member: CMSFIterator::BufferGetNext, public
  77. //
  78. // Synopsis: Fast, fixed-size buffer version of GetNext
  79. // for iterations that don't care about having
  80. // full stat info and an allocated name
  81. //
  82. // Arguments: [pib] - Buffer to fill in
  83. //
  84. // Returns: Appropriate status code
  85. //
  86. // Modifies: [pib]
  87. //
  88. //---------------------------------------------------------------
  89. SCODE CMSFIterator::BufferGetNext(SIterBuffer *pib)
  90. {
  91. SCODE sc;
  92. SID sidNext;
  93. CDirEntry *pdeNext;
  94. msfDebugOut((DEB_ITRACE, "In CMSFIterator::BufferGetNext(%p)\n", pib));
  95. if (_sidChildRoot == NOSTREAM)
  96. msfChk(STG_E_NOMOREFILES);
  97. msfChk(_pdir->FindGreaterEntry(_sidChildRoot, &_dfnCurrent, &sidNext));
  98. msfChk(_pdir->GetDirEntry(sidNext, FB_NONE, &pdeNext));
  99. pib->type = pdeNext->GetFlags();
  100. pib->dfnName = *(pdeNext->GetName());
  101. // update our iterator
  102. _dfnCurrent.Set(pdeNext->GetName());
  103. _pdir->ReleaseEntry(sidNext);
  104. msfDebugOut((DEB_ITRACE, "Out CMSFIterator::BufferGetNext\n"));
  105. // Fall through
  106. Err:
  107. return sc;
  108. }