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.

132 lines
2.4 KiB

  1. /*++
  2. Copyright (c) 1998 Microsoft Corporation
  3. Module Name:
  4. FTMan
  5. File Name:
  6. RootFree.cpp
  7. Abstract:
  8. Implementation of the CRootFreeSpacesData class. The class who stores the properties of the "fake" root of the
  9. free space tree
  10. Author:
  11. Cristian Teodorescu October 22, 1998
  12. Notes:
  13. Revision History:
  14. --*/
  15. #include "stdafx.h"
  16. #include "DiskMap.h"
  17. #include "FrSpace.h"
  18. #include "Resource.h"
  19. #include "RootFree.h"
  20. #ifdef _DEBUG
  21. #define new DEBUG_NEW
  22. #undef THIS_FILE
  23. static char THIS_FILE[] = __FILE__;
  24. #endif
  25. ///////////////////////////////////////////////////////////////////////////////////////////////////
  26. // CRootFreeSpacesData
  27. // Constructor
  28. CRootFreeSpacesData::CRootFreeSpacesData() : CItemData( IT_RootFreeSpaces, NULL, FALSE )
  29. {
  30. }
  31. ////////////////////////////////////////////////////////////////////////////////////////////////////
  32. // Public methods
  33. BOOL CRootFreeSpacesData::ReadItemInfo( CString& strErrors )
  34. {
  35. MY_TRY
  36. m_bValid = TRUE;
  37. strErrors = _T("");
  38. m_ulNumMembers = 1; // Just to notify the tree that this item has children
  39. m_iImage = ComputeImageIndex();
  40. return m_bValid;
  41. MY_CATCH_AND_THROW
  42. }
  43. BOOL CRootFreeSpacesData::ReadMembers( CObArray& arrMembersData, CString& strErrors )
  44. {
  45. MY_TRY
  46. BOOL bReturn = TRUE;
  47. arrMembersData.RemoveAll();
  48. strErrors = _T("");
  49. m_ulNumMembers = 0;
  50. CDiskMap diskMap;
  51. for( DWORD dwDiskNumber = 0; ; dwDiskNumber++ )
  52. {
  53. CObArray arrFreeSpaces;
  54. CString strDiskMapErrors;
  55. BOOL bMissingDisk;
  56. diskMap.SetDiskNumber(dwDiskNumber);
  57. BOOL bResult = diskMap.ReadFreeSpaces( arrFreeSpaces, strDiskMapErrors, bMissingDisk, this );
  58. strErrors += strDiskMapErrors;
  59. if( !bResult )
  60. {
  61. if( bMissingDisk ) // It's over. There are no more disks in the system
  62. break;
  63. else // Continue with the following disk
  64. {
  65. bReturn = FALSE;
  66. continue;
  67. }
  68. }
  69. arrMembersData.Append(arrFreeSpaces);
  70. m_ulNumMembers += (ULONG)arrFreeSpaces.GetSize();
  71. }
  72. return bReturn;
  73. MY_CATCH_AND_THROW
  74. }
  75. int CRootFreeSpacesData::ComputeImageIndex() const
  76. {
  77. return II_Root;
  78. }
  79. BOOL CRootFreeSpacesData::operator==(CItemData& rData) const
  80. {
  81. return(rData.GetItemType() == IT_RootFreeSpaces );
  82. }
  83. void CRootFreeSpacesData::GetDisplayName( CString& strDisplay ) const
  84. {
  85. MY_TRY
  86. strDisplay.LoadString(IDS_ROOT_FREE_SPACES_DISPLAY_NAME);
  87. MY_CATCH_AND_THROW
  88. }
  89. ////////////////////////////////////////////////////////////////////////////////////////////////////
  90. // Protected methods
  91.