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.

185 lines
4.0 KiB

  1. /*++
  2. Copyright (c) 1998 Microsoft Corporation
  3. Module Name:
  4. FTMan
  5. File Name:
  6. FrSpace.cpp
  7. Abstract:
  8. Implementation of the CFreeSpaceData class. The class that stores all information related
  9. to a free space
  10. Author:
  11. Cristian Teodorescu October 23, 1998
  12. Notes:
  13. Revision History:
  14. --*/
  15. #include "stdafx.h"
  16. #include "FrSpace.h"
  17. #include "Resource.h"
  18. #ifdef _DEBUG
  19. #define new DEBUG_NEW
  20. #undef THIS_FILE
  21. static char THIS_FILE[] = __FILE__;
  22. #endif
  23. ///////////////////////////////////////////////////////////////////////////////////////////////////
  24. // CFreeSpaceData
  25. // Constructor
  26. CFreeSpaceData::CFreeSpaceData(
  27. DWORD dwDiskNumber,
  28. DWORD dwSignature,
  29. LONGLONG llOffset,
  30. LONGLONG llSize,
  31. FREE_SPACE_TYPE wFreeSpaceType,
  32. LONGLONG llCylinderSize,
  33. DWORD dwPartitionCountOnLevel,
  34. DWORD dwExtendedPartitionCountOnLevel,
  35. CItemData* pParentData /* = NULL */)
  36. : CItemData( IT_FreeSpace, pParentData, FALSE ), m_dwDiskNumber(dwDiskNumber),
  37. m_dwSignature(dwSignature), m_llOffset(llOffset), m_llSize(llSize),
  38. m_wFreeSpaceType( wFreeSpaceType ), m_dwFreeSpaceNumber(0), m_llCylinderSize(llCylinderSize),
  39. m_dwPartitionCountOnLevel( dwPartitionCountOnLevel ),
  40. m_dwExtendedPartitionCountOnLevel( dwExtendedPartitionCountOnLevel )
  41. {
  42. }
  43. ////////////////////////////////////////////////////////////////////////////////////////////////////
  44. // Public methods
  45. BOOL CFreeSpaceData::ReadItemInfo( CString& strErrors )
  46. {
  47. MY_TRY
  48. m_bValid = TRUE;
  49. strErrors = _T("");
  50. m_ulNumMembers = 0;
  51. // Retrieve all disks used by this volume
  52. if( !RetrieveDisksSet() )
  53. {
  54. AddError( strErrors, IDS_ERR_RETRIEVE_DISKS_SET, FALSE );
  55. m_bValid = FALSE;
  56. }
  57. m_bIoOK = TRUE;
  58. m_iImage = ComputeImageIndex();
  59. return m_bValid;
  60. MY_CATCH_AND_THROW
  61. }
  62. BOOL CFreeSpaceData::ReadMembers( CObArray& arrMembersData, CString& strErrors )
  63. {
  64. arrMembersData.RemoveAll();
  65. strErrors = _T("");
  66. m_ulNumMembers = 0;
  67. return TRUE;
  68. }
  69. int CFreeSpaceData::ComputeImageIndex() const
  70. {
  71. return II_FreeSpace;
  72. }
  73. BOOL CFreeSpaceData::operator==(CItemData& rData) const
  74. {
  75. MY_TRY
  76. if( rData.GetItemType() != IT_FreeSpace )
  77. return FALSE;
  78. CFreeSpaceData* pFrSpaceData = (CFreeSpaceData*)(&rData);
  79. return( ( m_dwDiskNumber == pFrSpaceData->m_dwDiskNumber ) &&
  80. ( m_dwSignature == pFrSpaceData->m_dwSignature ) &&
  81. ( m_llOffset == pFrSpaceData->m_llOffset ) &&
  82. ( m_llSize == pFrSpaceData->m_llSize ) &&
  83. ( m_wFreeSpaceType == pFrSpaceData->m_wFreeSpaceType ) &&
  84. ( m_llCylinderSize == pFrSpaceData->m_llCylinderSize ) &&
  85. ( m_dwPartitionCountOnLevel == pFrSpaceData->m_dwPartitionCountOnLevel ) &&
  86. ( m_dwExtendedPartitionCountOnLevel == pFrSpaceData->m_dwExtendedPartitionCountOnLevel ) );
  87. MY_CATCH_AND_THROW
  88. }
  89. void CFreeSpaceData::GetDisplayName( CString& strDisplay ) const
  90. {
  91. MY_TRY
  92. strDisplay.Format( IDS_FREE_SPACE_NAME, m_dwDiskNumber, m_dwFreeSpaceNumber );
  93. MY_CATCH_AND_THROW
  94. }
  95. void CFreeSpaceData::GetDisplayType( CString& strDisplay ) const
  96. {
  97. MY_TRY
  98. switch( m_wFreeSpaceType )
  99. {
  100. case FST_Primary:
  101. strDisplay.LoadString( IDS_TYPE_FREE_SPACE );
  102. break;
  103. case FST_InExtendedPartition:
  104. strDisplay.LoadString( IDS_TYPE_FREE_SPACE_IN_EXTENDED_PARTITION );
  105. break;
  106. case FST_EmptyExtendedPartition:
  107. strDisplay.LoadString( IDS_TYPE_EMPTY_EXTENDED_PARTITION );
  108. break;
  109. default:
  110. ASSERT(FALSE);
  111. }
  112. MY_CATCH_AND_THROW
  113. }
  114. BOOL CFreeSpaceData::GetSize( LONGLONG& llSize ) const
  115. {
  116. llSize = m_llSize;
  117. return TRUE;
  118. }
  119. BOOL CFreeSpaceData::GetDiskNumber( ULONG& ulDiskNumber ) const
  120. {
  121. ulDiskNumber = m_dwDiskNumber;
  122. return TRUE;
  123. }
  124. BOOL CFreeSpaceData::GetOffset( LONGLONG& llOffset) const
  125. {
  126. llOffset = m_llOffset;
  127. return TRUE;
  128. }
  129. ////////////////////////////////////////////////////////////////////////////////////////////////////
  130. // Protected methods
  131. BOOL CFreeSpaceData::RetrieveDisksSet()
  132. {
  133. MY_TRY
  134. m_setDisks.RemoveAll();
  135. m_setDisks.Add( m_dwDiskNumber );
  136. return TRUE;
  137. MY_CATCH_AND_THROW
  138. }