Namespace System
Namespace IO


Enum DriveType
	Unknown = 0
	NoRootDirectory
	Removable
	Fixed
	CDRom
	Network
	Ram
End Enum

Class DriveInfo
	m_DriveName As String
Public
	Sub DriveInfo(driveName As String)
		If driveName.Length <> 1 Then
			'ArgumentException
			debug
		End If
		driveName.ToUpper()
		m_DriveName = driveName + ":\"
	End Sub

	Sub ~DriveInfo()
	End Sub

	'property
	Function AvailableFreeSpace() As QWord
		Dim availableFreeSpace As ULARGE_INTEGER
		If GetDiskFreeSpaceEx(m_DriveName, availableFreeSpace, ByVal 0, ByVal 0) Then
			Return (availableFreeSpace.HighPart << 32) Or availableFreeSpace.LowPart
		Else
			'IOException
		End If
	End Function

	Function DriveFormat() As String
		Dim systemName[15] As TCHAR
		If GetVolumeInformation(m_DriveName, NULL, 0, NULL, NULL, NULL, systemName, Len (systemName)) Then
			Dim resultStr = New String( systemName )
			Return resultStr
		Else
			'IOException
		End If
	End Function

	Function DriveType() As Long
		Return GetDriveType(m_DriveName)
	End Function

	Function IsReady() As Boolean
		If GetVolumeInformation(m_DriveName, NULL, 0, NULL, NULL, NULL, NULL, 0) Then
			Return True
		Else
			Return False
		End If
	End Function

	Function Name() As String
		Return m_DriveName
	End Function

/*	Function RootDirectory() As DirectoryInfo
	End Function*/

	Function TotalFreeSpace() As QWord
		Dim totalFreeSpace As ULARGE_INTEGER
		If GetDiskFreeSpaceEx(m_DriveName, ByVal 0, ByVal 0, totalFreeSpace) Then
			Return (totalFreeSpace.HighPart << 32) Or totalFreeSpace.LowPart
		Else
			'IOException
		End If
	End Function

	Function TotalSize() As QWord
		Dim totalSize As ULARGE_INTEGER
		If GetDiskFreeSpaceEx(m_DriveName, ByVal 0, totalSize, ByVal 0) Then
			Return (totalSize.HighPart << 32) Or totalSize.LowPart
		Else
			'IOException
		End If
	End Function

	Function VolumeLabel() As String
		Dim volumeName[63] As TCHAR
		If GetVolumeInformation(m_DriveName, volumeName, 64, NULL, NULL, NULL, NULL, 0) Then
			Dim resultStr = New String( volumeName )
			Return resultStr
		Else
			'IOException
		End If
	End Function
End Class


End Namespace
End Namespace
